This is the only place that's needed. Everywhere else can use 'long'. This avoids a bunch of warnings from Clang about common standard library functions having the wrong prototypes.
Signed-off-by: Chip Davis cdavis@codeweavers.com --- include/msvcrt/corecrt.h | 5 +++++ include/msvcrt/math.h | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/include/msvcrt/corecrt.h b/include/msvcrt/corecrt.h index c88d3e0570d..10e60d564c3 100644 --- a/include/msvcrt/corecrt.h +++ b/include/msvcrt/corecrt.h @@ -142,8 +142,13 @@ #ifndef _MSVCRT_LONG_DEFINED #define _MSVCRT_LONG_DEFINED /* we need 32-bit longs even on 64-bit */ +#ifdef __LP64__ typedef int __msvcrt_long; typedef unsigned int __msvcrt_ulong; +#else +typedef long __msvcrt_long; +typedef unsigned long __msvcrt_ulong; +#endif #endif
#ifndef _INTPTR_T_DEFINED diff --git a/include/msvcrt/math.h b/include/msvcrt/math.h index 76601de853a..68b6922458f 100644 --- a/include/msvcrt/math.h +++ b/include/msvcrt/math.h @@ -96,10 +96,10 @@ float __cdecl rintf(float); float __cdecl roundf(float); float __cdecl truncf(float);
-long __cdecl lrint(double); -long __cdecl lrintf(float); -long __cdecl lround(double); -long __cdecl lroundf(float); +__msvcrt_long __cdecl lrint(double); +__msvcrt_long __cdecl lrintf(float); +__msvcrt_long __cdecl lround(double); +__msvcrt_long __cdecl lroundf(float);
double __cdecl _copysign (double, double); double __cdecl _chgsign (double);
These must use 'double' on Winelib, and 'long double' elsewhere. The latter avoids warnings from Clang about 'strtold(3)' having the wrong prototype.
Signed-off-by: Chip Davis cdavis@codeweavers.com --- include/msvcrt/corecrt.h | 10 ++++++++++ include/msvcrt/stdlib.h | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/msvcrt/corecrt.h b/include/msvcrt/corecrt.h index 10e60d564c3..311d2cb8270 100644 --- a/include/msvcrt/corecrt.h +++ b/include/msvcrt/corecrt.h @@ -151,6 +151,16 @@ typedef unsigned long __msvcrt_ulong; #endif #endif
+#ifndef _MSVCRT_LDOUBLE_DEFINED +#define _MSVCRT_LDOUBLE_DEFINED +/* we need 64-bit long doubles even on Unix */ +#ifdef __WINESRC__ +typedef double __msvcrt_ldouble; +#else +typedef long double __msvcrt_ldouble; +#endif +#endif + #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h index 91fcc2a672d..86f7b695de8 100644 --- a/include/msvcrt/stdlib.h +++ b/include/msvcrt/stdlib.h @@ -152,7 +152,7 @@ int __cdecl _atodbl_l(_CRT_DOUBLE*,char*,_locale_t); int __cdecl _atoflt(_CRT_FLOAT*,char*); int __cdecl _atoflt_l(_CRT_FLOAT*,char*,_locale_t); __int64 __cdecl _atoi64(const char*); -long double __cdecl _atold(const char*); +__msvcrt_ldouble __cdecl _atold(const char*); int __cdecl _atoldbl(_LDOUBLE*,char*); void __cdecl _beep(unsigned int,unsigned int); char* __cdecl _ecvt(double,int,int*,int*); @@ -180,7 +180,7 @@ int __cdecl _set_error_mode(int); void __cdecl _seterrormode(int); void __cdecl _sleep(__msvcrt_ulong); void __cdecl _splitpath(const char*,char*,char*,char*,char*); -long double __cdecl _strtold(const char*,char**); +__msvcrt_ldouble __cdecl _strtold(const char*,char**); void __cdecl _swab(char*,char*,int); char* __cdecl _ui64toa(unsigned __int64,char*,int); errno_t __cdecl _ui64toa_s(unsigned __int64,char*,size_t,int); @@ -217,7 +217,7 @@ void* __cdecl realloc(void*,size_t); void __cdecl srand(unsigned int); float __cdecl strtof(const char*,char**); double __cdecl strtod(const char*,char**); -double __cdecl strtold(const char*,char**); +__msvcrt_ldouble __cdecl strtold(const char*,char**); __msvcrt_long __cdecl strtol(const char*,char**,int); __msvcrt_ulong __cdecl strtoul(const char*,char**,int); __int64 __cdecl strtoll_l(const char*,char**,int,_locale_t);
Hi Chip,
Shouldn't we always use double? What's the reason for "long double" case?
Thanks, Piotr
November 25, 2019 4:44 AM, "Piotr Caban" piotr.caban@gmail.com wrote:
Hi Chip,
Shouldn't we always use double? What's the reason for "long double" case?
Clang complains when the return type of strtold(3) is double.
Thanks, Piotr
Chip
November 25, 2019 9:35 AM, "Chip Davis" cdavis@codeweavers.com wrote:
November 25, 2019 4:44 AM, "Piotr Caban" piotr.caban@gmail.com wrote:
Hi Chip,
Shouldn't we always use double? What's the reason for "long double" case?
Clang complains when the return type of strtold(3) is double.
Oh, now I remember: on MinGW, long double is 80 bits. Sorry, disregard this patch.
Thanks, Piotr
Chip
Chip