limits.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // -*- C++ -*-
  2. //===--------------------- support/ibm/limits.h ---------------------------===//
  3. //
  4. // The LLVM Compiler Infrastructure
  5. //
  6. // This file is dual licensed under the MIT and the University of Illinois Open
  7. // Source Licenses. See LICENSE.TXT for details.
  8. //
  9. //===----------------------------------------------------------------------===//
  10. #ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H
  11. #define _LIBCPP_SUPPORT_IBM_LIMITS_H
  12. #if !defined(_AIX) // Linux
  13. #include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN
  14. static const unsigned int _QNAN_F = 0x7fc00000;
  15. #define NANF (*((float *)(&_QNAN_F)))
  16. static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0};
  17. #define NANL (*((long double *)(&_QNAN_LDBL128)))
  18. static const unsigned int _SNAN_F= 0x7f855555;
  19. #define NANSF (*((float *)(&_SNAN_F)))
  20. static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555};
  21. #define NANS (*((double *)(&_SNAN_D)))
  22. static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0};
  23. #define NANSL (*((long double *)(&_SNAN_LDBL128)))
  24. #define __builtin_huge_val() HUGE_VAL
  25. #define __builtin_huge_valf() HUGE_VALF
  26. #define __builtin_huge_vall() HUGE_VALL
  27. #define __builtin_nan(__dummy) NAN
  28. #define __builtin_nanf(__dummy) NANF
  29. #define __builtin_nanl(__dummy) NANL
  30. #define __builtin_nans(__dummy) NANS
  31. #define __builtin_nansf(__dummy) NANSF
  32. #define __builtin_nansl(__dummy) NANSL
  33. #else
  34. #include <math.h>
  35. #include <float.h> // limit constants
  36. #define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000
  37. #define __builtin_huge_valf() HUGE_VALF //0x7f800000
  38. #define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000
  39. #define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000
  40. #define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000
  41. #define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000
  42. #define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555
  43. #define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555
  44. #define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555
  45. #define __FLT_MANT_DIG__ FLT_MANT_DIG
  46. #define __FLT_DIG__ FLT_DIG
  47. #define __FLT_RADIX__ FLT_RADIX
  48. #define __FLT_MIN_EXP__ FLT_MIN_EXP
  49. #define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
  50. #define __FLT_MAX_EXP__ FLT_MAX_EXP
  51. #define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
  52. #define __FLT_MIN__ FLT_MIN
  53. #define __FLT_MAX__ FLT_MAX
  54. #define __FLT_EPSILON__ FLT_EPSILON
  55. // predefined by XLC on LoP
  56. #define __FLT_DENORM_MIN__ 1.40129846e-45F
  57. #define __DBL_MANT_DIG__ DBL_MANT_DIG
  58. #define __DBL_DIG__ DBL_DIG
  59. #define __DBL_MIN_EXP__ DBL_MIN_EXP
  60. #define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
  61. #define __DBL_MAX_EXP__ DBL_MAX_EXP
  62. #define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
  63. #define __DBL_MIN__ DBL_MIN
  64. #define __DBL_MAX__ DBL_MAX
  65. #define __DBL_EPSILON__ DBL_EPSILON
  66. // predefined by XLC on LoP
  67. #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
  68. #define __LDBL_MANT_DIG__ LDBL_MANT_DIG
  69. #define __LDBL_DIG__ LDBL_DIG
  70. #define __LDBL_MIN_EXP__ LDBL_MIN_EXP
  71. #define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
  72. #define __LDBL_MAX_EXP__ LDBL_MAX_EXP
  73. #define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
  74. #define __LDBL_MIN__ LDBL_MIN
  75. #define __LDBL_MAX__ LDBL_MAX
  76. #define __LDBL_EPSILON__ LDBL_EPSILON
  77. // predefined by XLC on LoP
  78. #if __LONGDOUBLE128
  79. #define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
  80. #else
  81. #define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
  82. #endif
  83. // predefined by XLC on LoP
  84. #define __CHAR_BIT__ 8
  85. #endif // _AIX
  86. #endif // _LIBCPP_SUPPORT_IBM_LIMITS_H