libc-config.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /* System definitions for code taken from the GNU C Library
  2. Copyright 2017-2021 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. #include <config.h>
  25. /* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
  26. _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and
  27. DragonFlyBSD 5.9 it includes <sys/cdefs.h> which defines __nonnull.
  28. Elsewhere it is harmless. */
  29. #include <errno.h>
  30. /* From glibc <errno.h>. */
  31. #ifndef __set_errno
  32. # define __set_errno(val) (errno = (val))
  33. #endif
  34. /* From glibc <features.h>. */
  35. #ifndef __GNUC_PREREQ
  36. # if defined __GNUC__ && defined __GNUC_MINOR__
  37. # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
  38. # else
  39. # define __GNUC_PREREQ(maj, min) 0
  40. # endif
  41. #endif
  42. #ifndef __glibc_clang_prereq
  43. # if defined __clang_major__ && defined __clang_minor__
  44. # ifdef __apple_build_version__
  45. /* Apple for some reason renumbers __clang_major__ and __clang_minor__.
  46. Gnulib code uses only __glibc_clang_prereq (3, 5); map it to
  47. 6000000 <= __apple_build_version__. Support for other calls to
  48. __glibc_clang_prereq can be added here as needed. */
  49. # define __glibc_clang_prereq(maj, min) \
  50. ((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0)
  51. # else
  52. # define __glibc_clang_prereq(maj, min) \
  53. ((maj) < __clang_major__ + ((min) <= __clang_minor__))
  54. # endif
  55. # else
  56. # define __glibc_clang_prereq(maj, min) 0
  57. # endif
  58. #endif
  59. #ifndef __attribute_maybe_unused__
  60. /* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
  61. Prepare to include <cdefs.h>, which is Gnulib's version of a
  62. more-recent glibc <sys/cdefs.h>. */
  63. /* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
  64. # ifndef _FEATURES_H
  65. # define _FEATURES_H 1
  66. # endif
  67. /* Define __WORDSIZE so that <cdefs.h> does not attempt to include
  68. nonexistent files. Make it a syntax error, since Gnulib does not
  69. use __WORDSIZE now, and if Gnulib uses it later the syntax error
  70. will let us know that __WORDSIZE needs configuring. */
  71. # ifndef __WORDSIZE
  72. # define __WORDSIZE %%%
  73. # endif
  74. /* Undef the macros unconditionally defined by our copy of glibc
  75. <sys/cdefs.h>, so that they do not clash with any system-defined
  76. versions. */
  77. # undef _SYS_CDEFS_H
  78. # undef __ASMNAME
  79. # undef __ASMNAME2
  80. # undef __BEGIN_DECLS
  81. # undef __CONCAT
  82. # undef __END_DECLS
  83. # undef __HAVE_GENERIC_SELECTION
  84. # undef __LDBL_COMPAT
  85. # undef __LDBL_REDIR
  86. # undef __LDBL_REDIR1
  87. # undef __LDBL_REDIR1_DECL
  88. # undef __LDBL_REDIR1_NTH
  89. # undef __LDBL_REDIR2_DECL
  90. # undef __LDBL_REDIR_DECL
  91. # undef __LDBL_REDIR_NTH
  92. # undef __LEAF
  93. # undef __LEAF_ATTR
  94. # undef __NTH
  95. # undef __NTHNL
  96. # undef __REDIRECT
  97. # undef __REDIRECT_LDBL
  98. # undef __REDIRECT_NTH
  99. # undef __REDIRECT_NTHNL
  100. # undef __REDIRECT_NTH_LDBL
  101. # undef __STRING
  102. # undef __THROW
  103. # undef __THROWNL
  104. # undef __attr_access
  105. # undef __attribute__
  106. # undef __attribute_alloc_size__
  107. # undef __attribute_artificial__
  108. # undef __attribute_const__
  109. # undef __attribute_deprecated__
  110. # undef __attribute_deprecated_msg__
  111. # undef __attribute_format_arg__
  112. # undef __attribute_format_strfmon__
  113. # undef __attribute_malloc__
  114. # undef __attribute_noinline__
  115. # undef __attribute_nonstring__
  116. # undef __attribute_pure__
  117. # undef __attribute_returns_twice__
  118. # undef __attribute_used__
  119. # undef __attribute_warn_unused_result__
  120. # undef __bos
  121. # undef __bos0
  122. # undef __errordecl
  123. # undef __extension__
  124. # undef __extern_always_inline
  125. # undef __extern_inline
  126. # undef __flexarr
  127. # undef __fortify_function
  128. # undef __glibc_c99_flexarr_available
  129. # undef __glibc_has_attribute
  130. # undef __glibc_has_builtin
  131. # undef __glibc_has_extension
  132. # undef __glibc_macro_warning
  133. # undef __glibc_macro_warning1
  134. # undef __glibc_objsize
  135. # undef __glibc_objsize0
  136. # undef __glibc_unlikely
  137. # undef __inline
  138. # undef __ptr_t
  139. # undef __restrict
  140. # undef __restrict_arr
  141. # undef __va_arg_pack
  142. # undef __va_arg_pack_len
  143. # undef __warnattr
  144. /* Include our copy of glibc <sys/cdefs.h>. */
  145. # include <cdefs.h>
  146. /* <cdefs.h> __inline is too pessimistic for non-GCC. */
  147. # undef __inline
  148. # ifndef HAVE___INLINE
  149. # if 199901 <= __STDC_VERSION__ || defined inline
  150. # define __inline inline
  151. # else
  152. # define __inline
  153. # endif
  154. # endif
  155. #endif /* defined __glibc_likely */
  156. /* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
  157. #define attribute_hidden
  158. #define libc_hidden_proto(name)
  159. #define libc_hidden_def(name)
  160. #define libc_hidden_weak(name)
  161. #define libc_hidden_ver(local, name)
  162. #define strong_alias(name, aliasname)
  163. #define weak_alias(name, aliasname)
  164. /* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
  165. #define SHLIB_COMPAT(lib, introduced, obsoleted) 0
  166. #define compat_symbol(lib, local, symbol, version) extern int dummy
  167. #define versioned_symbol(lib, local, symbol, version) extern int dummy