-- v3: include: Fix wmemchr C++ warning. include: Fix InlineIsEqualGUID C++ warning. include: Add some _BitScanForward(64) declarations in intrin.h. include: Add a __shiftright128 intrinsic definition. include: Add a _umul128 intrinsic definition. include: Move FILE_DISPOSITION_INFO after DeleteFile(A|W). include: Add a MB_CUR_MAX definition in ctype.h.
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/ctype.h | 7 +++++++ include/msvcrt/stdlib.h | 3 +++ 2 files changed, 10 insertions(+)
diff --git a/include/msvcrt/ctype.h b/include/msvcrt/ctype.h index 88e79411f64..5cfe312ea6d 100644 --- a/include/msvcrt/ctype.h +++ b/include/msvcrt/ctype.h @@ -50,6 +50,13 @@ _ACRTIMP int __cdecl isxdigit(int); _ACRTIMP int __cdecl tolower(int); _ACRTIMP int __cdecl toupper(int);
+#ifndef MB_CUR_MAX +_ACRTIMP int __cdecl ___mb_cur_max_func(void); +_ACRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t); +#define __mb_cur_max ___mb_cur_max_func() +#define MB_CUR_MAX ___mb_cur_max_func() +#endif /* MB_CUR_MAX */ + #ifdef __cplusplus } #endif diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index 9cb8ccb110a..8d64246c0b5 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -121,10 +121,13 @@ extern unsigned int _fmode;
#endif /* __i386__ */
+#ifndef MB_CUR_MAX _ACRTIMP int __cdecl ___mb_cur_max_func(void); _ACRTIMP int __cdecl ___mb_cur_max_l_func(_locale_t); #define __mb_cur_max ___mb_cur_max_func() #define MB_CUR_MAX ___mb_cur_max_func() +#endif /* MB_CUR_MAX */ + _ACRTIMP __msvcrt_ulong* __cdecl __doserrno(void); #define _doserrno (*__doserrno()) _ACRTIMP int* __cdecl _errno(void);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/kernel32/tests/file.c | 2 -- include/winbase.h | 12 ++++++++---- 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index c57edebb316..fcfe42f359b 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -35,8 +35,6 @@ #include "winnls.h" #include "fileapi.h"
-#undef DeleteFile /* needed for FILE_DISPOSITION_INFO */ - static HANDLE (WINAPI *pFindFirstFileExA)(LPCSTR,FINDEX_INFO_LEVELS,LPVOID,FINDEX_SEARCH_OPS,LPVOID,DWORD); static BOOL (WINAPI *pReplaceFileW)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID); static UINT (WINAPI *pGetSystemWindowsDirectoryA)(LPSTR, UINT); diff --git a/include/winbase.h b/include/winbase.h index 40142b73b02..53aea48e290 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -852,10 +852,6 @@ typedef struct _FILE_ALLOCATION_INFO { LARGE_INTEGER AllocationSize; } FILE_ALLOCATION_INFO, *PFILE_ALLOCATION_INFO;
-typedef struct _FILE_DISPOSITION_INFO { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFO, *PFILE_DISPOSITION_INFO; - typedef struct _FILE_END_OF_FILE_INFO { LARGE_INTEGER EndOfFile; } FILE_END_OF_FILE_INFO, *PFILE_END_OF_FILE_INFO; @@ -2869,6 +2865,14 @@ WINBASEAPI INT WINAPI lstrcmpW(LPCWSTR,LPCWSTR); WINBASEAPI INT WINAPI lstrcmpiA(LPCSTR,LPCSTR); WINBASEAPI INT WINAPI lstrcmpiW(LPCWSTR,LPCWSTR);
+#ifdef WINE_NO_UNICODE_MACROS +#undef DeleteFile +#endif + +typedef struct _FILE_DISPOSITION_INFO { + BOOLEAN DeleteFile; +} FILE_DISPOSITION_INFO, *PFILE_DISPOSITION_INFO; + #if !defined(__WINESRC__) || defined(WINE_NO_INLINE_STRING)
WINBASEAPI LPSTR WINAPI lstrcatA(LPSTR,LPCSTR);
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/intrin.h | 4 ++++ include/winnt.h | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/include/msvcrt/intrin.h b/include/msvcrt/intrin.h index ba825b7b09e..03d856c5933 100644 --- a/include/msvcrt/intrin.h +++ b/include/msvcrt/intrin.h @@ -90,6 +90,10 @@ unsigned __int64 __getReg(int);
#endif
+#if defined(_MSC_VER) && defined(__x86_64__) +unsigned __int64 _umul128(unsigned __int64,unsigned __int64,unsigned __int64*); +#endif + #ifdef __cplusplus } #endif diff --git a/include/winnt.h b/include/winnt.h index c810830b2b3..481ee16df79 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -7397,6 +7397,26 @@ static FORCEINLINE void YieldProcessor(void) #endif }
+ +#ifdef __x86_64__ + +#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(_umul128)) +#define UnsignedMultiply128 _umul128 +DWORD64 _umul128(DWORD64,DWORD64,DWORD64*); +#pragma intrinsic(_umul128) +#else +static FORCEINLINE DWORD64 UnsignedMultiply128( DWORD64 a, DWORD64 b, DWORD64 *hi ) +{ + unsigned __int128 v = (unsigned __int128)a * b; + *hi = v >> 64; + return (DWORD64)v; +} +#define _umul128 UnsignedMultiply128 +#endif + +#endif /* __x86_64__ */ + + #ifdef __cplusplus } #endif
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/intrin.h | 4 ++++ include/winnt.h | 12 ++++++++++++ 2 files changed, 16 insertions(+)
diff --git a/include/msvcrt/intrin.h b/include/msvcrt/intrin.h index 03d856c5933..7d22f80ed81 100644 --- a/include/msvcrt/intrin.h +++ b/include/msvcrt/intrin.h @@ -90,6 +90,10 @@ unsigned __int64 __getReg(int);
#endif
+#if defined(_MSC_VER) && defined(__x86_64__) +unsigned __int64 __shiftright128(unsigned __int64,unsigned __int64,unsigned char); +#endif + #if defined(_MSC_VER) && defined(__x86_64__) unsigned __int64 _umul128(unsigned __int64,unsigned __int64,unsigned __int64*); #endif diff --git a/include/winnt.h b/include/winnt.h index 481ee16df79..c02798f321d 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -7400,6 +7400,18 @@ static FORCEINLINE void YieldProcessor(void)
#ifdef __x86_64__
+#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(__shiftright128)) +#define ShiftRight128 __shiftright128 +DWORD64 __shiftright128(DWORD64,DWORD64,BYTE); +#pragma intrinsic(__shiftright128) +#elif !defined(__i386__) +static FORCEINLINE DWORD64 ShiftRight128( DWORD64 lo, DWORD64 hi, BYTE shift ) +{ + return ((unsigned __int128)hi << 64 | lo) >> shift; +} +#define __shiftright128 ShiftRight128 +#endif + #if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(_umul128)) #define UnsignedMultiply128 _umul128 DWORD64 _umul128(DWORD64,DWORD64,DWORD64*);
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/intrin.h | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/include/msvcrt/intrin.h b/include/msvcrt/intrin.h index 7d22f80ed81..cc0ca07e8de 100644 --- a/include/msvcrt/intrin.h +++ b/include/msvcrt/intrin.h @@ -98,6 +98,14 @@ unsigned __int64 __shiftright128(unsigned __int64,unsigned __int64,unsigned char unsigned __int64 _umul128(unsigned __int64,unsigned __int64,unsigned __int64*); #endif
+#if defined(_MSC_VER) +unsigned char _BitScanForward(unsigned long*,unsigned long); +#endif + +#if defined(_MSC_VER) && defined(__x86_64__) || defined(__aarch64__) || defined(__arm64ec__) +unsigned char _BitScanForward64(unsigned long*,unsigned __int64); +#endif + #ifdef __cplusplus } #endif
From: Rémi Bernon rbernon@codeweavers.com
--- include/guiddef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/guiddef.h b/include/guiddef.h index 0837ed34ad7..06a4495ca99 100644 --- a/include/guiddef.h +++ b/include/guiddef.h @@ -158,10 +158,10 @@ typedef GUID FMTID,*LPFMTID; #define IsEqualGUID(rguid1, rguid2) (!memcmp(&(rguid1), &(rguid2), sizeof(GUID))) inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2) { - return (((unsigned int *)&rguid1)[0] == ((unsigned int *)&rguid2)[0] && - ((unsigned int *)&rguid1)[1] == ((unsigned int *)&rguid2)[1] && - ((unsigned int *)&rguid1)[2] == ((unsigned int *)&rguid2)[2] && - ((unsigned int *)&rguid1)[3] == ((unsigned int *)&rguid2)[3]); + return (((const UINT *)&rguid1)[0] == ((const UINT *)&rguid2)[0] && + ((const UINT *)&rguid1)[1] == ((const UINT *)&rguid2)[1] && + ((const UINT *)&rguid1)[2] == ((const UINT *)&rguid2)[2] && + ((const UINT *)&rguid1)[3] == ((const UINT *)&rguid2)[3]); } #else #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
From: Rémi Bernon rbernon@codeweavers.com
--- include/msvcrt/corecrt.h | 9 +++++++++ include/msvcrt/wchar.h | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/include/msvcrt/corecrt.h b/include/msvcrt/corecrt.h index 65357a13403..ae926394ad9 100644 --- a/include/msvcrt/corecrt.h +++ b/include/msvcrt/corecrt.h @@ -250,6 +250,15 @@ typedef int errno_t; #define _ERRNO_T_DEFINED #endif
+#ifndef _CONST_RETURN +# ifdef __cplusplus +# define _CONST_RETURN const +# define _CRT_CONST_CORRECT_OVERLOADS +# else +# define _CONST_RETURN +# endif +#endif + struct threadlocaleinfostruct; struct threadmbcinfostruct; typedef struct threadlocaleinfostruct *pthreadlocinfo; diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h index 4ca189bd2c7..98167b59076 100644 --- a/include/msvcrt/wchar.h +++ b/include/msvcrt/wchar.h @@ -45,14 +45,22 @@ int __cdecl wctob(wint_t);
_ACRTIMP errno_t __cdecl wmemcpy_s(wchar_t *, size_t, const wchar_t *, size_t);
-static inline wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) +static inline _CONST_RETURN wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n) { const wchar_t *end; for (end = s + n; s < end; s++) - if (*s == c) return (wchar_t*)s; + if (*s == c) return (_CONST_RETURN wchar_t *)s; return NULL; }
+#ifdef __cplusplus +extern "C++" inline wchar_t *wmemchr(wchar_t *s, wchar_t c, size_t n) +{ + wchar_t const* s_const = s; + return const_cast<wchar_t *>(wmemchr(s_const, c, n)); +} +#endif + static inline int wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) { size_t i;
On Tue Nov 12 15:12:19 2024 +0000, Rémi Bernon wrote:
changed this line in [version 3 of the diff](/wine/wine/-/merge_requests/6752/diffs?diff_id=142670&start_sha=2adb566d708e7d9405fdca175efd49bb90792bff#380b090c85ec3d245329091d41adf928416dac8f_7404_7419)
Added a `__x86_64__` guard around it.
On Mon Nov 4 17:47:50 2024 +0000, Jacek Caban wrote:
Actually, that part may be fine.
I'm not sure what you meant with redundant?
v3: Rebased and add a `__x86_64__` guard around `UnsignedMultiply128` and `ShiftRight128`, reordered them to alphabetical order as they are in the SDK.
Jacek Caban (@jacek) commented about include/msvcrt/intrin.h:
unsigned __int64 _umul128(unsigned __int64,unsigned __int64,unsigned __int64*); #endif
+#if defined(_MSC_VER) +unsigned char _BitScanForward(unsigned long*,unsigned long); +#endif
+#if defined(_MSC_VER) && defined(__x86_64__) || defined(__aarch64__) || defined(__arm64ec__)
`__arm64ec__` check here is not needed, ARM64EC target defines `__x86_64__` as well. Also, it's missing brackets around `||` cases.
Jacek Caban (@jacek) commented about include/winnt.h:
#ifdef __x86_64__
+#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(__shiftright128)) +#define ShiftRight128 __shiftright128 +DWORD64 __shiftright128(DWORD64,DWORD64,BYTE); +#pragma intrinsic(__shiftright128) +#elif !defined(__i386__)
It's in `__x86_64__` `#ifdef` now, so this is a no-op check. From what I can see, `ShiftRight128` should be defined on ARM64 too, through.
Jacek Caban (@jacek) commented about include/winnt.h:
#endif }
+#ifdef __x86_64__
As far as I can see, `UnsignedMultiply128` should be available on ARM64 too, my comment was only about `_umul128`.