xref: /original-bsd/contrib/gcc-2.3.3/gstddef.h (revision 1897046e)
1 #ifndef _STDDEF_H
2 #ifndef _STDDEF_H_
3 #ifndef _ANSI_STDDEF_H
4 
5 /* Any one of these symbols __need_* means that GNU libc
6    wants us just to define one data type.  So don't define
7    the symbols that indicate this file's entire job has been done.  */
8 #if (!defined(__need_wchar_t) && !defined(__need_size_t)	\
9      && !defined(__need_ptrdiff_t) && !defined(__need_NULL))
10 #define _STDDEF_H
11 #define _STDDEF_H_
12 /* snaroff@next.com says the NeXT needs this.  */
13 #define _ANSI_STDDEF_H
14 #endif
15 
16 #ifndef __sys_stdtypes_h
17 /* This avoids lossage on SunOS but only if stdtypes.h comes first.
18    There's no way to win with the other order!  Sun lossage.  */
19 
20 /* On 4.3bsd-net2, make sure ansi.h is included, so we have
21    one less case to deal with in the following.  */
22 /* #if defined (__BSD_NET2__) || defined (____386BSD____)*/
23 #include <machine/ansi.h>
24 /* #endif*/
25 
26 /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
27     defined if the corresponding type is *not* defined.  */
28 #ifdef _ANSI_H_
29 #ifndef _SIZE_T_
30 #define _SIZE_T
31 #endif
32 #ifndef _PTRDIFF_T_
33 #define _PTRDIFF_T
34 #endif
35 #ifndef _WCHAR_T_
36 #define _WCHAR_T
37 #endif
38 #undef _PTRDIFF_T_
39 #ifndef __need_ptrdiff_t
40 #undef _SIZE_T_
41 #undef _WCHAR_T_
42 #endif
43 #endif /* _ANSI_H_ */
44 
45 /* In case nobody has defined these types, but we aren't running under
46    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
47    __WCHAR_TYPE__ have reasonable values.  This can happen if the
48    parts of GCC is compiled by an older compiler, that actually
49    include gstddef.h, such as collect2.  */
50 
51 /* Signed type of difference of two pointers.  */
52 
53 /* Define this type if we are doing the whole job,
54    or if we want this type in particular.  */
55 #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
56 #ifndef _PTRDIFF_T	/* in case <sys/types.h> has defined it. */
57 #ifndef _T_PTRDIFF_
58 #ifndef _T_PTRDIFF
59 #ifndef __PTRDIFF_T
60 #ifndef _PTRDIFF_T_
61 #ifndef ___int_ptrdiff_t_h
62 #ifndef _GCC_PTRDIFF_T
63 #define _PTRDIFF_T
64 #define _T_PTRDIFF_
65 #define _T_PTRDIFF
66 #define __PTRDIFF_T
67 #define _PTRDIFF_T_
68 #define ___int_ptrdiff_t_h
69 #define _GCC_PTRDIFF_T
70 #ifndef __PTRDIFF_TYPE__
71 #define __PTRDIFF_TYPE__ long int
72 #endif
73 typedef __PTRDIFF_TYPE__ ptrdiff_t;
74 #endif /* _GCC_PTRDIFF_T */
75 #endif /* ___int_ptrdiff_t_h */
76 #endif /* _PTRDIFF_T_ */
77 #endif /* __PTRDIFF_T */
78 #endif /* _T_PTRDIFF */
79 #endif /* _T_PTRDIFF_ */
80 #endif /* _PTRDIFF_T */
81 
82 /* If this symbol has done its job, get rid of it.  */
83 #undef	__need_ptrdiff_t
84 
85 #endif /* _STDDEF_H or __need_ptrdiff_t.  */
86 
87 /* Unsigned type of `sizeof' something.  */
88 
89 /* Define this type if we are doing the whole job,
90    or if we want this type in particular.  */
91 #if defined (_STDDEF_H) || defined (__need_size_t)
92 #ifndef _SIZE_T	/* in case <sys/types.h> has defined it. */
93 #ifndef _T_SIZE_
94 #ifndef _T_SIZE
95 #ifndef __SIZE_T
96 #ifndef _SIZE_T_
97 #ifndef ___int_size_t_h
98 #ifndef _GCC_SIZE_T
99 #ifndef _SIZET_
100 #define _SIZE_T
101 #define _T_SIZE_
102 #define _T_SIZE
103 #define __SIZE_T
104 #define _SIZE_T_
105 #define ___int_size_t_h
106 #define _GCC_SIZE_T
107 #define _SIZET_
108 #ifndef __SIZE_TYPE__
109 #define __SIZE_TYPE__ long unsigned int
110 #endif
111 typedef __SIZE_TYPE__ size_t;
112 #endif /* _SIZET_ */
113 #endif /* _GCC_SIZE_T */
114 #endif /* ___int_size_t_h */
115 #endif /* _SIZE_T_ */
116 #endif /* __SIZE_T */
117 #endif /* _T_SIZE */
118 #endif /* _T_SIZE_ */
119 #endif /* _SIZE_T */
120 #undef	__need_size_t
121 #endif /* _STDDEF_H or __need_size_t.  */
122 
123 
124 /* Wide character type.
125    Locale-writers should change this as necessary to
126    be big enough to hold unique values not between 0 and 127,
127    and not (wchar_t) -1, for each defined multibyte character.  */
128 
129 /* Define this type if we are doing the whole job,
130    or if we want this type in particular.  */
131 #if defined (_STDDEF_H) || defined (__need_wchar_t)
132 #ifndef _WCHAR_T
133 #ifndef _T_WCHAR_
134 #ifndef _T_WCHAR
135 #ifndef __WCHAR_T
136 #ifndef _WCHAR_T_
137 #ifndef ___int_wchar_t_h
138 #ifndef _GCC_WCHAR_T
139 #define _WCHAR_T
140 #define _T_WCHAR_
141 #define _T_WCHAR
142 #define __WCHAR_T
143 #define _WCHAR_T_
144 #define ___int_wchar_t_h
145 #define _GCC_WCHAR_T
146 #ifndef __WCHAR_TYPE__
147 #define __WCHAR_TYPE__ int
148 #endif
149 #ifdef __GNUG__
150 /* In C++, wchar_t is a distinct basic type,
151    and we can expect __wchar_t to be defined by cc1plus.  */
152 typedef __wchar_t wchar_t;
153 #else
154 /* In C, cpp tells us which type to make an alias for.  */
155 typedef __WCHAR_TYPE__ wchar_t;
156 #endif
157 #endif
158 #endif
159 #endif
160 #endif
161 #endif
162 #endif
163 #endif
164 #undef	__need_wchar_t
165 #endif /* _STDDEF_H or __need_wchar_t.  */
166 
167 /*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
168     are already defined.  We need not worry about the case of wanting just
169     one of these types, not on 4.3bsd-net2, because only the GNU libc
170     header files do that.  */
171 #ifdef _ANSI_H_
172 #undef _PTRDIFF_T_
173 #ifdef _STDDEF_H /* This is a kludge.
174 		    _STDDEF_H is defined when we are using the whole file,
175 		    undefined when obstack.h wants just ptrdiff_t.  */
176 #undef _SIZE_T_
177 #undef _WCHAR_T_
178 #endif
179 #endif
180 
181 #endif /* __sys_stdtypes_h */
182 
183 /* A null pointer constant.  */
184 
185 #if defined (_STDDEF_H) || defined (__need_NULL)
186 #undef NULL		/* in case <stdio.h> has defined it. */
187 #define NULL ((void *)0)
188 #endif	/* NULL not defined and <stddef.h> or need NULL.  */
189 #undef	__need_NULL
190 
191 #ifdef _STDDEF_H
192 
193 /* Offset of member MEMBER in a struct of type TYPE.  */
194 
195 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
196 
197 #endif /* _STDDEF_H was defined this time */
198 
199 #endif /* _ANSI_STDDEF_H was not defined before */
200 #endif /* _STDDEF_H_ was not defined before */
201 #endif /* _STDDEF_H was not defined before */
202