libc-header-start.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Handle feature test macros at the start of a header.
  17. Copyright (C) 2016-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library; if not, see
  29. <https://www.gnu.org/licenses/>. */
  30. /* This header is internal to glibc and should not be included outside
  31. of glibc headers. Headers including it must define
  32. __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header
  33. cannot have multiple include guards because ISO C feature test
  34. macros depend on the definition of the macro when an affected
  35. header is included, not when the first system header is
  36. included. */
  37. #ifndef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
  38. # error "Never include <bits/libc-header-start.h> directly."
  39. #endif
  40. #undef __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
  41. #include <features.h>
  42. /* ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__
  43. macro. */
  44. #undef __GLIBC_USE_LIB_EXT2
  45. #if (defined __USE_GNU \
  46. || (defined __STDC_WANT_LIB_EXT2__ && __STDC_WANT_LIB_EXT2__ > 0))
  47. # define __GLIBC_USE_LIB_EXT2 1
  48. #else
  49. # define __GLIBC_USE_LIB_EXT2 0
  50. #endif
  51. /* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__
  52. macro. Most but not all symbols enabled by that macro in TS
  53. 18661-1 are enabled unconditionally in C23. In C23, the symbols in
  54. Annex F still require a new feature test macro
  55. __STDC_WANT_IEC_60559_EXT__ instead (C23 does not define
  56. __STDC_WANT_IEC_60559_BFP_EXT__), while a few features from TS
  57. 18661-1 are not included in C23 (and thus should depend on
  58. __STDC_WANT_IEC_60559_BFP_EXT__ even when C23 features are
  59. enabled).
  60. __GLIBC_USE (IEC_60559_BFP_EXT) controls those features from TS
  61. 18661-1 not included in C23.
  62. __GLIBC_USE (IEC_60559_BFP_EXT_C23) controls those features from TS
  63. 18661-1 that are also included in C23 (with no feature test macro
  64. required in C23).
  65. __GLIBC_USE (IEC_60559_EXT) controls those features from TS 18661-1
  66. that are included in C23 but conditional on
  67. __STDC_WANT_IEC_60559_EXT__. (There are currently no features
  68. conditional on __STDC_WANT_IEC_60559_EXT__ that are not in TS
  69. 18661-1.) */
  70. #undef __GLIBC_USE_IEC_60559_BFP_EXT
  71. #if defined __USE_GNU || defined __STDC_WANT_IEC_60559_BFP_EXT__
  72. # define __GLIBC_USE_IEC_60559_BFP_EXT 1
  73. #else
  74. # define __GLIBC_USE_IEC_60559_BFP_EXT 0
  75. #endif
  76. #undef __GLIBC_USE_IEC_60559_BFP_EXT_C23
  77. #if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC23)
  78. # define __GLIBC_USE_IEC_60559_BFP_EXT_C23 1
  79. #else
  80. # define __GLIBC_USE_IEC_60559_BFP_EXT_C23 0
  81. #endif
  82. #undef __GLIBC_USE_IEC_60559_EXT
  83. #if __GLIBC_USE (IEC_60559_BFP_EXT) || defined __STDC_WANT_IEC_60559_EXT__
  84. # define __GLIBC_USE_IEC_60559_EXT 1
  85. #else
  86. # define __GLIBC_USE_IEC_60559_EXT 0
  87. #endif
  88. /* ISO/IEC TS 18661-4:2015 defines the
  89. __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. Other than the reduction
  90. functions, the symbols from this TS are enabled unconditionally in
  91. C23. */
  92. #undef __GLIBC_USE_IEC_60559_FUNCS_EXT
  93. #if defined __USE_GNU || defined __STDC_WANT_IEC_60559_FUNCS_EXT__
  94. # define __GLIBC_USE_IEC_60559_FUNCS_EXT 1
  95. #else
  96. # define __GLIBC_USE_IEC_60559_FUNCS_EXT 0
  97. #endif
  98. #undef __GLIBC_USE_IEC_60559_FUNCS_EXT_C23
  99. #if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC23)
  100. # define __GLIBC_USE_IEC_60559_FUNCS_EXT_C23 1
  101. #else
  102. # define __GLIBC_USE_IEC_60559_FUNCS_EXT_C23 0
  103. #endif
  104. /* ISO/IEC TS 18661-3:2015 defines the
  105. __STDC_WANT_IEC_60559_TYPES_EXT__ macro. */
  106. #undef __GLIBC_USE_IEC_60559_TYPES_EXT
  107. #if defined __USE_GNU || defined __STDC_WANT_IEC_60559_TYPES_EXT__
  108. # define __GLIBC_USE_IEC_60559_TYPES_EXT 1
  109. #else
  110. # define __GLIBC_USE_IEC_60559_TYPES_EXT 0
  111. #endif