libc-config.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /* System definitions for code taken from the GNU C Library
  2. Copyright 2017-2024 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this program; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. /* Written by Paul Eggert. */
  15. /* This is intended to be a good-enough substitute for glibc system
  16. macros like those defined in <sys/cdefs.h>, so that Gnulib code
  17. shared with glibc can do this as the first #include:
  18. #ifndef _LIBC
  19. # include <libc-config.h>
  20. #endif
  21. When compiled as part of glibc this is a no-op; when compiled as
  22. part of Gnulib this includes Gnulib's <config.h> and defines macros
  23. that glibc library code would normally assume.
  24. Note: This header file MUST NOT be included by public header files
  25. of Gnulib. */
  26. #include <config.h>
  27. /* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
  28. _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and
  29. DragonFlyBSD 5.9 it includes <sys/cdefs.h> which defines __nonnull.
  30. Elsewhere it is harmless. */
  31. #include <errno.h>
  32. /* From glibc <errno.h>. */
  33. #ifndef __set_errno
  34. # define __set_errno(val) (errno = (val))
  35. #endif
  36. /* From glibc <features.h>. */
  37. #ifndef __GNUC_PREREQ
  38. # if defined __GNUC__ && defined __GNUC_MINOR__
  39. # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
  40. # else
  41. # define __GNUC_PREREQ(maj, min) 0
  42. # endif
  43. #endif
  44. #ifndef __glibc_clang_prereq
  45. # if defined __clang_major__ && defined __clang_minor__
  46. # ifdef __apple_build_version__
  47. /* Apple for some reason renumbers __clang_major__ and __clang_minor__.
  48. Gnulib code uses only __glibc_clang_prereq (3, 5); map it to
  49. 6000000 <= __apple_build_version__. Support for other calls to
  50. __glibc_clang_prereq can be added here as needed. */
  51. # define __glibc_clang_prereq(maj, min) \
  52. ((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0)
  53. # else
  54. # define __glibc_clang_prereq(maj, min) \
  55. ((maj) < __clang_major__ + ((min) <= __clang_minor__))
  56. # endif
  57. # else
  58. # define __glibc_clang_prereq(maj, min) 0
  59. # endif
  60. #endif
  61. #ifndef __attribute_nonnull__
  62. /* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
  63. Prepare to include <cdefs.h>, which is Gnulib's version of a
  64. more-recent glibc <sys/cdefs.h>. */
  65. /* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
  66. # ifndef _FEATURES_H
  67. # define _FEATURES_H 1
  68. # endif
  69. /* Define __GNULIB_CDEFS so that <cdefs.h> does not attempt to include
  70. nonexistent files. */
  71. # define __GNULIB_CDEFS
  72. /* Undef the macros unconditionally defined by our copy of glibc
  73. <sys/cdefs.h>, so that they do not clash with any system-defined
  74. versions. */
  75. # undef _SYS_CDEFS_H
  76. # undef __ASMNAME
  77. # undef __ASMNAME2
  78. # undef __BEGIN_DECLS
  79. # undef __CONCAT
  80. # undef __END_DECLS
  81. # undef __HAVE_GENERIC_SELECTION
  82. # undef __LDBL_COMPAT
  83. # undef __LDBL_REDIR
  84. # undef __LDBL_REDIR1
  85. # undef __LDBL_REDIR1_DECL
  86. # undef __LDBL_REDIR1_NTH
  87. # undef __LDBL_REDIR2_DECL
  88. # undef __LDBL_REDIR_DECL
  89. # undef __LDBL_REDIR_NTH
  90. # undef __LEAF
  91. # undef __LEAF_ATTR
  92. # undef __NTH
  93. # undef __NTHNL
  94. # undef __REDIRECT
  95. # undef __REDIRECT_LDBL
  96. # undef __REDIRECT_NTH
  97. # undef __REDIRECT_NTHNL
  98. # undef __REDIRECT_NTH_LDBL
  99. # undef __STRING
  100. # undef __THROW
  101. # undef __THROWNL
  102. # undef __attr_access
  103. # undef __attr_access_none
  104. # undef __attr_dealloc
  105. # undef __attr_dealloc_free
  106. # undef __attribute__
  107. # undef __attribute_alloc_align__
  108. # undef __attribute_alloc_size__
  109. # undef __attribute_artificial__
  110. # undef __attribute_const__
  111. # undef __attribute_deprecated__
  112. # undef __attribute_deprecated_msg__
  113. # undef __attribute_format_arg__
  114. # undef __attribute_format_strfmon__
  115. # undef __attribute_malloc__
  116. # undef __attribute_maybe_unused__
  117. # undef __attribute_noinline__
  118. # undef __attribute_nonstring__
  119. # undef __attribute_pure__
  120. # undef __attribute_returns_twice__
  121. # undef __attribute_used__
  122. # undef __attribute_warn_unused_result__
  123. # undef __errordecl
  124. # undef __extension__
  125. # undef __extern_always_inline
  126. # undef __extern_inline
  127. # undef __flexarr
  128. # undef __fortified_attr_access
  129. # undef __fortify_function
  130. # undef __glibc_c99_flexarr_available
  131. # undef __glibc_has_attribute
  132. # undef __glibc_has_builtin
  133. # undef __glibc_has_extension
  134. # undef __glibc_likely
  135. # undef __glibc_macro_warning
  136. # undef __glibc_macro_warning1
  137. # undef __glibc_unlikely
  138. # undef __inline
  139. # undef __ptr_t
  140. # undef __restrict
  141. # undef __restrict_arr
  142. # undef __va_arg_pack
  143. # undef __va_arg_pack_len
  144. # undef __warnattr
  145. # undef __wur
  146. # ifndef __GNULIB_CDEFS
  147. # undef __bos
  148. # undef __bos0
  149. # undef __glibc_fortify
  150. # undef __glibc_fortify_n
  151. # undef __glibc_objsize
  152. # undef __glibc_objsize0
  153. # undef __glibc_safe_len_cond
  154. # undef __glibc_safe_or_unknown_len
  155. # undef __glibc_unsafe_len
  156. # undef __glibc_unsigned_or_positive
  157. # endif
  158. /* Include our copy of glibc <sys/cdefs.h>. */
  159. # include <cdefs.h>
  160. /* <cdefs.h> __inline is too pessimistic for non-GCC. */
  161. # undef __inline
  162. # ifndef HAVE___INLINE
  163. # if 199901 <= __STDC_VERSION__ || defined inline
  164. # define __inline inline
  165. # else
  166. # define __inline
  167. # endif
  168. # endif
  169. #endif /* defined __glibc_likely */
  170. /* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
  171. #define attribute_hidden
  172. #define libc_hidden_proto(name)
  173. #define libc_hidden_def(name)
  174. #define libc_hidden_weak(name)
  175. #define libc_hidden_ver(local, name)
  176. #define strong_alias(name, aliasname)
  177. #define weak_alias(name, aliasname)
  178. /* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
  179. #define SHLIB_COMPAT(lib, introduced, obsoleted) 0
  180. #define compat_symbol(lib, local, symbol, version) extern int dummy
  181. #define versioned_symbol(lib, local, symbol, version) extern int dummy