]> git.ipfire.org Git - thirdparty/glibc.git/blob - misc/sys/cdefs.h
996023968862356ca021b8d0f64df845efc17836
[thirdparty/glibc.git] / misc / sys / cdefs.h
1 /* Copyright (C) 1992,93,94,95,96,97,98,99, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 #ifndef _SYS_CDEFS_H
20 #define _SYS_CDEFS_H 1
21
22 /* We are almost always included from features.h. */
23 #ifndef _FEATURES_H
24 # include <features.h>
25 #endif
26
27 /* The GNU libc does not support any K&R compilers or the traditional mode
28 of ISO C compilers anymore. Check for some of the combinations not
29 anymore supported. */
30 #if defined __GNUC__ && !defined __STDC__
31 # error "You need a ISO C conforming compiler to use the glibc headers"
32 #endif
33
34 /* Some user header file might have defined this before. */
35 #undef __P
36 #undef __PMT
37
38 #ifdef __GNUC__
39
40 /* GCC can always grok prototypes. For C++ programs we add throw()
41 to help it optimize the function calls. But this works only with
42 gcc 2.8.x and egcs. */
43 # if defined __cplusplus && __GNUC_PREREQ (2,8)
44 # define __THROW throw ()
45 # else
46 # define __THROW
47 # endif
48 # define __P(args) args __THROW
49 /* This macro will be used for functions which might take C++ callback
50 functions. */
51 # define __PMT(args) args
52
53 #else /* Not GCC. */
54
55 # define __inline /* No inline functions. */
56
57 # define __P(args) args
58 # define __PMT(args) args
59
60 # define __const const
61 # define __signed signed
62 # define __volatile volatile
63
64 #endif /* GCC. */
65
66 /* For these things, GCC behaves the ANSI way normally,
67 and the non-ANSI way under -traditional. */
68
69 #define __CONCAT(x,y) x ## y
70 #define __STRING(x) #x
71
72 /* This is not a typedef so `const __ptr_t' does the right thing. */
73 #define __ptr_t void *
74 #define __long_double_t long double
75
76
77 /* C++ needs to know that types and declarations are C, not C++. */
78 #ifdef __cplusplus
79 # define __BEGIN_DECLS extern "C" {
80 # define __END_DECLS }
81 #else
82 # define __BEGIN_DECLS
83 # define __END_DECLS
84 #endif
85
86
87 /* Support for bounded pointers. */
88 #ifndef __BOUNDED_POINTERS__
89 # define __bounded /* nothing */
90 # define __unbounded /* nothing */
91 # define __ptrvalue /* nothing */
92 #endif
93
94
95 /* __asm__ ("xyz") is used throughout the headers to rename functions
96 at the assembly language level. This is wrapped by the __REDIRECT
97 macro, in order to support compilers that can do this some other
98 way. When compilers don't support asm-names at all, we have to do
99 preprocessor tricks instead (which don't have exactly the right
100 semantics, but it's the best we can do).
101
102 Example:
103 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
104
105 #if defined __GNUC__ && __GNUC__ >= 2
106
107 # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
108 # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
109 # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
110
111 /*
112 #elif __SOME_OTHER_COMPILER__
113
114 # define __REDIRECT(name, proto, alias) name proto; \
115 _Pragma("let " #name " = " #alias)
116 */
117 #endif
118
119 /* GCC has various useful declarations that can be made with the
120 `__attribute__' syntax. All of the ways we use this do fine if
121 they are omitted for compilers that don't understand it. */
122 #if !defined __GNUC__ || __GNUC__ < 2
123 # define __attribute__(xyz) /* Ignore */
124 #endif
125
126 /* At some point during the gcc 2.96 development the `malloc' attribute
127 for functions was introduced. We don't want to use it unconditionally
128 (although this would be possible) since it generates warnings. */
129 #if __GNUC_PREREQ (2,96)
130 # define __attribute_malloc__ __attribute__ ((__malloc__))
131 #else
132 # define __attribute_malloc__ /* Ignore */
133 #endif
134
135 /* At some point during the gcc 2.96 development the `pure' attribute
136 for functions was introduced. We don't want to use it unconditionally
137 (although this would be possible) since it generates warnings. */
138 #if __GNUC_PREREQ (2,96)
139 # define __attribute_pure__ __attribute__ ((__pure__))
140 #else
141 # define __attribute_pure__ /* Ignore */
142 #endif
143
144 /* At some point during the gcc 2.8 development the `format_arg' attribute
145 for functions was introduced. We don't want to use it unconditionally
146 (although this would be possible) since it generates warnings. */
147 #if __GNUC_PREREQ (2,8)
148 # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
149 #else
150 # define __attribute_format_arg__(x) /* Ignore */
151 #endif
152
153 /* It is possible to compile containing GCC extensions even if GCC is
154 run in pedantic mode if the uses are carefully marked using the
155 `__extension__' keyword. But this is not generally available before
156 version 2.8. */
157 #if !__GNUC_PREREQ (2,8)
158 # define __extension__ /* Ignore */
159 #endif
160
161 /* __restrict is known in EGCS 1.2 and above. */
162 #if !__GNUC_PREREQ (2,92)
163 # define __restrict /* Ignore */
164 #endif
165
166 #endif /* sys/cdefs.h */