]> git.ipfire.org Git - thirdparty/glibc.git/blame - misc/sys/cdefs.h
Update to LGPL v2.1.
[thirdparty/glibc.git] / misc / sys / cdefs.h
CommitLineData
852d75f9 1/* Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
54d79e99 2 This file is part of the GNU C Library.
28f540f4 3
54d79e99 4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
28f540f4 8
54d79e99
UD
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
41bdb6e2 12 Lesser General Public License for more details.
28f540f4 13
41bdb6e2
AJ
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
28f540f4
RM
18
19#ifndef _SYS_CDEFS_H
28f540f4 20#define _SYS_CDEFS_H 1
5107cf1d 21
a6ff34d7
UD
22/* We are almost always included from features.h. */
23#ifndef _FEATURES_H
7688db91
UD
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"
a6ff34d7 32#endif
28f540f4
RM
33
34/* Some user header file might have defined this before. */
35#undef __P
d112ae30 36#undef __PMT
28f540f4
RM
37
38#ifdef __GNUC__
39
dff14448
UD
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. */
4360eafd 43# if defined __cplusplus && __GNUC_PREREQ (2,8)
99e46354 44# define __THROW throw ()
dff14448 45# else
99e46354 46# define __THROW
dff14448 47# endif
99e46354 48# define __P(args) args __THROW
dff14448
UD
49/* This macro will be used for functions which might take C++ callback
50 functions. */
9c3a54d4 51# define __PMT(args) args
4360eafd 52
28f540f4
RM
53#else /* Not GCC. */
54
dfd2257a 55# define __inline /* No inline functions. */
28f540f4 56
9b767d19 57# define __THROW
7f4e0e58
UD
58# define __P(args) args
59# define __PMT(args) args
28f540f4 60
c1422e5b
UD
61# define __const const
62# define __signed signed
63# define __volatile volatile
64
28f540f4
RM
65#endif /* GCC. */
66
67/* For these things, GCC behaves the ANSI way normally,
68 and the non-ANSI way under -traditional. */
69
7f4e0e58
UD
70#define __CONCAT(x,y) x ## y
71#define __STRING(x) #x
28f540f4
RM
72
73/* This is not a typedef so `const __ptr_t' does the right thing. */
7f4e0e58
UD
74#define __ptr_t void *
75#define __long_double_t long double
857fa1b8
RM
76
77
28f540f4
RM
78/* C++ needs to know that types and declarations are C, not C++. */
79#ifdef __cplusplus
dfd2257a
UD
80# define __BEGIN_DECLS extern "C" {
81# define __END_DECLS }
28f540f4 82#else
dfd2257a
UD
83# define __BEGIN_DECLS
84# define __END_DECLS
28f540f4
RM
85#endif
86
ab95290c
UD
87
88/* Support for bounded pointers. */
89#ifndef __BOUNDED_POINTERS__
90# define __bounded /* nothing */
91# define __unbounded /* nothing */
5785c39f 92# define __ptrvalue /* nothing */
ab95290c
UD
93#endif
94
95
a1620a4c
UD
96/* Support for flexible arrays. */
97#if __GNUC_PREREQ (2,97)
98/* GCC 2.97 supports C99 flexible array members. */
99# define __flexarr []
100#else
101# ifdef __GNUC__
102# define __flexarr [0]
103# else
8ab5926a 104# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
a1620a4c
UD
105# define __flexarr []
106# else
107/* Some other non-C99 compiler. Approximate with [1]. */
108# define __flexarr [1]
109# endif
110# endif
111#endif
112
113
01cad722
UD
114/* __asm__ ("xyz") is used throughout the headers to rename functions
115 at the assembly language level. This is wrapped by the __REDIRECT
116 macro, in order to support compilers that can do this some other
117 way. When compilers don't support asm-names at all, we have to do
118 preprocessor tricks instead (which don't have exactly the right
119 semantics, but it's the best we can do).
120
121 Example:
fbedbe9d 122 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
01cad722
UD
123
124#if defined __GNUC__ && __GNUC__ >= 2
125
5408c757
UD
126# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
127# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
128# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
01cad722
UD
129
130/*
131#elif __SOME_OTHER_COMPILER__
132
5408c757
UD
133# define __REDIRECT(name, proto, alias) name proto; \
134 _Pragma("let " #name " = " #alias)
01cad722
UD
135*/
136#endif
137
138/* GCC has various useful declarations that can be made with the
28f540f4 139 `__attribute__' syntax. All of the ways we use this do fine if
01cad722 140 they are omitted for compilers that don't understand it. */
dfd2257a 141#if !defined __GNUC__ || __GNUC__ < 2
e9e9b245 142# define __attribute__(xyz) /* Ignore */
ae177b9c
UD
143#endif
144
e9e9b245
UD
145/* At some point during the gcc 2.96 development the `malloc' attribute
146 for functions was introduced. We don't want to use it unconditionally
147 (although this would be possible) since it generates warnings. */
ae177b9c
UD
148#if __GNUC_PREREQ (2,96)
149# define __attribute_malloc__ __attribute__ ((__malloc__))
150#else
151# define __attribute_malloc__ /* Ignore */
01cad722 152#endif
2f6d1f1b 153
ca5a4c3c
AJ
154/* At some point during the gcc 2.96 development the `pure' attribute
155 for functions was introduced. We don't want to use it unconditionally
156 (although this would be possible) since it generates warnings. */
157#if __GNUC_PREREQ (2,96)
158# define __attribute_pure__ __attribute__ ((__pure__))
159#else
160# define __attribute_pure__ /* Ignore */
161#endif
162
ca8d5a5f
UD
163/* At some point during the gcc 2.8 development the `format_arg' attribute
164 for functions was introduced. We don't want to use it unconditionally
165 (although this would be possible) since it generates warnings. */
166#if __GNUC_PREREQ (2,8)
167# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
168#else
169# define __attribute_format_arg__(x) /* Ignore */
170#endif
171
66e23ba1
UD
172/* At some point during the gcc 2.97 development the `strfmon' format
173 attribute for functions was introduced. We don't want to use it
174 unconditionally (although this would be possible) since it
175 generates warnings. */
176#if __GNUC_PREREQ (2,97)
177# define __attribute_format_strfmon__(a,b) \
178 __attribute__ ((__format__ (__strfmon__, a, b)))
179#else
180# define __attribute_format_strfmon__(a,b) /* Ignore */
181#endif
182
8325d82c
UD
183/* It is possible to compile containing GCC extensions even if GCC is
184 run in pedantic mode if the uses are carefully marked using the
185 `__extension__' keyword. But this is not generally available before
186 version 2.8. */
4360eafd 187#if !__GNUC_PREREQ (2,8)
8325d82c 188# define __extension__ /* Ignore */
8325d82c
UD
189#endif
190
a6ff34d7 191/* __restrict is known in EGCS 1.2 and above. */
4360eafd 192#if !__GNUC_PREREQ (2,92)
a6ff34d7 193# define __restrict /* Ignore */
a6ff34d7 194#endif
2f6d1f1b 195
98cbe360
UD
196/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
197 array_name[restrict]
b912ca11 198 GCC 3.1 supports this. */
852d75f9 199#if __GNUC_PREREQ (3,1) && !defined __GNUG__
b912ca11
UD
200# define __restrict_arr __restrict
201#else
202# ifdef __GNUC__
203# define __restrict_arr /* Not supported in old GCC. */
204# else
205# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
206# define __restrict_arr restrict
207# else
208/* Some other non-C99 compiler. */
209# define __restrict_arr /* Not supported. */
210# endif
211# endif
212#endif
98cbe360 213
28f540f4 214#endif /* sys/cdefs.h */