summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/include
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/include')
-rw-r--r--winsup/mingw/include/_mingw.h12
-rw-r--r--winsup/mingw/include/math.h50
2 files changed, 45 insertions, 17 deletions
diff --git a/winsup/mingw/include/_mingw.h b/winsup/mingw/include/_mingw.h
index 4b3b42d6c..2d7a47cde 100644
--- a/winsup/mingw/include/_mingw.h
+++ b/winsup/mingw/include/_mingw.h
@@ -110,6 +110,14 @@
#define __CRT_INLINE extern __inline__
#endif
+#if defined (__GNUC__) && defined (__GNUC_MINOR__)
+#define __MINGW_GNUC_PREREQ(major, minor) \
+ (__GNUC__ > (major) \
+ || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
+#else
+#define __MINGW_GNUC_PREREQ(major, minor) 0
+#endif
+
#ifdef __cplusplus
# define __UNUSED_PARAM(x)
#else
@@ -128,7 +136,7 @@
#define __MINGW_ATTRIB_CONST
#endif
-#if ( __GNUC__ >= 3)
+#if __MINGW_GNUC_PREREQ (3, 0)
#define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
#define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
#else
@@ -139,7 +147,7 @@
/* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
variadiac macro facility, because variadic macros cause syntax
errors with --traditional-cpp. */
-#if (__GNUC__ > 3 ||( __GNUC__ == 3 && __GNUC_MINOR__ >= 3))
+#if __MINGW_GNUC_PREREQ (3, 3)
#define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
#else
#define __MINGW_ATTRIB_NONNULL(arg)
diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h
index 2f39aeb3a..c7800623f 100644
--- a/winsup/mingw/include/math.h
+++ b/winsup/mingw/include/math.h
@@ -500,6 +500,9 @@ extern double __cdecl logb (double);
extern float __cdecl logbf (float);
extern long double __cdecl logbl (long double);
+/* Inline versions. GCC-4.0+ can do a better fast-math optimization
+ with __builtins. */
+#if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
__CRT_INLINE double __cdecl logb (double x)
{
double res;
@@ -523,6 +526,7 @@ __CRT_INLINE long double __cdecl logbl (long double x)
"fstp %%st" : "=t" (res) : "0" (x));
return res;
}
+#endif /* !defined __FAST_MATH__ || !__MINGW_GNUC_PREREQ (4, 0) */
/* 7.12.6.12 Double in C89 */
extern float __cdecl modff (float, float*);
@@ -597,6 +601,22 @@ extern long double __cdecl nearbyintl (long double);
/* 7.12.9.4 */
/* round, using fpu control word settings */
+extern double __cdecl rint (double);
+extern float __cdecl rintf (float);
+extern long double __cdecl rintl (long double);
+
+/* 7.12.9.5 */
+extern long __cdecl lrint (double);
+extern long __cdecl lrintf (float);
+extern long __cdecl lrintl (long double);
+
+extern long long __cdecl llrint (double);
+extern long long __cdecl llrintf (float);
+extern long long __cdecl llrintl (long double);
+
+/* Inline versions of above.
+ GCC 4.0+ can do a better fast-math job with __builtins. */
+#if !(__MINGW_GNUC_PREREQ (4, 0) && defined __FAST_MATH__ )
__CRT_INLINE double __cdecl rint (double x)
{
double retval;
@@ -618,54 +638,54 @@ __CRT_INLINE long double __cdecl rintl (long double x)
return retval;
}
-/* 7.12.9.5 */
__CRT_INLINE long __cdecl lrint (double x)
{
long retval;
- __asm__ __volatile__ \
- ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
+ __asm__ __volatile__
+ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
return retval;
}
__CRT_INLINE long __cdecl lrintf (float x)
{
long retval;
- __asm__ __volatile__ \
- ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
+ __asm__ __volatile__
+ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
return retval;
}
__CRT_INLINE long __cdecl lrintl (long double x)
{
long retval;
- __asm__ __volatile__ \
- ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \
+ __asm__ __volatile__
+ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
return retval;
}
-__CRT_INLINE long long __cdecl llrint (double x)
+__CRT_INLINE long long __cdecl llrint (double x)
{
long long retval;
- __asm__ __volatile__ \
- ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
+ __asm__ __volatile__
+ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
return retval;
}
-__CRT_INLINE long long __cdecl llrintf (float x)
+__CRT_INLINE long long __cdecl llrintf (float x)
{
long long retval;
- __asm__ __volatile__ \
- ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
+ __asm__ __volatile__
+ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
return retval;
}
__CRT_INLINE long long __cdecl llrintl (long double x)
{
long long retval;
- __asm__ __volatile__ \
- ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \
+ __asm__ __volatile__
+ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
return retval;
}
+#endif /* !__FAST_MATH__ || !__MINGW_GNUC_PREREQ (4,0) */
/* 7.12.9.6 */
/* round away from zero, regardless of fpu control word settings */