This fixes LLVM ASAN an the ASAN then works as expected with Wine. Would something like this be acceptable for upstream?
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50993 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/ntdll/string.c | 98 ++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 49 deletions(-)
diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c index 0fa83821d21..7370bf3631b 100644 --- a/dlls/ntdll/string.c +++ b/dlls/ntdll/string.c @@ -69,7 +69,7 @@ static const unsigned short ctypes[257] = /********************************************************************* * memchr (NTDLL.@) */ -void * __cdecl memchr( const void *ptr, int c, size_t n ) +void * __cdecl DECLSPEC_HOTPATCH memchr( const void *ptr, int c, size_t n ) { const unsigned char *p = ptr;
@@ -81,7 +81,7 @@ void * __cdecl memchr( const void *ptr, int c, size_t n ) /********************************************************************* * memcmp (NTDLL.@) */ -int __cdecl memcmp( const void *ptr1, const void *ptr2, size_t n ) +int __cdecl DECLSPEC_HOTPATCH memcmp( const void *ptr1, const void *ptr2, size_t n ) { const unsigned char *p1, *p2;
@@ -100,7 +100,7 @@ int __cdecl memcmp( const void *ptr1, const void *ptr2, size_t n ) * NOTES * Behaves like memmove. */ -void * __cdecl memcpy( void *dst, const void *src, size_t n ) +void * __cdecl DECLSPEC_HOTPATCH memcpy( void *dst, const void *src, size_t n ) { volatile unsigned char *d = dst; /* avoid gcc optimizations */ const unsigned char *s = src; @@ -122,7 +122,7 @@ void * __cdecl memcpy( void *dst, const void *src, size_t n ) /********************************************************************* * memmove (NTDLL.@) */ -void * __cdecl memmove( void *dst, const void *src, size_t n ) +void * __cdecl DECLSPEC_HOTPATCH memmove( void *dst, const void *src, size_t n ) { volatile unsigned char *d = dst; /* avoid gcc optimizations */ const unsigned char *s = src; @@ -157,7 +157,7 @@ static inline void memset_aligned_32( unsigned char *d, uint64_t v, size_t n ) /********************************************************************* * memset (NTDLL.@) */ -void *__cdecl memset( void *dst, int c, size_t n ) +void *__cdecl DECLSPEC_HOTPATCH memset( void *dst, int c, size_t n ) { typedef uint64_t DECLSPEC_ALIGN(1) unaligned_ui64; typedef uint32_t DECLSPEC_ALIGN(1) unaligned_ui32; @@ -214,7 +214,7 @@ void *__cdecl memset( void *dst, int c, size_t n ) /********************************************************************* * strcat (NTDLL.@) */ -char * __cdecl strcat( char *dst, const char *src ) +char * __cdecl DECLSPEC_HOTPATCH strcat( char *dst, const char *src ) { char *d = dst; while (*d) d++; @@ -226,7 +226,7 @@ char * __cdecl strcat( char *dst, const char *src ) /********************************************************************* * strchr (NTDLL.@) */ -char * __cdecl strchr( const char *str, int c ) +char * __cdecl DECLSPEC_HOTPATCH strchr( const char *str, int c ) { do { if (*str == (char)c) return (char *)(ULONG_PTR)str; } while (*str++); return NULL; @@ -236,7 +236,7 @@ char * __cdecl strchr( const char *str, int c ) /********************************************************************* * strcmp (NTDLL.@) */ -int __cdecl strcmp( const char *str1, const char *str2 ) +int __cdecl DECLSPEC_HOTPATCH strcmp( const char *str1, const char *str2 ) { while (*str1 && *str1 == *str2) { str1++; str2++; } if ((unsigned char)*str1 > (unsigned char)*str2) return 1; @@ -248,7 +248,7 @@ int __cdecl strcmp( const char *str1, const char *str2 ) /********************************************************************* * strcpy (NTDLL.@) */ -char * __cdecl strcpy( char *dst, const char *src ) +char * __cdecl DECLSPEC_HOTPATCH strcpy( char *dst, const char *src ) { char *d = dst; while ((*d++ = *src++)); @@ -259,7 +259,7 @@ char * __cdecl strcpy( char *dst, const char *src ) /********************************************************************* * strcspn (NTDLL.@) */ -size_t __cdecl strcspn( const char *str, const char *reject ) +size_t __cdecl DECLSPEC_HOTPATCH strcspn( const char *str, const char *reject ) { const char *ptr; for (ptr = str; *ptr; ptr++) if (strchr( reject, *ptr )) break; @@ -270,7 +270,7 @@ size_t __cdecl strcspn( const char *str, const char *reject ) /********************************************************************* * strlen (NTDLL.@) */ -size_t __cdecl strlen( const char *str ) +size_t __cdecl DECLSPEC_HOTPATCH strlen( const char *str ) { const char *s = str; while (*s) s++; @@ -281,7 +281,7 @@ size_t __cdecl strlen( const char *str ) /********************************************************************* * strncat (NTDLL.@) */ -char * __cdecl strncat( char *dst, const char *src, size_t len ) +char * __cdecl DECLSPEC_HOTPATCH strncat( char *dst, const char *src, size_t len ) { char *d = dst; while (*d) d++; @@ -294,7 +294,7 @@ char * __cdecl strncat( char *dst, const char *src, size_t len ) /********************************************************************* * strncmp (NTDLL.@) */ -int __cdecl strncmp( const char *str1, const char *str2, size_t len ) +int __cdecl DECLSPEC_HOTPATCH strncmp( const char *str1, const char *str2, size_t len ) { if (!len) return 0; while (--len && *str1 && *str1 == *str2) { str1++; str2++; } @@ -306,7 +306,7 @@ int __cdecl strncmp( const char *str1, const char *str2, size_t len ) * strncpy (NTDLL.@) */ #undef strncpy -char * __cdecl strncpy( char *dst, const char *src, size_t len ) +char * __cdecl DECLSPEC_HOTPATCH strncpy( char *dst, const char *src, size_t len ) { char *d; for (d = dst; len && *src; d++, src++, len--) *d = *src; @@ -318,7 +318,7 @@ char * __cdecl strncpy( char *dst, const char *src, size_t len ) /********************************************************************* * strnlen (NTDLL.@) */ -size_t __cdecl strnlen( const char *str, size_t len ) +size_t __cdecl DECLSPEC_HOTPATCH strnlen( const char *str, size_t len ) { const char *s = str; for (s = str; len && *s; s++, len--) ; @@ -329,7 +329,7 @@ size_t __cdecl strnlen( const char *str, size_t len ) /********************************************************************* * strpbrk (NTDLL.@) */ -char * __cdecl strpbrk( const char *str, const char *accept ) +char * __cdecl DECLSPEC_HOTPATCH strpbrk( const char *str, const char *accept ) { for ( ; *str; str++) if (strchr( accept, *str )) return (char *)(ULONG_PTR)str; return NULL; @@ -339,7 +339,7 @@ char * __cdecl strpbrk( const char *str, const char *accept ) /********************************************************************* * strrchr (NTDLL.@) */ -char * __cdecl strrchr( const char *str, int c ) +char * __cdecl DECLSPEC_HOTPATCH strrchr( const char *str, int c ) { char *ret = NULL; do { if (*str == (char)c) ret = (char *)(ULONG_PTR)str; } while (*str++); @@ -350,7 +350,7 @@ char * __cdecl strrchr( const char *str, int c ) /********************************************************************* * strspn (NTDLL.@) */ -size_t __cdecl strspn( const char *str, const char *accept ) +size_t __cdecl DECLSPEC_HOTPATCH strspn( const char *str, const char *accept ) { const char *ptr; for (ptr = str; *ptr; ptr++) if (!strchr( accept, *ptr )) break; @@ -361,7 +361,7 @@ size_t __cdecl strspn( const char *str, const char *accept ) /********************************************************************* * strstr (NTDLL.@) */ -char * __cdecl strstr( const char *str, const char *sub ) +char * __cdecl DECLSPEC_HOTPATCH strstr( const char *str, const char *sub ) { while (*str) { @@ -377,7 +377,7 @@ char * __cdecl strstr( const char *str, const char *sub ) /********************************************************************* * _memccpy (NTDLL.@) */ -void * __cdecl _memccpy( void *dst, const void *src, int c, size_t n ) +void * __cdecl DECLSPEC_HOTPATCH _memccpy( void *dst, const void *src, int c, size_t n ) { unsigned char *d = dst; const unsigned char *s = src; @@ -389,7 +389,7 @@ void * __cdecl _memccpy( void *dst, const void *src, int c, size_t n ) /********************************************************************* * tolower (NTDLL.@) */ -int __cdecl tolower( int c ) +int __cdecl DECLSPEC_HOTPATCH tolower( int c ) { return (char)c >= 'A' && (char)c <= 'Z' ? c - 'A' + 'a' : c; } @@ -413,7 +413,7 @@ int __cdecl tolower( int c ) * Any Nul characters in s1 or s2 are ignored. This function always * compares up to len bytes or the first place where s1 and s2 differ. */ -int __cdecl _memicmp( const void *str1, const void *str2, size_t len ) +int __cdecl DECLSPEC_HOTPATCH _memicmp( const void *str1, const void *str2, size_t len ) { const unsigned char *s1 = str1, *s2 = str2; int ret = 0; @@ -430,7 +430,7 @@ int __cdecl _memicmp( const void *str1, const void *str2, size_t len ) /********************************************************************* * _strnicmp (NTDLL.@) */ -int __cdecl _strnicmp( LPCSTR str1, LPCSTR str2, size_t n ) +int __cdecl DECLSPEC_HOTPATCH _strnicmp( LPCSTR str1, LPCSTR str2, size_t n ) { int l1, l2;
@@ -455,7 +455,7 @@ int __cdecl _strnicmp( LPCSTR str1, LPCSTR str2, size_t n ) * _stricmp (NTDLL.@) * _strcmpi (NTDLL.@) */ -int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 ) +int __cdecl DECLSPEC_HOTPATCH _stricmp( LPCSTR str1, LPCSTR str2 ) { return _strnicmp( str1, str2, -1 ); } @@ -473,7 +473,7 @@ int __cdecl _stricmp( LPCSTR str1, LPCSTR str2 ) * str. There is no error return, if str is NULL or invalid, this * function will crash. */ -LPSTR __cdecl _strupr( LPSTR str ) +LPSTR __cdecl DECLSPEC_HOTPATCH _strupr( LPSTR str ) { LPSTR ret = str; for ( ; *str; str++) *str = RtlUpperChar(*str); @@ -493,7 +493,7 @@ LPSTR __cdecl _strupr( LPSTR str ) * str. There is no error return, if str is NULL or invalid, this * function will crash. */ -LPSTR __cdecl _strlwr( LPSTR str ) +LPSTR __cdecl DECLSPEC_HOTPATCH _strlwr( LPSTR str ) { LPSTR ret = str; for ( ; *str; str++) *str = tolower(*str); @@ -504,7 +504,7 @@ LPSTR __cdecl _strlwr( LPSTR str ) /********************************************************************* * toupper (NTDLL.@) */ -int __cdecl toupper( int c ) +int __cdecl DECLSPEC_HOTPATCH toupper( int c ) { char str[2], *p = str; WCHAR wc; @@ -523,7 +523,7 @@ int __cdecl toupper( int c ) /********************************************************************* * isalnum (NTDLL.@) */ -int __cdecl isalnum( int c ) +int __cdecl DECLSPEC_HOTPATCH isalnum( int c ) { return ctypes[c + 1] & (C1_LOWER | C1_UPPER | C1_DIGIT); } @@ -532,7 +532,7 @@ int __cdecl isalnum( int c ) /********************************************************************* * isalpha (NTDLL.@) */ -int __cdecl isalpha( int c ) +int __cdecl DECLSPEC_HOTPATCH isalpha( int c ) { return ctypes[c + 1] & (C1_LOWER | C1_UPPER); } @@ -541,7 +541,7 @@ int __cdecl isalpha( int c ) /********************************************************************* * iscntrl (NTDLL.@) */ -int __cdecl iscntrl( int c ) +int __cdecl DECLSPEC_HOTPATCH iscntrl( int c ) { return ctypes[c + 1] & C1_CNTRL; } @@ -550,7 +550,7 @@ int __cdecl iscntrl( int c ) /********************************************************************* * isdigit (NTDLL.@) */ -int __cdecl isdigit( int c ) +int __cdecl DECLSPEC_HOTPATCH isdigit( int c ) { return ctypes[c + 1] & C1_DIGIT; } @@ -559,7 +559,7 @@ int __cdecl isdigit( int c ) /********************************************************************* * isgraph (NTDLL.@) */ -int __cdecl isgraph( int c ) +int __cdecl DECLSPEC_HOTPATCH isgraph( int c ) { return ctypes[c + 1] & (C1_LOWER | C1_UPPER | C1_DIGIT | C1_PUNCT); } @@ -568,7 +568,7 @@ int __cdecl isgraph( int c ) /********************************************************************* * islower (NTDLL.@) */ -int __cdecl islower( int c ) +int __cdecl DECLSPEC_HOTPATCH islower( int c ) { return ctypes[c + 1] & C1_LOWER; } @@ -577,7 +577,7 @@ int __cdecl islower( int c ) /********************************************************************* * isprint (NTDLL.@) */ -int __cdecl isprint( int c ) +int __cdecl DECLSPEC_HOTPATCH isprint( int c ) { return ctypes[c + 1] & (C1_LOWER | C1_UPPER | C1_DIGIT | C1_PUNCT | C1_BLANK); } @@ -586,7 +586,7 @@ int __cdecl isprint( int c ) /********************************************************************* * ispunct (NTDLL.@) */ -int __cdecl ispunct( int c ) +int __cdecl DECLSPEC_HOTPATCH ispunct( int c ) { return ctypes[c + 1] & C1_PUNCT; } @@ -595,7 +595,7 @@ int __cdecl ispunct( int c ) /********************************************************************* * isspace (NTDLL.@) */ -int __cdecl isspace( int c ) +int __cdecl DECLSPEC_HOTPATCH isspace( int c ) { return ctypes[c + 1] & C1_SPACE; } @@ -604,7 +604,7 @@ int __cdecl isspace( int c ) /********************************************************************* * isupper (NTDLL.@) */ -int __cdecl isupper( int c ) +int __cdecl DECLSPEC_HOTPATCH isupper( int c ) { return ctypes[c + 1] & C1_UPPER; } @@ -613,7 +613,7 @@ int __cdecl isupper( int c ) /********************************************************************* * isxdigit (NTDLL.@) */ -int __cdecl isxdigit( int c ) +int __cdecl DECLSPEC_HOTPATCH isxdigit( int c ) { return ctypes[c + 1] & C1_XDIGIT; } @@ -684,7 +684,7 @@ static int char_to_int( char c ) /********************************************************************* * strtol (NTDLL.@) */ -__msvcrt_long __cdecl strtol( const char *s, char **end, int base ) +__msvcrt_long __cdecl DECLSPEC_HOTPATCH strtol( const char *s, char **end, int base ) { BOOL negative = FALSE, empty = TRUE; LONG ret = 0; @@ -731,7 +731,7 @@ __msvcrt_long __cdecl strtol( const char *s, char **end, int base ) /********************************************************************* * strtoul (NTDLL.@) */ -__msvcrt_ulong __cdecl strtoul( const char *s, char **end, int base ) +__msvcrt_ulong __cdecl DECLSPEC_HOTPATCH strtoul( const char *s, char **end, int base ) { BOOL negative = FALSE, empty = TRUE; ULONG ret = 0; @@ -786,7 +786,7 @@ __msvcrt_ulong __cdecl strtoul( const char *s, char **end, int base ) * - Does not check if radix is in the range of 2 to 36. * - If str is NULL it crashes, as the native function does. */ -char * __cdecl _ultoa( __msvcrt_ulong value, char *str, int radix ) +char * __cdecl DECLSPEC_HOTPATCH _ultoa( __msvcrt_ulong value, char *str, int radix ) { char buffer[33]; char *pos; @@ -825,7 +825,7 @@ char * __cdecl _ultoa( __msvcrt_ulong value, char *str, int radix ) * - Does not check if radix is in the range of 2 to 36. * - If str is NULL it crashes, as the native function does. */ -char * __cdecl _ltoa( __msvcrt_long value, char *str, int radix ) +char * __cdecl DECLSPEC_HOTPATCH _ltoa( __msvcrt_long value, char *str, int radix ) { ULONG val; int negative; @@ -878,7 +878,7 @@ char * __cdecl _ltoa( __msvcrt_long value, char *str, int radix ) * - Does not check if radix is in the range of 2 to 36. * - If str is NULL it crashes, as the native function does. */ -char * __cdecl _itoa( +char * __cdecl DECLSPEC_HOTPATCH _itoa( int value, /* [I] Value to be converted */ char *str, /* [O] Destination for the converted value */ int radix) /* [I] Number base for conversion */ @@ -901,7 +901,7 @@ char * __cdecl _itoa( * - Does not check if radix is in the range of 2 to 36. * - If str is NULL it crashes, as the native function does. */ -char * __cdecl _ui64toa( +char * __cdecl DECLSPEC_HOTPATCH _ui64toa( ULONGLONG value, /* [I] Value to be converted */ char *str, /* [O] Destination for the converted value */ int radix) /* [I] Number base for conversion */ @@ -952,7 +952,7 @@ char * __cdecl _ui64toa( * The native msvcrt _i64toa function and our ntdll _i64toa function * do not have this bug. */ -char * __cdecl _i64toa( +char * __cdecl DECLSPEC_HOTPATCH _i64toa( LONGLONG value, /* [I] Value to be converted */ char *str, /* [O] Destination for the converted value */ int radix) /* [I] Number base for conversion */ @@ -1011,7 +1011,7 @@ char * __cdecl _i64toa( * - No check is made for value overflow, only the lower 64 bits are assigned. * - If str is NULL it crashes, as the native function does. */ -LONGLONG __cdecl _atoi64( const char *str ) +LONGLONG __cdecl DECLSPEC_HOTPATCH _atoi64( const char *str ) { ULONGLONG RunningTotal = 0; BOOL bMinus = FALSE; @@ -1039,7 +1039,7 @@ LONGLONG __cdecl _atoi64( const char *str ) /********************************************************************* * atoi (NTDLL.@) */ -int __cdecl atoi( const char *nptr ) +int __cdecl DECLSPEC_HOTPATCH atoi( const char *nptr ) { return _atoi64( nptr ); } @@ -1048,7 +1048,7 @@ int __cdecl atoi( const char *nptr ) /********************************************************************* * atol (NTDLL.@) */ -__msvcrt_long __cdecl atol( const char *nptr ) +__msvcrt_long __cdecl DECLSPEC_HOTPATCH atol( const char *nptr ) { return _atoi64( nptr ); } @@ -1528,7 +1528,7 @@ int WINAPIV sscanf( const char *str, const char *format, ... ) * RETURNS * Nothing. */ -void __cdecl _splitpath(const char* inpath, char * drv, char * dir, +void __cdecl DECLSPEC_HOTPATCH _splitpath(const char* inpath, char * drv, char * dir, char* fname, char * ext ) { const char *p, *end;