floatn.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Macros to control TS 18661-3 glibc features on x86.
  2. Copyright (C) 2017-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _BITS_FLOATN_H
  16. #define _BITS_FLOATN_H
  17. #include <features.h>
  18. /* Defined to 1 if the current compiler invocation provides a
  19. floating-point type with the IEEE 754 binary128 format, and this
  20. glibc includes corresponding *f128 interfaces for it. The required
  21. libgcc support was added some time after the basic compiler
  22. support, for x86_64 and x86. */
  23. #if (defined __x86_64__ \
  24. ? __GNUC_PREREQ (4, 3) \
  25. : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
  26. # define __HAVE_FLOAT128 1
  27. #else
  28. # define __HAVE_FLOAT128 0
  29. #endif
  30. /* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
  31. from the default float, double and long double types in this glibc. */
  32. #if __HAVE_FLOAT128
  33. # define __HAVE_DISTINCT_FLOAT128 1
  34. #else
  35. # define __HAVE_DISTINCT_FLOAT128 0
  36. #endif
  37. /* Defined to 1 if the current compiler invocation provides a
  38. floating-point type with the right format for _Float64x, and this
  39. glibc includes corresponding *f64x interfaces for it. */
  40. #define __HAVE_FLOAT64X 1
  41. /* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
  42. of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
  43. the format of _Float128, which must be different from that of long
  44. double. */
  45. #define __HAVE_FLOAT64X_LONG_DOUBLE 1
  46. #ifndef __ASSEMBLER__
  47. /* Defined to concatenate the literal suffix to be used with _Float128
  48. types, if __HAVE_FLOAT128 is 1. */
  49. # if __HAVE_FLOAT128
  50. # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
  51. /* The literal suffix f128 exists only since GCC 7.0. */
  52. # define __f128(x) x##q
  53. # else
  54. # define __f128(x) x##f128
  55. # endif
  56. # endif
  57. /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
  58. # if __HAVE_FLOAT128
  59. # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
  60. /* Add a typedef for older GCC compilers which don't natively support
  61. _Complex _Float128. */
  62. typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
  63. # define __CFLOAT128 __cfloat128
  64. # else
  65. # define __CFLOAT128 _Complex _Float128
  66. # endif
  67. # endif
  68. /* The remaining of this file provides support for older compilers. */
  69. # if __HAVE_FLOAT128
  70. /* The type _Float128 exists only since GCC 7.0. */
  71. # if !__GNUC_PREREQ (7, 0) || defined __cplusplus
  72. typedef __float128 _Float128;
  73. # endif
  74. /* __builtin_huge_valf128 doesn't exist before GCC 7.0. */
  75. # if !__GNUC_PREREQ (7, 0)
  76. # define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
  77. # endif
  78. /* Older GCC has only a subset of built-in functions for _Float128 on
  79. x86, and __builtin_infq is not usable in static initializers.
  80. Converting a narrower sNaN to _Float128 produces a quiet NaN, so
  81. attempts to use _Float128 sNaNs will not work properly with older
  82. compilers. */
  83. # if !__GNUC_PREREQ (7, 0)
  84. # define __builtin_copysignf128 __builtin_copysignq
  85. # define __builtin_fabsf128 __builtin_fabsq
  86. # define __builtin_inff128() ((_Float128) __builtin_inf ())
  87. # define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))
  88. # define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
  89. # endif
  90. /* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
  91. e.g.: __builtin_signbitf128, before GCC 6. However, there has never
  92. been a __builtin_signbitf128 in GCC and the type-generic builtin is
  93. only available since GCC 6. */
  94. # if !__GNUC_PREREQ (6, 0)
  95. # define __builtin_signbitf128 __signbitf128
  96. # endif
  97. # endif
  98. #endif /* !__ASSEMBLER__. */
  99. #include <bits/floatn-common.h>
  100. #endif /* _BITS_FLOATN_H */