Piotr Caban : msvcrt: Import ceil implementation from musl.
Alexandre Julliard
julliard at winehq.org
Mon May 17 15:45:30 CDT 2021
Module: wine
Branch: master
Commit: 2a5e68ab807939b1b5b1484a189717b659b0a28e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2a5e68ab807939b1b5b1484a189717b659b0a28e
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon May 17 15:38:01 2021 +0200
msvcrt: Import ceil 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 | 23 ++++++++++++++++++++++-
dlls/msvcrt/unixlib.c | 9 ---------
dlls/msvcrt/unixlib.h | 1 -
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 3c4abd5630c..a4dd61f881c 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -1740,10 +1740,31 @@ float CDECL _hypotf(float x, float y)
/*********************************************************************
* ceil (MSVCRT.@)
+ *
+ * Based on musl: src/math/ceilf.c
*/
double CDECL ceil( double x )
{
- return unix_funcs->ceil(x);
+ union {double f; UINT64 i;} u = {x};
+ int e = (u.i >> 52 & 0x7ff) - 0x3ff;
+ UINT64 m;
+
+ if (e >= 52)
+ return x;
+ if (e >= 0) {
+ m = 0x000fffffffffffffULL >> e;
+ if ((u.i & m) == 0)
+ return x;
+ if (u.i >> 63 == 0)
+ u.i += m;
+ u.i &= ~m;
+ } else {
+ if (u.i >> 63)
+ return -0.0;
+ else if (u.i << 1)
+ return 1.0;
+ }
+ return u.f;
}
/*********************************************************************
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index 1c4f1254a53..9d9f86b7358 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -121,14 +121,6 @@ static float CDECL unix_atanhf(float x)
#endif
}
-/*********************************************************************
- * ceil
- */
-static double CDECL unix_ceil( double x )
-{
- return ceil( x );
-}
-
/*********************************************************************
* ceilf
*/
@@ -713,7 +705,6 @@ static const struct unix_funcs funcs =
unix_asinhf,
unix_atanh,
unix_atanhf,
- unix_ceil,
unix_ceilf,
unix_cos,
unix_cosf,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index ec380e106d4..70d955d5e4f 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -29,7 +29,6 @@ struct unix_funcs
float (CDECL *asinhf)(float x);
double (CDECL *atanh)(double x);
float (CDECL *atanhf)(float x);
- double (CDECL *ceil)(double x);
float (CDECL *ceilf)(float x);
double (CDECL *cos)(double x);
float (CDECL *cosf)(float x);
More information about the wine-cvs
mailing list