[PATCH v2 0/2] MR10123: include: Use -mlong-double-64 and add long double math function declarations.
As an alternative, I tried using double instead of long double in those declarations. This is problematic for some of them, because compilers recognize their signatures (for builtin handling) and warn when they do not match. We could make most of those functions inline wrappers around the double variants, but that is not really feasible for some of them, such as `nexttoward`. `long double` is already 64-bit in Clang MSVC mode. The `-mlong-double-64` option also appears to be supported on mingw as well as on Unix GCC and Clang. -- v2: include: Add long double math function declarations. https://gitlab.winehq.org/wine/wine/-/merge_requests/10123
From: Jacek Caban <jacek@codeweavers.com> --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 3137bc9a806..473fd09ffc6 100644 --- a/configure.ac +++ b/configure.ac @@ -569,6 +569,7 @@ This is an error since --enable-archs=$wine_arch was requested.])]) WINE_TRY_PE_CFLAGS([-ffunction-sections]) WINE_TRY_PE_CFLAGS([-fasync-exceptions -DMIN_CLANG_VERSION=19], AS_VAR_APPEND([${wine_arch}_EXTRACFLAGS],[" -fasync-exceptions"])) WINE_TRY_PE_CFLAGS([-ffp-exception-behavior=maytrap]) + WINE_TRY_PE_CFLAGS([-mlong-double-64]) dnl clang had broken -fms-hotpatch support before version 18 (https://github.com/llvm/llvm-project/pull/77245) WINE_TRY_PE_CFLAGS([-fms-hotpatch -DMIN_CLANG_VERSION=18], @@ -2016,6 +2017,7 @@ then mingw32*) dnl Check for delayload linker support WINE_TRY_CFLAGS([-Wl,-delayload,autoconftest.dll],[AC_SUBST(DELAYLOADFLAG,["-Wl,-delayload,"])]) ;; *) MSVCRTFLAGS="-D_WIN32" + WINE_TRY_CFLAGS([-mlong-double-64],[MSVCRTFLAGS="$MSVCRTFLAGS -mlong-double-64"]) WINE_TRY_CFLAGS([-fno-builtin],[MSVCRTFLAGS="$MSVCRTFLAGS -fno-builtin"]) WINE_TRY_CFLAGS([-fshort-wchar],[MSVCRTFLAGS="$MSVCRTFLAGS -fshort-wchar"]) WINE_TRY_CFLAGS([-Wno-format],[MSVCRTFLAGS="$MSVCRTFLAGS -Wno-format"]) ;; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10123
From: Jacek Caban <jacek@codeweavers.com> --- dlls/msvcr120/tests/msvcr120.c | 4 --- include/msvcrt/math.h | 66 +++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/dlls/msvcr120/tests/msvcr120.c b/dlls/msvcr120/tests/msvcr120.c index 856e9251e61..67a534247e2 100644 --- a/dlls/msvcr120/tests/msvcr120.c +++ b/dlls/msvcr120/tests/msvcr120.c @@ -38,10 +38,6 @@ #include <locale.h> -_ACRTIMP float __cdecl nexttowardf(float, double); -_ACRTIMP double __cdecl nexttoward(double, double); -_ACRTIMP double __cdecl nexttowardl(double, double); - #define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF) #ifdef __i386__ diff --git a/include/msvcrt/math.h b/include/msvcrt/math.h index 39d285eeb64..11f3fa9644e 100644 --- a/include/msvcrt/math.h +++ b/include/msvcrt/math.h @@ -431,6 +431,70 @@ static inline double y1( double x ) { return _y1( x ); } static inline double yn( int n, double x ) { return _yn( n, x ); } static inline float hypotf( float x, float y ) { return _hypotf( x, y ); } -static inline long double atan2l( long double x, long double y ) { return atan2( (double)y, (double)x ); } +#if !defined(__SIZEOF_LONG_DOUBLE__) || __SIZEOF_LONG_DOUBLE__ == 8 + +_ACRTIMP float __cdecl nexttowardf(float, long double); +_ACRTIMP double __cdecl nexttoward(double, long double); +_ACRTIMP long double __cdecl nexttowardl(long double, long double); + +_ACRTIMP long double __cdecl acoshl(long double); +_ACRTIMP long double __cdecl asinhl(long double); +_ACRTIMP long double __cdecl atanhl(long double); +_ACRTIMP long double __cdecl cbrtl(long double); +_ACRTIMP long double __cdecl copysignl(long double, long double); +_ACRTIMP long double __cdecl coshl(long double); +_ACRTIMP long double __cdecl erfcl(long double); +_ACRTIMP long double __cdecl erfl(long double); +_ACRTIMP long double __cdecl exp2l(long double); +_ACRTIMP long double __cdecl expm1l(long double); +_ACRTIMP long double __cdecl fdiml(long double, long double); +_ACRTIMP long double __cdecl fmal(long double, long double, long double); +_ACRTIMP long double __cdecl fmaxl(long double, long double); +_ACRTIMP long double __cdecl fminl(long double, long double); +_ACRTIMP int __cdecl ilogbl(long double); +_ACRTIMP long double __cdecl lgammal(long double); +_ACRTIMP __int64 __cdecl llrintl(long double); +_ACRTIMP __int64 __cdecl llroundl(long double); +_ACRTIMP __msvcrt_long __cdecl lrintl(long double); +_ACRTIMP __msvcrt_long __cdecl lroundl(long double); +_ACRTIMP long double __cdecl log1pl(long double); +_ACRTIMP long double __cdecl log2l(long double); +_ACRTIMP long double __cdecl logbl(long double); +_ACRTIMP long double __cdecl nanl(const char *); +_ACRTIMP long double __cdecl nearbyintl(long double); +_ACRTIMP long double __cdecl nextafterl(long double, long double); +_ACRTIMP long double __cdecl remainderl(long double, long double); +_ACRTIMP long double __cdecl remquol(long double, long double, int *); +_ACRTIMP long double __cdecl rintl(long double); +_ACRTIMP long double __cdecl roundl(long double); +_ACRTIMP long double __cdecl scalblnl(long double, __msvcrt_long); +_ACRTIMP long double __cdecl scalbnl(long double, int); +_ACRTIMP long double __cdecl tgammal(long double); +_ACRTIMP long double __cdecl truncl(long double); + +static inline long double acosl(long double x) { return acos(x); } +static inline long double asinl(long double x) { return asin(x); } +static inline long double atan2l(long double y, long double x) { return atan2(y, x); } +static inline long double atanl(long double x) { return atan(x); } +static inline long double ceill(long double x) { return ceil(x); } +static inline long double cosl(long double x) { return cos(x); } +static inline long double expl(long double x) { return exp(x); } +static inline long double fabsl(long double x) { return fabs(x); } +static inline long double floorl(long double x) { return floor(x); } +static inline long double fmodl(long double x, long double y) { return fmod(x, y); } +static inline long double frexpl(long double x, int *y) { return frexp(x, y); } +static inline long double hypotl(long double x, long double y) { return _hypot(x, y); } +static inline long double ldexpl(long double x, int y) { return ldexp(x, y); } +static inline long double log10l(long double x) { return log10(x); } +static inline long double logl(long double x) { return log(x); } +static inline long double modfl(long double x, long double *y) { return modf(x, (double *)y); } +static inline long double powl(long double x, long double y) { return pow(x, y); } +static inline long double sinhl(long double x) { return sinh(x); } +static inline long double sinl(long double x) { return sin(x); } +static inline long double sqrtl(long double x) { return sqrt(x); } +static inline long double tanhl(long double x) { return tanh(x); } +static inline long double tanl(long double x) { return tan(x); } + +#endif #endif /* __WINE_MATH_H */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10123
participants (2)
-
Jacek Caban -
Jacek Caban (@jacek)