Patch by Paul Davey with minor style changes by myself: For gcc 4 (and clang)

define the HUGE_VAL and friends macros to the respective __builtin_*()
functions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39307 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-11-05 13:20:52 +00:00
parent aa3507feea
commit 7aff60b7de

View File

@ -21,23 +21,35 @@
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
/* platform independent IEEE floating point special values */
#define __HUGE_VAL_v 0x7ff0000000000000LL
#define __huge_val_t union { unsigned char __c[8]; long long __ll; double __d; }
#ifndef HUGE_VAL
# define HUGE_VAL (((__huge_val_t) { __ll: __HUGE_VAL_v }).__d)
#if __GNUC__ >= 4
/* gcc4 and clang definitions */
# ifndef HUGE_VAL
# define HUGE_VAL __builtin_huge_val()
# endif
# define HUGE_VALF __builtin_huge_valf()
# define HUGE_VALL __builtin_huge_vall()
# define NAN __builtin_nanf("")
# define INFINITY __builtin_inff()
#else
/* gcc2 definitions */
# define __HUGE_VAL_v 0x7ff0000000000000LL
# define __huge_val_t union { unsigned char __c[8]; long long __ll; double __d; }
# ifndef HUGE_VAL
# define HUGE_VAL (((__huge_val_t) { __ll: __HUGE_VAL_v }).__d)
# endif
# define __HUGE_VALF_v 0x7f800000L
# define __huge_valf_t union { unsigned char __c[4]; long __l; float __f; }
# define HUGE_VALF (((__huge_valf_t) { __l: __HUGE_VALF_v }).__f)
/* TODO: define HUGE_VALL for long doubles */
# define __NAN_VALF_v 0x7fc00000L
# define NAN (((__huge_valf_t) { __l: __NAN_VALF_v }).__f)
# define INFINITY HUGE_VALF
#endif
#define __HUGE_VALF_v 0x7f800000L
#define __huge_valf_t union { unsigned char __c[4]; long __l; float __f; }
#define HUGE_VALF (((__huge_valf_t) { __l: __HUGE_VALF_v }).__f)
/* TODO: define HUGE_VALL for long doubles */
#define __NAN_VALF_v 0x7fc00000L
#define NAN (((__huge_valf_t) { __l: __NAN_VALF_v }).__f)
#define INFINITY HUGE_VALF
/* floating-point categories */
#define FP_NAN 0
#define FP_INFINITE 1