[PATCH 02/15] msvcr120: Implement more C99 math functions.

Martin Storsjo martin at martin.st
Mon Dec 1 04:27:01 CST 2014


Implement the *rint, trunc, *round, log2, exp2 and cbrt
function families.

These are directly passed on to the corresponding host
libc functions.
---
 dlls/msvcr120/msvcr120.spec |  60 +++++------
 dlls/msvcrt/math.c          | 241 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 271 insertions(+), 30 deletions(-)

diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index d0ba290..e0e4661 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -2058,9 +2058,9 @@
 @ stub catanhf
 @ stub catanhl
 @ stub catanl
-@ stub cbrt
-@ stub cbrtf
-@ stub cbrtl
+@ cdecl cbrt(double) MSVCR120_cbrt
+@ cdecl cbrtf(float) MSVCR120_cbrtf
+@ cdecl cbrtl(double) MSVCR120_cbrtl
 @ stub ccos
 @ stub ccosf
 @ stub ccosh
@@ -2127,9 +2127,9 @@
 @ stub erfl
 @ cdecl exit(long) MSVCRT_exit
 @ cdecl exp(double) MSVCRT_exp
-@ stub exp2
-@ stub exp2f
-@ stub exp2l
+@ cdecl exp2(double) MSVCR120_exp2
+@ cdecl exp2f(float) MSVCR120_exp2f
+@ cdecl exp2l(double) MSVCR120_exp2l
 @ cdecl -arch=arm,x86_64 expf(float) MSVCRT_expf
 @ stub expm1
 @ stub expm1f
@@ -2245,12 +2245,12 @@
 @ stub lgammal
 @ cdecl -ret64 llabs(int64) MSVCRT_llabs
 @ stub lldiv
-@ stub llrint
-@ stub llrintf
-@ stub llrintl
-@ stub llround
-@ stub llroundf
-@ stub llroundl
+@ cdecl -ret64 llrint(double) MSVCR120_llrint
+@ cdecl -ret64 llrintf(float) MSVCR120_llrintf
+@ cdecl -ret64 llrintl(double) MSVCR120_llrintl
+@ cdecl -ret64 llround(double) MSVCR120_llround
+@ cdecl -ret64 llroundf(float) MSVCR120_llroundf
+@ cdecl -ret64 llroundl(double) MSVCR120_llroundl
 @ cdecl localeconv() MSVCRT_localeconv
 @ cdecl log(double) MSVCRT_log
 @ cdecl -arch=arm,x86_64 logf(float) MSVCRT_logf
@@ -2259,19 +2259,19 @@
 @ stub log1p
 @ stub log1pf
 @ stub log1pl
-@ stub log2
-@ stub log2f
-@ stub log2l
+@ cdecl log2(double) MSVCR120_log2
+@ cdecl log2f(float) MSVCR120_log2f
+@ cdecl log2l(double) MSVCR120_log2l
 @ stub logb
 @ stub logbf
 @ stub logbl
 @ cdecl -arch=i386,x86_64,arm longjmp(ptr long) MSVCRT_longjmp
-@ stub lrint
-@ stub lrintf
-@ stub lrintl
-@ stub lround
-@ stub lroundf
-@ stub lroundl
+@ cdecl lrint(double) MSVCR120_lrint
+@ cdecl lrintf(float) MSVCR120_lrintf
+@ cdecl lrintl(double) MSVCR120_lrintl
+@ cdecl lround(double) MSVCR120_lround
+@ cdecl lroundf(float) MSVCR120_lroundf
+@ cdecl lroundl(double) MSVCR120_lroundl
 @ cdecl malloc(long) MSVCRT_malloc
 @ cdecl mblen(ptr long) MSVCRT_mblen
 @ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen
@@ -2330,12 +2330,12 @@
 @ stub remquol
 @ cdecl rename(str str) MSVCRT_rename
 @ cdecl rewind(ptr) MSVCRT_rewind
-@ stub rint
-@ stub rintf
-@ stub rintl
-@ stub round
-@ stub roundf
-@ stub roundl
+@ cdecl rint(double) MSVCR120_rint
+@ cdecl rintf(float) MSVCR120_rintf
+@ cdecl rintl(double) MSVCR120_rintl
+@ cdecl round(double) MSVCR120_round
+@ cdecl roundf(float) MSVCR120_roundf
+@ cdecl roundl(double) MSVCR120_roundl
 @ stub scalbln
 @ stub scalblnf
 @ stub scalblnl
@@ -2414,9 +2414,9 @@
 @ stub towctrans
 @ cdecl towlower(long) MSVCRT_towlower
 @ cdecl towupper(long) MSVCRT_towupper
-@ stub trunc
-@ stub truncf
-@ stub truncl
+@ cdecl trunc(double) MSVCR120_trunc
+@ cdecl truncf(float) MSVCR120_truncf
+@ cdecl truncl(double) MSVCR120_truncl
 @ cdecl ungetc(long ptr) MSVCRT_ungetc
 @ cdecl ungetwc(long ptr) MSVCRT_ungetwc
 @ cdecl vfprintf(ptr str ptr) MSVCRT_vfprintf
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index d67b2e8..15f86ed 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -39,6 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
 #endif
 
 typedef int (CDECL *MSVCRT_matherr_func)(struct MSVCRT__exception *);
+typedef double LDOUBLE;  /* long double is just a double */
 
 static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
 
@@ -2205,3 +2206,243 @@ void __cdecl __libm_sse2_sqrt_precise(void)
 }
 
 #endif  /* __i386__ */
