zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

float.h (4498B) - Raw


      1 /* Copyright (c) 2017 Apple Inc. All rights reserved.
      2  *
      3  * @APPLE_LICENSE_HEADER_START@
      4  *
      5  * The contents of this file constitute Original Code as defined in and
      6  * are subject to the Apple Public Source License Version 1.1 (the
      7  * "License").  You may not use this file except in compliance with the
      8  * License.  Please obtain a copy of the License at
      9  * http://www.apple.com/publicsource and read it before using this file.
     10  *
     11  * This Original Code and all software distributed under the License are
     12  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
     13  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
     14  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
     15  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
     16  * License for the specific language governing rights and limitations
     17  * under the License.
     18  *
     19  * @APPLE_LICENSE_HEADER_END@
     20  */
     21 
     22 #ifndef __FLOAT_H
     23 #define __FLOAT_H
     24 
     25 #if !defined(__has_feature) || !__has_feature(modules)
     26 /* clang's float.h comes before this header in the search order. It
     27  * will include this header first, undef all of these macros, and then
     28  * redeclare them. That doesn't work when the two headers are in
     29  * different clang modules. The only way to avoid redeclaration errors
     30  * is to not declare the macros here, and let clang's float.h handle
     31  * them.
     32  */
     33 
     34 /* Undefine anything that we'll be redefining below. */
     35 #undef FLT_EVAL_METHOD
     36 #undef FLT_ROUNDS
     37 #undef FLT_RADIX
     38 #undef FLT_MANT_DIG
     39 #undef DBL_MANT_DIG
     40 #undef LDBL_MANT_DIG
     41 #undef FLT_DIG
     42 #undef DBL_DIG
     43 #undef LDBL_DIG
     44 #undef FLT_MIN_EXP
     45 #undef DBL_MIN_EXP
     46 #undef LDBL_MIN_EXP
     47 #undef FLT_MIN_10_EXP
     48 #undef DBL_MIN_10_EXP
     49 #undef LDBL_MIN_10_EXP
     50 #undef FLT_MAX_EXP
     51 #undef DBL_MAX_EXP
     52 #undef LDBL_MAX_EXP
     53 #undef FLT_MAX_10_EXP
     54 #undef DBL_MAX_10_EXP
     55 #undef LDBL_MAX_10_EXP
     56 #undef FLT_MAX
     57 #undef DBL_MAX
     58 #undef LDBL_MAX
     59 #undef FLT_EPSILON
     60 #undef DBL_EPSILON
     61 #undef LDBL_EPSILON
     62 #undef FLT_MIN
     63 #undef DBL_MIN
     64 #undef LDBL_MIN
     65 
     66 #if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
     67 #  undef DECIMAL_DIG
     68 #endif
     69 
     70 #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
     71 #  undef FLT_HAS_SUBNORM
     72 #  undef DBL_HAS_SUBNORM
     73 #  undef LDBL_HAS_SUBNORM
     74 #  undef FLT_TRUE_MIN
     75 #  undef DBL_TRUE_MIN
     76 #  undef LDBL_TRUE_MIN
     77 #  undef FLT_DECIMAL_DIG
     78 #  undef DBL_DECIMAL_DIG
     79 #  undef LDBL_DECIMAL_DIG
     80 #endif
     81 
     82 /* Characteristics of floating point types, C99 5.2.4.2.2 */
     83 
     84 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
     85 #define FLT_ROUNDS (__builtin_flt_rounds())
     86 #define FLT_RADIX __FLT_RADIX__
     87 
     88 #define FLT_MANT_DIG __FLT_MANT_DIG__
     89 #define DBL_MANT_DIG __DBL_MANT_DIG__
     90 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
     91 
     92 #define FLT_DIG __FLT_DIG__
     93 #define DBL_DIG __DBL_DIG__
     94 #define LDBL_DIG __LDBL_DIG__
     95 
     96 #define FLT_MIN_EXP __FLT_MIN_EXP__
     97 #define DBL_MIN_EXP __DBL_MIN_EXP__
     98 #define LDBL_MIN_EXP __LDBL_MIN_EXP__
     99 
    100 #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
    101 #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
    102 #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
    103 
    104 #define FLT_MAX_EXP __FLT_MAX_EXP__
    105 #define DBL_MAX_EXP __DBL_MAX_EXP__
    106 #define LDBL_MAX_EXP __LDBL_MAX_EXP__
    107 
    108 #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
    109 #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
    110 #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
    111 
    112 #define FLT_MAX __FLT_MAX__
    113 #define DBL_MAX __DBL_MAX__
    114 #define LDBL_MAX __LDBL_MAX__
    115 
    116 #define FLT_EPSILON __FLT_EPSILON__
    117 #define DBL_EPSILON __DBL_EPSILON__
    118 #define LDBL_EPSILON __LDBL_EPSILON__
    119 
    120 #define FLT_MIN __FLT_MIN__
    121 #define DBL_MIN __DBL_MIN__
    122 #define LDBL_MIN __LDBL_MIN__
    123 
    124 #if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
    125 #  define DECIMAL_DIG __DECIMAL_DIG__
    126 #endif
    127 
    128 #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
    129 #  if defined __arm__ /*  On 32-bit arm, denorms are not supported.           */
    130 #    define FLT_HAS_SUBNORM 0
    131 #    define DBL_HAS_SUBNORM 0
    132 #    define LDBL_HAS_SUBNORM 0
    133 #    define FLT_TRUE_MIN __FLT_MIN__
    134 #    define DBL_TRUE_MIN __DBL_MIN__
    135 #    define LDBL_TRUE_MIN __LDBL_MIN__
    136 #  else /* All Apple platforms except 32-bit arm have denorms.                */
    137 #    define FLT_HAS_SUBNORM 1
    138 #    define DBL_HAS_SUBNORM 1
    139 #    define LDBL_HAS_SUBNORM 1
    140 #    define FLT_TRUE_MIN __FLT_DENORM_MIN__
    141 #    define DBL_TRUE_MIN __DBL_DENORM_MIN__
    142 #    define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
    143 #  endif
    144 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
    145 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
    146 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
    147 #endif
    148 
    149 #endif /* !__has_feature(modules) */
    150 
    151 #endif /* __FLOAT_H */