libc-config.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 General Public
  5. License as published by the Free Software Foundation; either
  6. version 3 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. General Public License for more details.
  11. You should have received a copy of the GNU 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 it
  27. includes <sys/cdefs.h> which defines __nonnull. Elsewhere it
  28. 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 __glibc_likely
  60. /* <sys/cdefs.h> either does not exist, or predates glibc commit
  61. 2012-12-28T06:33:01Z!siddhesh@redhat.com
  62. (91998e449e0ce758db55aecf2abc3ee510fcbc8f)
  63. and so does not suffice for Gnulib. Prepare to include <cdefs.h>,
  64. which is Gnulib's copy of a 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 __WORDSIZE so that <cdefs.h> does not attempt to include
  70. nonexistent files. Make it a syntax error, since Gnulib does not
  71. use __WORDSIZE now, and if Gnulib uses it later the syntax error
  72. will let us know that __WORDSIZE needs configuring. */
  73. # ifndef __WORDSIZE
  74. # define __WORDSIZE %%%
  75. # endif
  76. /* Undef the macros unconditionally defined by our copy of glibc
  77. <sys/cdefs.h>, so that they do not clash with any system-defined
  78. versions. */
  79. # undef _SYS_CDEFS_H
  80. # undef __ASMNAME
  81. # undef __ASMNAME2
  82. # undef __BEGIN_DECLS
  83. # undef __CONCAT
  84. # undef __END_DECLS
  85. # undef __HAVE_GENERIC_SELECTION
  86. # undef __LDBL_COMPAT
  87. # undef __LDBL_REDIR
  88. # undef __LDBL_REDIR1
  89. # undef __LDBL_REDIR1_DECL
  90. # undef __LDBL_REDIR1_NTH
  91. # undef __LDBL_REDIR2_DECL
  92. # undef __LDBL_REDIR_DECL
  93. # undef __LDBL_REDIR_NTH
  94. # undef __LEAF
  95. # undef __LEAF_ATTR
  96. # undef __NTH
  97. # undef __NTHNL
  98. # undef __REDIRECT
  99. # undef __REDIRECT_LDBL
  100. # undef __REDIRECT_NTH
  101. # undef __REDIRECT_NTHNL
  102. # undef __REDIRECT_NTH_LDBL
  103. # undef __STRING
  104. # undef __THROW
  105. # undef __THROWNL
  106. # undef __attr_access
  107. # undef __attribute__
  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_noinline__
  117. # undef __attribute_nonstring__
  118. # undef __attribute_pure__
  119. # undef __attribute_returns_twice__
  120. # undef __attribute_used__
  121. # undef __attribute_warn_unused_result__
  122. # undef __bos
  123. # undef __bos0
  124. # undef __errordecl
  125. # undef __extension__
  126. # undef __extern_always_inline
  127. # undef __extern_inline
  128. # undef __flexarr
  129. # undef __fortify_function
  130. # undef __glibc_c99_flexarr_available
  131. # undef __glibc_clang_has_attribute
  132. # undef __glibc_clang_has_builtin
  133. # undef __glibc_clang_has_extension
  134. # undef __glibc_macro_warning
  135. # undef __glibc_macro_warning1
  136. # undef __glibc_objsize
  137. # undef __glibc_objsize0
  138. # undef __glibc_unlikely
  139. # undef __inline
  140. # undef __ptr_t
  141. # undef __restrict
  142. # undef __restrict_arr
  143. # undef __va_arg_pack
  144. # undef __va_arg_pack_len
  145. # undef __warnattr
  146. /* Include our copy of glibc <sys/cdefs.h>. */
  147. # include <cdefs.h>
  148. /* <cdefs.h> __inline is too pessimistic for non-GCC. */
  149. # undef __inline
  150. # ifndef HAVE___INLINE
  151. # if 199901 <= __STDC_VERSION__ || defined inline
  152. # define __inline inline
  153. # else
  154. # define __inline
  155. # endif
  156. # endif
  157. #endif /* defined __glibc_likely */
  158. /* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
  159. #define attribute_hidden
  160. #define libc_hidden_proto(name)
  161. #define libc_hidden_def(name)
  162. #define libc_hidden_weak(name)
  163. #define libc_hidden_ver(local, name)
  164. #define strong_alias(name, aliasname)
  165. #define weak_alias(name, aliasname)
  166. /* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
  167. #define SHLIB_COMPAT(lib, introduced, obsoleted) 0
  168. #define compat_symbol(lib, local, symbol, version) extern int dummy
  169. #define versioned_symbol(lib, local, symbol, version) extern int dummy