diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2005-10-21 01:42:33 +0400 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2005-10-21 01:42:33 +0400 |
commit | 09968b6d2769d8f11e156c1c826ae0764a64d14a (patch) | |
tree | 5c048550c8b1f24f5768a596a536488ee1c5ccf4 /newlib/libc | |
parent | 34da20b26f3a46f986e989740c71a8ff955072e5 (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.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/include/math.h | 68 |
1 files changed, 46 insertions, 22 deletions
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. */ |