Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2005-10-21 01:42:33 +0400
committerJeff Johnston <jjohnstn@redhat.com>2005-10-21 01:42:33 +0400
commit09968b6d2769d8f11e156c1c826ae0764a64d14a (patch)
tree5c048550c8b1f24f5768a596a536488ee1c5ccf4
parent34da20b26f3a46f986e989740c71a8ff955072e5 (diff)
2005-10-20 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/math.h (HUGE_VAL, HUGE_VALF, HUGE_VALL): When gcc is 3.3 or greater, use special gcc builtins.
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/include/math.h68
2 files changed, 51 insertions, 22 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 1788da034..3aaf33349 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2005-10-20 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/include/math.h (HUGE_VAL, HUGE_VALF, HUGE_VALL): When
+ gcc is 3.3 or greater, use special gcc builtins.
+
2005-10-20 Corinna Vinschen <corinna@vinschen.de>
* libc/include/sys/time.h: Declare futimes and lutimes for Cygwin.
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 3eec0e48f..041e8000b 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -9,41 +9,65 @@
_BEGIN_STD_C
-#ifndef HUGE_VAL
-
-/* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined
- (which might have been done by something like math-68881.h). */
-
-union __fmath
-{
- __ULong i[1];
- float f;
-};
-
union __dmath
{
__ULong i[2];
double d;
};
-
+
+union __fmath
+{
+ __ULong i[1];
+ float f;
+};
+
union __ldmath
{
__ULong i[4];
_LONG_DOUBLE ld;
};
-/* Declare this as an array without bounds so that no matter what small data
- support a port and/or library has, this reference will be via the general
- method for accessing globals. */
-extern __IMPORT const union __dmath __infinity[];
-extern __IMPORT const union __fmath __infinityf[];
-extern __IMPORT const union __ldmath __infinityld[];
+#if defined(__GNUC__) && \
+ ( (__GNUC__ >= 4) || \
+ ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
+
+ /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
+
+ #ifndef HUGE_VAL
+ #define HUGE_VAL (__builtin_huge_val())
+ #endif
+
+ #ifndef HUGE_VALF
+ #define HUGE_VALF (__builtin_huge_valf())
+ #endif
+
+ #ifndef HUGE_VALL
+ #define HUGE_VALL (__builtin_huge_vall())
+ #endif
+
+#else /* !gcc >= 3.3 */
+
+ /* No builtins. Use floating-point unions instead. Declare as an array
+ without bounds so no matter what small data support a port and/or
+ library has, the reference will be via the general method for accessing
+ globals. */
+
+ #ifndef HUGE_VAL
+ extern __IMPORT const union __dmath __infinity[];
+ #define HUGE_VAL (__infinity[0].d)
+ #endif
+
+ #ifndef HUGE_VALF
+ extern __IMPORT const union __fmath __infinityf[];
+ #define HUGE_VALF (__infinityf[0].f)
+ #endif
-#define HUGE_VAL (__infinity[0].d)
-#define HUGE_VALF (__infinityf[0].f)
-#define HUGE_VALL (__infinityld[0].ld)
+ #ifndef HUGE_VALL
+ extern __IMPORT const union __ldmath __infinityld[];
+ #define HUGE_VALL (__infinityld[0].ld)
+ #endif
-#endif /* ! defined (HUGE_VAL) */
+#endif /* !gcc >= 3.3 */
/* Reentrant ANSI C functions. */