Ticket #6230: clang-math.patch

File clang-math.patch, 1.1 KB (added by kaliber, 14 years ago)

Simple math.h changes for clang

  • headers/posix/math.h

     
    2424#define __HUGE_VAL_v    0x7ff0000000000000LL
    2525#define __huge_val_t    union { unsigned char __c[8]; long long __ll; double __d; }
    2626#ifndef HUGE_VAL
     27#ifdef __clang__
     28#define HUGE_VAL        __builtin_huge_val()
     29#else
    2730#   define HUGE_VAL     (((__huge_val_t) { __ll: __HUGE_VAL_v }).__d)
    2831#endif
     32#endif
    2933
    3034#define __HUGE_VALF_v   0x7f800000L
    3135#define __huge_valf_t   union { unsigned char __c[4]; long __l; float __f; }
     36#ifdef __clang__
     37#define HUGE_VALF       __builtin_huge_valf()
     38#else
    3239#define HUGE_VALF       (((__huge_valf_t) { __l: __HUGE_VALF_v }).__f)
     40#endif
    3341
    3442/* TODO: define HUGE_VALL for long doubles */
    3543
    3644#define __NAN_VALF_v    0x7fc00000L
     45#ifdef __clang__
     46#define NAN             __builtin_nanf("")
     47#else
    3748#define NAN             (((__huge_valf_t) { __l: __NAN_VALF_v }).__f)
     49#endif
    3850
     51#ifdef __clang__
     52#define INFINITY        __builtin_inff()
     53#else
    3954#define INFINITY        HUGE_VALF
     55#endif
    4056
    4157/* floating-point categories */
    4258#define FP_NAN          0