Update.
[platform/upstream/glibc.git] / misc / sys / cdefs.h
1 /* Copyright (C) 1992,93,94,95,96,97,98,99 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 /* Some user header file might have defined this before.  */
28 #undef  __P
29 #undef  __PMT
30
31 #ifdef __GNUC__
32
33 /* GCC can always grok prototypes.  For C++ programs we add throw()
34    to help it optimize the function calls.  But this works only with
35    gcc 2.8.x and egcs.  */
36 # if defined __cplusplus && __GNUC_PREREQ (2,8)
37 #  define __THROW       throw ()
38 # else
39 #  define __THROW
40 # endif
41 # define __P(args)      args __THROW
42 /* This macro will be used for functions which might take C++ callback
43    functions.  */
44 # define __PMT(args)    args
45
46 #else   /* Not GCC.  */
47
48 # define __inline               /* No inline functions.  */
49
50 # if (defined __STDC__ && __STDC__) || defined __cplusplus
51
52 #  define __P(args)     args
53 #  define __PMT(args)   args
54
55 # else  /* Not ANSI C or C++.  */
56
57 #  define __P(args)     ()      /* No prototypes.  */
58 #  define __PMT(args)   ()
59
60 # endif /* ANSI C or C++.  */
61
62 # define __const        const
63 # define __signed       signed
64 # define __volatile     volatile
65
66 #endif  /* GCC.  */
67
68 /* For these things, GCC behaves the ANSI way normally,
69    and the non-ANSI way under -traditional.  */
70
71 #if defined __STDC__ && __STDC__
72
73 # define __CONCAT(x,y)  x ## y
74 # define __STRING(x)    #x
75
76 /* This is not a typedef so `const __ptr_t' does the right thing.  */
77 # define __ptr_t void *
78 # define __long_double_t  long double
79
80 #else
81
82 # define __CONCAT(x,y)  x/**/y
83 # define __STRING(x)    "x"
84
85 # define __ptr_t char *
86 # define __long_double_t  long double
87
88 /* The BSD header files use the ANSI keywords unmodified (this means that
89    old programs may lose if they use the new keywords as identifiers), but
90    those names are not available under -traditional.  We define them to
91    their __ versions, which are taken care of above.  */
92 # ifdef __USE_BSD
93 #  define const         __const
94 #  define signed                __signed
95 #  define volatile      __volatile
96 # endif
97
98 #endif  /* __STDC__ */
99
100
101 /* C++ needs to know that types and declarations are C, not C++.  */
102 #ifdef  __cplusplus
103 # define __BEGIN_DECLS  extern "C" {
104 # define __END_DECLS    }
105 #else
106 # define __BEGIN_DECLS
107 # define __END_DECLS
108 #endif
109
110 /* __asm__ ("xyz") is used throughout the headers to rename functions
111    at the assembly language level.  This is wrapped by the __REDIRECT
112    macro, in order to support compilers that can do this some other
113    way.  When compilers don't support asm-names at all, we have to do
114    preprocessor tricks instead (which don't have exactly the right
115    semantics, but it's the best we can do).
116
117    Example:
118    int __REDIRECT(setpgrp, __P((__pid_t pid, __pid_t pgrp)), setpgid); */
119
120 #if defined __GNUC__ && __GNUC__ >= 2
121
122 # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
123 # define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
124 # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
125
126 /*
127 #elif __SOME_OTHER_COMPILER__
128
129 # define __REDIRECT(name, proto, alias) name proto; \
130         _Pragma("let " #name " = " #alias)
131 */
132 #endif
133
134 /* GCC has various useful declarations that can be made with the
135    `__attribute__' syntax.  All of the ways we use this do fine if
136    they are omitted for compilers that don't understand it. */
137 #if !defined __GNUC__ || __GNUC__ < 2
138
139 # define __attribute__(xyz)     /* Ignore */
140
141 #endif
142
143 /* At some point during the gcc 2.96 development the `malloc' attribute
144    for functions was introduced.  We don't want to use it unconditionally
145    (although this would be possible) since it generates warnings.  */
146 #if __GNUC_PREREQ (2,96)
147 # define __attribute_malloc__ __attribute__ ((__malloc__))
148 #else
149 # define __attribute_malloc__ /* Ignore */
150 #endif
151
152 /* It is possible to compile containing GCC extensions even if GCC is
153    run in pedantic mode if the uses are carefully marked using the
154    `__extension__' keyword.  But this is not generally available before
155    version 2.8.  */
156 #if !__GNUC_PREREQ (2,8)
157 # define __extension__          /* Ignore */
158 #endif
159
160 /* __restrict is known in EGCS 1.2 and above. */
161 #if !__GNUC_PREREQ (2,92)
162 # define __restrict     /* Ignore */
163 #endif
164
165 #endif   /* sys/cdefs.h */