Piotr Caban : msvcrt: Import _logbf implementation from musl.
Alexandre Julliard
julliard at winehq.org
Fri May 21 14:19:44 CDT 2021
Module: wine
Branch: master
Commit: 78fc19d67a525d78dbf89e9b9fe93082bdd2b4ba
URL: https://source.winehq.org/git/wine.git/?a=commit;h=78fc19d67a525d78dbf89e9b9fe93082bdd2b4ba
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu May 20 23:04:44 2021 +0200
msvcrt: Import _logbf 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 | 49 +++++++++++++++++++++++++++++--------------------
dlls/msvcrt/unixlib.c | 9 ---------
dlls/msvcrt/unixlib.h | 1 -
3 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index df00f0532bb..234483da299 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -275,15 +275,38 @@ float CDECL _nextafterf( float x, float y )
return y;
}
+/* Copied from musl: src/math/ilogbf.c */
+static int __ilogbf(float x)
+{
+ union { float f; UINT32 i; } u = { x };
+ int e = u.i >> 23 & 0xff;
+
+ if (!e)
+ {
+ u.i <<= 9;
+ if (u.i == 0) return FP_ILOGB0;
+ /* subnormal x */
+ for (e = -0x7f; u.i >> 31 == 0; e--, u.i <<= 1);
+ return e;
+ }
+ if (e == 0xff) return u.i << 9 ? FP_ILOGBNAN : INT_MAX;
+ return e - 0x7f;
+}
+
/*********************************************************************
* _logbf (MSVCRT.@)
+ *
+ * Copied from musl: src/math/logbf.c
*/
-float CDECL _logbf( float num )
+float CDECL _logbf(float x)
{
- float ret = unix_funcs->logbf(num);
- if (isnan(num)) return math_error(_DOMAIN, "_logbf", num, 0, ret);
- if (!num) return math_error(_SING, "_logbf", num, 0, ret);
- return ret;
+ if (!isfinite(x))
+ return x * x;
+ if (x == 0) {
+ *_errno() = ERANGE;
+ return -1 / (x * x);
+ }
+ return __ilogbf(x);
}
#endif
@@ -6178,23 +6201,9 @@ int CDECL ilogb(double x)
/*********************************************************************
* ilogbf (MSVCR120.@)
- *
- * Copied from musl: src/math/ilogbf.c
*/
int CDECL ilogbf(float x)
{
- union { float f; UINT32 i; } u = { x };
- int e = u.i >> 23 & 0xff;
-
- if (!e)
- {
- u.i <<= 9;
- if (u.i == 0) return FP_ILOGB0;
- /* subnormal x */
- for (e = -0x7f; u.i >> 31 == 0; e--, u.i <<= 1);
- return e;
- }
- if (e == 0xff) return u.i << 9 ? FP_ILOGBNAN : INT_MAX;
- return e - 0x7f;
+ return __ilogbf(x);
}
#endif /* _MSVCR_VER>=120 */
diff --git a/dlls/msvcrt/unixlib.c b/dlls/msvcrt/unixlib.c
index 51fe7ef6f0f..a4d570a282a 100644
--- a/dlls/msvcrt/unixlib.c
+++ b/dlls/msvcrt/unixlib.c
@@ -387,14 +387,6 @@ static float CDECL unix_log2f(float x)
#endif
}
-/*********************************************************************
- * logbf
- */
-static float CDECL unix_logbf( float x )
-{
- return logbf( x );
-}
-
/*********************************************************************
* pow
*/
@@ -536,7 +528,6 @@ static const struct unix_funcs funcs =
unix_log1pf,
unix_log2,
unix_log2f,
- unix_logbf,
unix_pow,
unix_powf,
unix_sin,
diff --git a/dlls/msvcrt/unixlib.h b/dlls/msvcrt/unixlib.h
index a0cded99e20..d4471477715 100644
--- a/dlls/msvcrt/unixlib.h
+++ b/dlls/msvcrt/unixlib.h
@@ -56,7 +56,6 @@ struct unix_funcs
float (CDECL *log1pf)(float x);
double (CDECL *log2)(double x);
float (CDECL *log2f)(float x);
- float (CDECL *logbf)(float x);
double (CDECL *pow)(double x, double y);
float (CDECL *powf)(float x, float y);
double (CDECL *sin)(double x);
More information about the wine-cvs
mailing list