[PATCH] msvcr120: Implement the _dclass/_fdclass/_ldclass functions.

Martin Storsjo martin at martin.st
Tue Dec 9 00:43:07 CST 2014


These are used in the implementation of the C99 fpclassify
macro in MSVC 2013.
---
 dlls/msvcr120/msvcr120.spec |  6 +++---
 dlls/msvcrt/math.c          | 41 +++++++++++++++++++++++++++++++++++++++++
 dlls/msvcrt/msvcrt.h        |  7 +++++++
 3 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index e0e4661..9c765b3 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1104,7 +1104,7 @@
 @ varargs _cwscanf_s(wstr)
 @ varargs _cwscanf_s_l(wstr ptr)
 @ extern _daylight MSVCRT___daylight
-@ stub _dclass
+@ cdecl _dclass(double) MSVCR120__dclass
 @ cdecl _difftime32(long long) MSVCRT__difftime32
 @ cdecl _difftime64(long long) MSVCRT__difftime64
 @ stub _dosmaperr
@@ -1140,7 +1140,7 @@
 @ cdecl _fcloseall() MSVCRT__fcloseall
 @ cdecl _fcvt(double long ptr ptr) MSVCRT__fcvt
 @ cdecl _fcvt_s(ptr long double long ptr ptr) MSVCRT__fcvt_s
-@ stub _fdclass
+@ cdecl _fdclass(float) MSVCR120__fdclass
 @ cdecl _fdopen(long str) MSVCRT__fdopen
 @ stub _fdpcomp
 @ stub _fdsign
@@ -1389,7 +1389,7 @@
 @ cdecl _j1(double) MSVCRT__j1
 @ cdecl _jn(long double) MSVCRT__jn
 @ cdecl _kbhit()
-@ stub _ldclass
+@ cdecl _ldclass(double) MSVCR120__ldclass
 @ stub _ldpcomp
 @ stub _ldsign
 @ stub _ldtest
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 16a9c4e..9b75d36 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -2526,3 +2526,44 @@ LDOUBLE CDECL MSVCR120_truncl(LDOUBLE x)
 {
     return MSVCR120_trunc(x);
 }
+
+/*********************************************************************
+ *      _dclass (MSVCR120.@)
+ */
+short CDECL MSVCR120__dclass(double x)
+{
+    switch (MSVCRT__fpclass(x)) {
+    case MSVCRT__FPCLASS_QNAN:
+    case MSVCRT__FPCLASS_SNAN:
+        return MSVCRT_FP_NAN;
+    case MSVCRT__FPCLASS_NINF:
+    case MSVCRT__FPCLASS_PINF:
+        return MSVCRT_FP_INFINITE;
+    case MSVCRT__FPCLASS_ND:
+    case MSVCRT__FPCLASS_PD:
+        return MSVCRT_FP_SUBNORMAL;
+    case MSVCRT__FPCLASS_NN:
+    case MSVCRT__FPCLASS_PN:
+    default:
+        return MSVCRT_FP_NORMAL;
+    case MSVCRT__FPCLASS_NZ:
+    case MSVCRT__FPCLASS_PZ:
+        return MSVCRT_FP_ZERO;
+    }
+}
+
+/*********************************************************************
+ *      _fdclass (MSVCR120.@)
+ */
+short CDECL MSVCR120__fdclass(float x)
+{
+    return MSVCR120__dclass(x);
+}
+
+/*********************************************************************
+ *      _ldclass (MSVCR120.@)
+ */
+short CDECL MSVCR120__ldclass(LDOUBLE x)
+{
+    return MSVCR120__dclass(x);
+}
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index f397087..41f31b9 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -824,6 +824,13 @@ struct MSVCRT__stat64 {
 #define MSVCRT__FPCLASS_PN   0x0100  /* Positive Normal */
 #define MSVCRT__FPCLASS_PINF 0x0200  /* Positive Infinity */
 
+/* fpclassify constants */
+#define MSVCRT_FP_INFINITE   1
+#define MSVCRT_FP_NAN        2
+#define MSVCRT_FP_NORMAL    -1
+#define MSVCRT_FP_SUBNORMAL -2
+#define MSVCRT_FP_ZERO       0
+
 #define MSVCRT__MCW_EM        0x0008001f
 #define MSVCRT__MCW_IC        0x00040000
 #define MSVCRT__MCW_RC        0x00000300
-- 
1.8.1.2




More information about the wine-patches mailing list