-- v2: 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 c775ab71694..2003210ec19 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; @@ -2867,6 +2863,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 | 14 ++++++++++++++ 2 files changed, 18 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..794970a35f5 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -7397,6 +7397,20 @@ static FORCEINLINE void YieldProcessor(void) #endif }
+#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(_umul128)) +#define UnsignedMultiply128 _umul128 +DWORD64 _umul128(DWORD64,DWORD64,DWORD64*); +#pragma intrinsic(_umul128) +#elif !defined(__i386__) +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 + #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..1be630b5753 100644 --- a/include/msvcrt/intrin.h +++ b/include/msvcrt/intrin.h @@ -94,6 +94,10 @@ unsigned __int64 __getReg(int); unsigned __int64 _umul128(unsigned __int64,unsigned __int64,unsigned __int64*); #endif
+#if defined(_MSC_VER) && defined(__x86_64__) +unsigned __int64 __shiftright128(unsigned __int64,unsigned __int64,unsigned char); +#endif + #ifdef __cplusplus } #endif diff --git a/include/winnt.h b/include/winnt.h index 794970a35f5..667be50b17f 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -7411,6 +7411,18 @@ static FORCEINLINE DWORD64 UnsignedMultiply128( DWORD64 a, DWORD64 b, DWORD64 *h #define _umul128 UnsignedMultiply128 #endif
+#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 + #ifdef __cplusplus } #endif
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 1be630b5753..2a5de49fc73 100644 --- a/include/msvcrt/intrin.h +++ b/include/msvcrt/intrin.h @@ -98,6 +98,14 @@ unsigned __int64 _umul128(unsigned __int64,unsigned __int64,unsigned __int64*); unsigned __int64 __shiftright128(unsigned __int64,unsigned __int64,unsigned char); #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;
Jacek Caban (@jacek) commented about include/winnt.h:
#endif }
+#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(_umul128)) +#define UnsignedMultiply128 _umul128 +DWORD64 _umul128(DWORD64,DWORD64,DWORD64*); +#pragma intrinsic(_umul128) +#elif !defined(__i386__)
As far as I can see, it should be available `UnsignedMultiply128` is not available for 32-bit ARM in winsdk.
Jacek Caban (@jacek) commented about include/winnt.h:
#endif }
+#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(_umul128)) +#define UnsignedMultiply128 _umul128 +DWORD64 _umul128(DWORD64,DWORD64,DWORD64*); +#pragma intrinsic(_umul128) +#elif !defined(__i386__) +static FORCEINLINE DWORD64 UnsignedMultiply128( DWORD64 a, DWORD64 b, DWORD64 *hi ) +{
- unsigned __int128 v = (unsigned __int128)a * b;
`__int128` would be a new requirement for the compiler and seems redundant.
Jacek Caban (@jacek) commented about include/winnt.h:
#endif }
+#if defined(_MSC_VER) && !defined(__arm64ec__) && (!defined(__clang__) || __has_builtin(_umul128)) +#define UnsignedMultiply128 _umul128 +DWORD64 _umul128(DWORD64,DWORD64,DWORD64*); +#pragma intrinsic(_umul128) +#elif !defined(__i386__) +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
I think this should be available only for x86_64 target.
On Mon Nov 4 15:52:24 2024 +0000, Jacek Caban wrote:
`__int128` would be a new requirement for the compiler and seems redundant.
Actually, that part may be fine.