+
+/*********************************************************************
+ *      rint (MSVCR120.@)
+ */
+double CDECL MSVCR120_rint(double x)
+{
+    return rint(x);
+}
+
+/*********************************************************************
+ *      rintf (MSVCR120.@)
+ */
+float CDECL MSVCR120_rintf(float x)
+{
+    return rintf(x);
+}
+
+/*********************************************************************
+ *      rintl (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_rintl(LDOUBLE x)
+{
+    return rintl(x);
+}
+
+/*********************************************************************
+ *      lrint (MSVCR120.@)
+ */
+MSVCRT_long CDECL MSVCR120_lrint(double x)
+{
+    return lrint(x);
+}
+
+/*********************************************************************
+ *      lrintf (MSVCR120.@)
+ */
+MSVCRT_long CDECL MSVCR120_lrintf(float x)
+{
+    return lrintf(x);
+}
+
+/*********************************************************************
+ *      lrintl (MSVCR120.@)
+ */
+MSVCRT_long CDECL MSVCR120_lrintl(LDOUBLE x)
+{
+    return lrintl(x);
+}
+
+/*********************************************************************
+ *      llrint (MSVCR120.@)
+ */
+MSVCRT_longlong CDECL MSVCR120_llrint(double x)
+{
+    return llrint(x);
+}
+
+/*********************************************************************
+ *      llrintf (MSVCR120.@)
+ */
+MSVCRT_longlong CDECL MSVCR120_llrintf(float x)
+{
+    return llrintf(x);
+}
+
+/*********************************************************************
+ *      rintl (MSVCR120.@)
+ */
+MSVCRT_longlong CDECL MSVCR120_llrintl(LDOUBLE x)
+{
+    return llrintl(x);
+}
+
+/*********************************************************************
+ *      trunc (MSVCR120.@)
+ */
+double CDECL MSVCR120_trunc(double x)
+{
+    return trunc(x);
+}
+
+/*********************************************************************
+ *      truncf (MSVCR120.@)
+ */
+float CDECL MSVCR120_truncf(float x)
+{
+    return truncf(x);
+}
+
+/*********************************************************************
+ *      truncl (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_truncl(LDOUBLE x)
+{
+    return trunc(x);
+}
+
+/*********************************************************************
+ *      round (MSVCR120.@)
+ */
+double CDECL MSVCR120_round(double x)
+{
+    return round(x);
+}
+
+/*********************************************************************
+ *      roundf (MSVCR120.@)
+ */
+float CDECL MSVCR120_roundf(float x)
+{
+    return roundf(x);
+}
+
+/*********************************************************************
+ *      roundl (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_roundl(LDOUBLE x)
+{
+    return roundl(x);
+}
+
+/*********************************************************************
+ *      lround (MSVCR120.@)
+ */
+MSVCRT_long CDECL MSVCR120_lround(double x)
+{
+    return lround(x);
+}
+
+/*********************************************************************
+ *      lroundf (MSVCR120.@)
+ */
+MSVCRT_long CDECL MSVCR120_lroundf(float x)
+{
+    return lroundf(x);
+}
+
+/*********************************************************************
+ *      lroundl (MSVCR120.@)
+ */
+MSVCRT_long CDECL MSVCR120_lroundl(LDOUBLE x)
+{
+    return lroundl(x);
+}
+
+/*********************************************************************
+ *      llround (MSVCR120.@)
+ */
+MSVCRT_longlong CDECL MSVCR120_llround(double x)
+{
+    return llround(x);
+}
+
+/*********************************************************************
+ *      llroundf (MSVCR120.@)
+ */
+MSVCRT_longlong CDECL MSVCR120_llroundf(float x)
+{
+    return llroundf(x);
+}
+
+/*********************************************************************
+ *      roundl (MSVCR120.@)
+ */
+MSVCRT_longlong CDECL MSVCR120_llroundl(LDOUBLE x)
+{
+    return llroundl(x);
+}
+
+/*********************************************************************
+ *      log2 (MSVCR120.@)
+ */
+double CDECL MSVCR120_log2(double x)
+{
+    return log2(x);
+}
+
+/*********************************************************************
+ *      log2f (MSVCR120.@)
+ */
+float CDECL MSVCR120_log2f(float x)
+{
+    return log2f(x);
+}
+
+/*********************************************************************
+ *      log2l (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_log2l(LDOUBLE x)
+{
+    return log2l(x);
+}
+
+/*********************************************************************
+ *      exp2 (MSVCR120.@)
+ */
+double CDECL MSVCR120_exp2(double x)
+{
+    return exp2(x);
+}
+
+/*********************************************************************
+ *      exp2f (MSVCR120.@)
+ */
+float CDECL MSVCR120_exp2f(float x)
+{
+    return exp2f(x);
+}
+
+/*********************************************************************
+ *      exp2l (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_exp2l(LDOUBLE x)
+{
+    return exp2l(x);
+}
+
+/*********************************************************************
+ *      cbrt (MSVCR120.@)
+ */
+double CDECL MSVCR120_cbrt(double x)
+{
+    return cbrt(x);
+}
+
+/*********************************************************************
+ *      cbrtf (MSVCR120.@)
+ */
+float CDECL MSVCR120_cbrtf(float x)
+{
+    return cbrtf(x);
+}
+
+/*********************************************************************
+ *      cbrtl (MSVCR120.@)
+ */
+LDOUBLE CDECL MSVCR120_cbrtl(LDOUBLE x)
+{
+    return cbrtl(x);
+}
-- 
1.8.1.2




More information about the wine-patches mailing list