cdefs.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. /* Copyright (C) 1992-2001, 2002, 2004, 2005, 2006, 2007, 2009
  2. Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _SYS_CDEFS_H
  17. #define _SYS_CDEFS_H 1
  18. /* We are almost always included from features.h. */
  19. #ifndef _FEATURES_H
  20. # include <features.h>
  21. #endif
  22. /* The GNU libc does not support any K&R compilers or the traditional mode
  23. of ISO C compilers anymore. Check for some of the combinations not
  24. anymore supported. */
  25. #if defined __GNUC__ && !defined __STDC__
  26. # error "You need a ISO C conforming compiler to use the glibc headers"
  27. #endif
  28. /* Some user header file might have defined this before. */
  29. #undef __P
  30. #undef __PMT
  31. #ifdef __GNUC__
  32. /* GCC can always grok prototypes. For C++ programs we add throw()
  33. to help it optimize the function calls. But this works only with
  34. gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
  35. as non-throwing using a function attribute since programs can use
  36. the -fexceptions options for C code as well. */
  37. # if !defined __cplusplus && __GNUC_PREREQ (3, 3)
  38. # define __THROW __attribute__ ((__nothrow__))
  39. # define __NTH(fct) __attribute__ ((__nothrow__)) fct
  40. # else
  41. # if defined __cplusplus && __GNUC_PREREQ (2,8)
  42. # define __THROW throw ()
  43. # define __NTH(fct) fct throw ()
  44. # else
  45. # define __THROW
  46. # define __NTH(fct) fct
  47. # endif
  48. # endif
  49. #else /* Not GCC. */
  50. # define __inline /* No inline functions. */
  51. # define __THROW
  52. # define __NTH(fct) fct
  53. # define __const const
  54. # define __signed signed
  55. # define __volatile volatile
  56. #endif /* GCC. */
  57. /* These two macros are not used in glibc anymore. They are kept here
  58. only because some other projects expect the macros to be defined. */
  59. #define __P(args) args
  60. #define __PMT(args) args
  61. /* For these things, GCC behaves the ANSI way normally,
  62. and the non-ANSI way under -traditional. */
  63. #define __CONCAT(x,y) x ## y
  64. #define __STRING(x) #x
  65. /* This is not a typedef so `const __ptr_t' does the right thing. */
  66. #define __ptr_t void *
  67. #define __long_double_t long double
  68. /* C++ needs to know that types and declarations are C, not C++. */
  69. #ifdef __cplusplus
  70. # define __BEGIN_DECLS extern "C" {
  71. # define __END_DECLS }
  72. #else
  73. # define __BEGIN_DECLS
  74. # define __END_DECLS
  75. #endif
  76. /* The standard library needs the functions from the ISO C90 standard
  77. in the std namespace. At the same time we want to be safe for
  78. future changes and we include the ISO C99 code in the non-standard
  79. namespace __c99. The C++ wrapper header take case of adding the
  80. definitions to the global namespace. */
  81. #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
  82. # define __BEGIN_NAMESPACE_STD namespace std {
  83. # define __END_NAMESPACE_STD }
  84. # define __USING_NAMESPACE_STD(name) using std::name;
  85. # define __BEGIN_NAMESPACE_C99 namespace __c99 {
  86. # define __END_NAMESPACE_C99 }
  87. # define __USING_NAMESPACE_C99(name) using __c99::name;
  88. #else
  89. /* For compatibility we do not add the declarations into any
  90. namespace. They will end up in the global namespace which is what
  91. old code expects. */
  92. # define __BEGIN_NAMESPACE_STD
  93. # define __END_NAMESPACE_STD
  94. # define __USING_NAMESPACE_STD(name)
  95. # define __BEGIN_NAMESPACE_C99
  96. # define __END_NAMESPACE_C99
  97. # define __USING_NAMESPACE_C99(name)
  98. #endif
  99. /* Support for bounded pointers. */
  100. #ifndef __BOUNDED_POINTERS__
  101. # define __bounded /* nothing */
  102. # define __unbounded /* nothing */
  103. # define __ptrvalue /* nothing */
  104. #endif
  105. /* Fortify support. */
  106. #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
  107. #define __bos0(ptr) __builtin_object_size (ptr, 0)
  108. #if __GNUC_PREREQ (4,3) \
  109. || (defined __GNUC_RH_RELEASE__ && __GNUC__ == 4 \
  110. && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 2 \
  111. && __GNUC_RH_RELEASE__ >= 31)
  112. # define __warndecl(name, msg) \
  113. extern void name (void) __attribute__((__warning__ (msg)))
  114. # define __warnattr(msg) __attribute__((__warning__ (msg)))
  115. # define __errordecl(name, msg) \
  116. extern void name (void) __attribute__((__error__ (msg)))
  117. #else
  118. # define __warndecl(name, msg) extern void name (void)
  119. # define __warnattr(msg)
  120. # define __errordecl(name, msg) extern void name (void)
  121. #endif
  122. /* Support for flexible arrays. */
  123. #if __GNUC_PREREQ (2,97)
  124. /* GCC 2.97 supports C99 flexible array members. */
  125. # define __flexarr []
  126. #else
  127. # ifdef __GNUC__
  128. # define __flexarr [0]
  129. # else
  130. # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  131. # define __flexarr []
  132. # else
  133. /* Some other non-C99 compiler. Approximate with [1]. */
  134. # define __flexarr [1]
  135. # endif
  136. # endif
  137. #endif
  138. /* __asm__ ("xyz") is used throughout the headers to rename functions
  139. at the assembly language level. This is wrapped by the __REDIRECT
  140. macro, in order to support compilers that can do this some other
  141. way. When compilers don't support asm-names at all, we have to do
  142. preprocessor tricks instead (which don't have exactly the right
  143. semantics, but it's the best we can do).
  144. Example:
  145. int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
  146. #if defined __GNUC__ && __GNUC__ >= 2
  147. # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
  148. # ifdef __cplusplus
  149. # define __REDIRECT_NTH(name, proto, alias) \
  150. name proto __THROW __asm__ (__ASMNAME (#alias))
  151. # else
  152. # define __REDIRECT_NTH(name, proto, alias) \
  153. name proto __asm__ (__ASMNAME (#alias)) __THROW
  154. # endif
  155. # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
  156. # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
  157. /*
  158. #elif __SOME_OTHER_COMPILER__
  159. # define __REDIRECT(name, proto, alias) name proto; \
  160. _Pragma("let " #name " = " #alias)
  161. */
  162. #endif
  163. /* GCC has various useful declarations that can be made with the
  164. `__attribute__' syntax. All of the ways we use this do fine if
  165. they are omitted for compilers that don't understand it. */
  166. #if !defined __GNUC__ || __GNUC__ < 2
  167. # define __attribute__(xyz) /* Ignore */
  168. #endif
  169. /* At some point during the gcc 2.96 development the `malloc' attribute
  170. for functions was introduced. We don't want to use it unconditionally
  171. (although this would be possible) since it generates warnings. */
  172. #if __GNUC_PREREQ (2,96)
  173. # define __attribute_malloc__ __attribute__ ((__malloc__))
  174. #else
  175. # define __attribute_malloc__ /* Ignore */
  176. #endif
  177. /* At some point during the gcc 2.96 development the `pure' attribute
  178. for functions was introduced. We don't want to use it unconditionally
  179. (although this would be possible) since it generates warnings. */
  180. #if __GNUC_PREREQ (2,96)
  181. # define __attribute_pure__ __attribute__ ((__pure__))
  182. #else
  183. # define __attribute_pure__ /* Ignore */
  184. #endif
  185. /* At some point during the gcc 3.1 development the `used' attribute
  186. for functions was introduced. We don't want to use it unconditionally
  187. (although this would be possible) since it generates warnings. */
  188. #if __GNUC_PREREQ (3,1)
  189. # define __attribute_used__ __attribute__ ((__used__))
  190. # define __attribute_noinline__ __attribute__ ((__noinline__))
  191. #else
  192. # define __attribute_used__ __attribute__ ((__unused__))
  193. # define __attribute_noinline__ /* Ignore */
  194. #endif
  195. /* gcc allows marking deprecated functions. */
  196. #if __GNUC_PREREQ (3,2)
  197. # define __attribute_deprecated__ __attribute__ ((__deprecated__))
  198. #else
  199. # define __attribute_deprecated__ /* Ignore */
  200. #endif
  201. /* At some point during the gcc 2.8 development the `format_arg' attribute
  202. for functions was introduced. We don't want to use it unconditionally
  203. (although this would be possible) since it generates warnings.
  204. If several `format_arg' attributes are given for the same function, in
  205. gcc-3.0 and older, all but the last one are ignored. In newer gccs,
  206. all designated arguments are considered. */
  207. #if __GNUC_PREREQ (2,8)
  208. # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
  209. #else
  210. # define __attribute_format_arg__(x) /* Ignore */
  211. #endif
  212. /* At some point during the gcc 2.97 development the `strfmon' format
  213. attribute for functions was introduced. We don't want to use it
  214. unconditionally (although this would be possible) since it
  215. generates warnings. */
  216. #if __GNUC_PREREQ (2,97)
  217. # define __attribute_format_strfmon__(a,b) \
  218. __attribute__ ((__format__ (__strfmon__, a, b)))
  219. #else
  220. # define __attribute_format_strfmon__(a,b) /* Ignore */
  221. #endif
  222. /* The nonull function attribute allows to mark pointer parameters which
  223. must not be NULL. */
  224. #if __GNUC_PREREQ (3,3)
  225. # define __nonnull(params) __attribute__ ((__nonnull__ params))
  226. #else
  227. # define __nonnull(params)
  228. #endif
  229. /* If fortification mode, we warn about unused results of certain
  230. function calls which can lead to problems. */
  231. #if __GNUC_PREREQ (3,4)
  232. # define __attribute_warn_unused_result__ \
  233. __attribute__ ((__warn_unused_result__))
  234. # if __USE_FORTIFY_LEVEL > 0
  235. # define __wur __attribute_warn_unused_result__
  236. # endif
  237. #else
  238. # define __attribute_warn_unused_result__ /* empty */
  239. #endif
  240. #ifndef __wur
  241. # define __wur /* Ignore */
  242. #endif
  243. /* Forces a function to be always inlined. */
  244. #if __GNUC_PREREQ (3,2)
  245. # define __always_inline __inline __attribute__ ((__always_inline__))
  246. #else
  247. # define __always_inline __inline
  248. #endif
  249. /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
  250. inline semantics, unless -fgnu89-inline is used. */
  251. #if !defined __cplusplus || __GNUC_PREREQ (4,3) \
  252. || (defined __GNUC_RH_RELEASE__ && __GNUC__ == 4 \
  253. && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 2 \
  254. && __GNUC_RH_RELEASE__ >= 31)
  255. # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
  256. # define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
  257. # if __GNUC_PREREQ (4,3) \
  258. || (defined __GNUC_RH_RELEASE__ && __GNUC__ == 4 \
  259. && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 2 \
  260. && __GNUC_RH_RELEASE__ >= 31)
  261. # define __extern_always_inline \
  262. extern __always_inline __attribute__ ((__gnu_inline__, __artificial__))
  263. # else
  264. # define __extern_always_inline \
  265. extern __always_inline __attribute__ ((__gnu_inline__))
  266. # endif
  267. # else
  268. # define __extern_inline extern __inline
  269. # if __GNUC_PREREQ (4,3)
  270. # define __extern_always_inline \
  271. extern __always_inline __attribute__ ((__artificial__))
  272. # else
  273. # define __extern_always_inline extern __always_inline
  274. # endif
  275. # endif
  276. #endif
  277. /* GCC 4.3 and above allow passing all anonymous arguments of an
  278. __extern_always_inline function to some other vararg function. */
  279. #if __GNUC_PREREQ (4,3) \
  280. || (defined __GNUC_RH_RELEASE__ && __GNUC__ == 4 \
  281. && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 2 \
  282. && __GNUC_RH_RELEASE__ >= 31)
  283. # define __va_arg_pack() __builtin_va_arg_pack ()
  284. # define __va_arg_pack_len() __builtin_va_arg_pack_len ()
  285. #endif
  286. /* It is possible to compile containing GCC extensions even if GCC is
  287. run in pedantic mode if the uses are carefully marked using the
  288. `__extension__' keyword. But this is not generally available before
  289. version 2.8. */
  290. #if !__GNUC_PREREQ (2,8)
  291. # define __extension__ /* Ignore */
  292. #endif
  293. /* __restrict is known in EGCS 1.2 and above. */
  294. #if !__GNUC_PREREQ (2,92)
  295. # define __restrict /* Ignore */
  296. #endif
  297. /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
  298. array_name[restrict]
  299. GCC 3.1 supports this. */
  300. #if __GNUC_PREREQ (3,1) && !defined __GNUG__
  301. # define __restrict_arr __restrict
  302. #else
  303. # ifdef __GNUC__
  304. # define __restrict_arr /* Not supported in old GCC. */
  305. # else
  306. # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  307. # define __restrict_arr restrict
  308. # else
  309. /* Some other non-C99 compiler. */
  310. # define __restrict_arr /* Not supported. */
  311. # endif
  312. # endif
  313. #endif
  314. #include <bits/wordsize.h>
  315. #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
  316. # define __LDBL_COMPAT 1
  317. # ifdef __REDIRECT
  318. # define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
  319. # define __LDBL_REDIR(name, proto) \
  320. __LDBL_REDIR1 (name, proto, __nldbl_##name)
  321. # define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
  322. # define __LDBL_REDIR_NTH(name, proto) \
  323. __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
  324. # define __LDBL_REDIR1_DECL(name, alias) \
  325. extern __typeof (name) name __asm (__ASMNAME (#alias));
  326. # define __LDBL_REDIR_DECL(name) \
  327. extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
  328. # define __REDIRECT_LDBL(name, proto, alias) \
  329. __LDBL_REDIR1 (name, proto, __nldbl_##alias)
  330. # define __REDIRECT_NTH_LDBL(name, proto, alias) \
  331. __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
  332. # endif
  333. #endif
  334. #if !defined __LDBL_COMPAT || !defined __REDIRECT
  335. # define __LDBL_REDIR1(name, proto, alias) name proto
  336. # define __LDBL_REDIR(name, proto) name proto
  337. # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
  338. # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
  339. # define __LDBL_REDIR_DECL(name)
  340. # ifdef __REDIRECT
  341. # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
  342. # define __REDIRECT_NTH_LDBL(name, proto, alias) \
  343. __REDIRECT_NTH (name, proto, alias)
  344. # endif
  345. #endif
  346. #endif /* sys/cdefs.h */