Alex Henrie : libport: Move rint fallback implementations from msvcrt to libport.

Alexandre Julliard julliard at winehq.org
Sun Mar 18 09:02:32 CDT 2018


Module: wine
Branch: oldstable
Commit: 59f4b9e527f5915aabd9df257cb259269f5c1aa0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=59f4b9e527f5915aabd9df257cb259269f5c1aa0

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Mon Nov  6 21:01:13 2017 -0500

libport: Move rint fallback implementations from msvcrt to libport.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 06d9c7e25e4ff71731c81f172269c8cd81b0c68a)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/dsound/dsound_convert.c |  1 +
 dlls/msvcrt/math.c           | 24 ----------------
 include/wine/port.h          | 24 ++++++++++++++++
 libs/port/Makefile.in        |  1 +
 libs/port/rint.c             | 66 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 92 insertions(+), 24 deletions(-)

diff --git a/dlls/dsound/dsound_convert.c b/dlls/dsound/dsound_convert.c
index 0c9a34b..ad0442e 100644
--- a/dlls/dsound/dsound_convert.c
+++ b/dlls/dsound/dsound_convert.c
@@ -35,6 +35,7 @@
  */
 
 #include "config.h"
+#include "wine/port.h"
 
 #include <stdarg.h>
 #include <math.h>
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index f2d41c8..e56fdaa 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -2477,11 +2477,7 @@ LDOUBLE CDECL MSVCR120_log2l(LDOUBLE x)
  */
 double CDECL MSVCR120_rint(double x)
 {
-#ifdef HAVE_RINT
     return rint(x);
-#else
-    return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
-#endif
 }
 
 /*********************************************************************
@@ -2489,11 +2485,7 @@ double CDECL MSVCR120_rint(double x)
  */
 float CDECL MSVCR120_rintf(float x)
 {
-#ifdef HAVE_RINTF
     return rintf(x);
-#else
-    return MSVCR120_rint(x);
-#endif
 }
 
 /*********************************************************************
@@ -2509,11 +2501,7 @@ LDOUBLE CDECL MSVCR120_rintl(LDOUBLE x)
  */
 MSVCRT_long CDECL MSVCR120_lrint(double x)
 {
-#ifdef HAVE_LRINT
     return lrint(x);
-#else
-    return MSVCR120_rint(x);
-#endif
 }
 
 /*********************************************************************
@@ -2521,11 +2509,7 @@ MSVCRT_long CDECL MSVCR120_lrint(double x)
  */
 MSVCRT_long CDECL MSVCR120_lrintf(float x)
 {
-#ifdef HAVE_LRINTF
     return lrintf(x);
-#else
-    return MSVCR120_lrint(x);
-#endif
 }
 
 /*********************************************************************
@@ -2541,11 +2525,7 @@ MSVCRT_long CDECL MSVCR120_lrintl(LDOUBLE x)
  */
 MSVCRT_longlong CDECL MSVCR120_llrint(double x)
 {
-#ifdef HAVE_LLRINT
     return llrint(x);
-#else
-    return MSVCR120_rint(x);
-#endif
 }
 
 /*********************************************************************
@@ -2553,11 +2533,7 @@ MSVCRT_longlong CDECL MSVCR120_llrint(double x)
  */
 MSVCRT_longlong CDECL MSVCR120_llrintf(float x)
 {
-#ifdef HAVE_LLRINTF
     return llrintf(x);
-#else
-    return MSVCR120_llrint(x);
-#endif
 }
 
 /*********************************************************************
diff --git a/include/wine/port.h b/include/wine/port.h
index 2989b39..addece0 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -272,6 +272,22 @@ int isinf(double x);
 int isnan(double x);
 #endif
 
+#ifndef HAVE_LLRINT
+__int64 llrint(double x);
+#endif
+
+#ifndef HAVE_LLRINTF
+__int64 llrintf(float x);
+#endif
+
+#ifndef HAVE_LRINT
+long lrint(double x);
+#endif
+
+#ifndef HAVE_LRINTF
+long lrintf(float x);
+#endif
+
 #ifndef HAVE_LSTAT
 int lstat(const char *file_name, struct stat *buf);
 #endif /* HAVE_LSTAT */
@@ -308,6 +324,14 @@ ssize_t pwrite( int fd, const void *buf, size_t count, off_t offset );
 int readlink( const char *path, char *buf, size_t size );
 #endif /* HAVE_READLINK */
 
+#ifndef HAVE_RINT
+double rint(double x);
+#endif
+
+#ifndef HAVE_RINTF
+float rintf(float x);
+#endif
+
 #ifndef HAVE_STATVFS
 int statvfs( const char *path, struct statvfs *buf );
 #endif
diff --git a/libs/port/Makefile.in b/libs/port/Makefile.in
index 9d7e44f..7fefda1 100644
--- a/libs/port/Makefile.in
+++ b/libs/port/Makefile.in
@@ -96,6 +96,7 @@ C_SRCS = \
 	pread.c \
 	pwrite.c \
 	readlink.c \
+	rint.c \
 	spawn.c \
 	statvfs.c \
 	strcasecmp.c \
diff --git a/libs/port/rint.c b/libs/port/rint.c
new file mode 100644
index 0000000..a99c00b
--- /dev/null
+++ b/libs/port/rint.c
@@ -0,0 +1,66 @@
+/*
+ * rint family
+ *
+ * Copyright 2017 Alex Henrie
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#include <math.h>
+
+#ifndef HAVE_RINT
+double rint(double x)
+{
+    return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif
+
+#ifndef HAVE_RINTF
+float rintf(float x)
+{
+    return rintf(x);
+}
+#endif
+
+#ifndef HAVE_LRINT
+long lrint(double x)
+{
+    return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif
+
+#ifndef HAVE_LRINTF
+long lrintf(float x)
+{
+    return lrint(x);
+}
+#endif
+
+#ifndef HAVE_LLRINT
+__int64 llrint(double x)
+{
+    return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif
+
+#ifndef HAVE_LLRINTF
+__int64 llrintf(float x)
+{
+    return llrint(x);
+}
+#endif




More information about the wine-cvs mailing list