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