Piotr Caban : msvcrt: Import modff implementation from musl.
Alexandre Julliard
julliard at winehq.org
Tue May 18 15:42:38 CDT 2021
Module: wine
Branch: master
Commit: 29e99741d94517b1b17b300a0c7b85a1c0806a00
URL: https://source.winehq.org/git/wine.git/?a=commit;h=29e99741d94517b1b17b300a0c7b85a1c0806a00
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue May 18 19:08:44 2021 +0200
msvcrt: Import modff implementation from musl.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/math.c | 32 +++++++++++++++++++++++++++++++-
dlls/msvcrt/unixlib.c | 9 ---------
dlls/msvcrt/unixlib.h | 1 -
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index a860dfc3d2b..fab505abfb5 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -922,10 +922,40 @@ float CDECL frexpf( float x, int *exp )
/*********************************************************************
* modff (MSVCRT.@)
+ *
+ * Copied from musl: src/math/modff.c
*/
float CDECL modff( float x, float *iptr )
{
- return unix_funcs->modff( x, iptr );
+ union {float f; UINT32 i;} u = {x};
+ UINT32 mask;
+ int e = (u.i >> 23 & 0xff) - 0x7f;
+
+ /* no fractional part */
+ if (e >= 23) {
+ *iptr = x;
+ if (e == 0x80 && u.i << 9 != 0) { /* nan */
+ return x;
+ }
+ u.i &= 0x80000000;
+ return u.f;
+ }
+ /* no integral part */
+ if (e < 0) {
+ u.i &= 0x80000000;
+ *iptr = u.f;
+ return x;
+ }
+
+ mask = 0x007fffff >> e;
+ if ((u.i & mask) == 0) {
+ *iptr = x;
+ u.i &= 0x80000000;
+ return u.f;
+ }
+ u.i &= ~mask;
+ *iptr = u.f;
+ return x - u.f;
}
#endif
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index 2a3d8ed4090..62c6a5ae189 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -459,14 +459,6 @@ static float CDECL unix_logbf( float x )
return logbf( x );
}
-/*********************************************************************
- * modff
- */
-static float CDECL unix_modff( float x, float *iptr )
-{
- return modff( x, iptr );
-}
-
/*********************************************************************
* pow
*/
@@ -666,7 +658,6 @@ static const struct unix_funcs funcs =
unix_log2f,
unix_logb,
unix_logbf,
- unix_modff,
unix_pow,
unix_powf,
unix_remainder,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index 080c9da9d08..69f4e02f321 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -62,7 +62,6 @@ struct unix_funcs
float (CDECL *log2f)(float x);
double (CDECL *logb)(double x);
float (CDECL *logbf)(float x);
- float (CDECL *modff)(float x, float *iptr);
double (CDECL *pow)(double x, double y);
float (CDECL *powf)(float x, float y);
double (CDECL *remainder)(double x, double y);
More information about the wine-cvs
mailing list