xref: /386bsd/usr/src/usr.bin/gcc/cc1/gstddef.h (revision a2142627)
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 /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
46    Just ignore it.  */
47 #if defined (__sequent__) && defined (_PTRDIFF_T_)
48 #undef _PTRDIFF_T_
49 #endif
50 
51 /* In case nobody has defined these types, but we aren't running under
52    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and
53    __WCHAR_TYPE__ have reasonable values.  This can happen if the
54    parts of GCC is compiled by an older compiler, that actually
55    include gstddef.h, such as collect2.  */
56 
57 /* Signed type of difference of two pointers.  */
58 
59 /* Define this type if we are doing the whole job,
60    or if we want this type in particular.  */
61 #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
62 #ifndef _PTRDIFF_T	/* in case <sys/types.h> has defined it. */
63 #ifndef _T_PTRDIFF_
64 #ifndef _T_PTRDIFF
65 #ifndef __PTRDIFF_T
66 #ifndef _PTRDIFF_T_
67 #ifndef ___int_ptrdiff_t_h
68 #ifndef _GCC_PTRDIFF_T
69 #define _PTRDIFF_T
70 #define _T_PTRDIFF_
71 #define _T_PTRDIFF
72 #define __PTRDIFF_T
73 #define _PTRDIFF_T_
74 #define ___int_ptrdiff_t_h
75 #define _GCC_PTRDIFF_T
76 #ifndef __PTRDIFF_TYPE__
77 #define __PTRDIFF_TYPE__ long int
78 #endif
79 typedef __PTRDIFF_TYPE__ ptrdiff_t;
80 #endif /* _GCC_PTRDIFF_T */
81 #endif /* ___int_ptrdiff_t_h */
82 #endif /* _PTRDIFF_T_ */
83 #endif /* __PTRDIFF_T */
84 #endif /* _T_PTRDIFF */
85 #endif /* _T_PTRDIFF_ */
86 #endif /* _PTRDIFF_T */
87 
88 /* If this symbol has done its job, get rid of it.  */
89 #undef	__need_ptrdiff_t
90 
91 #endif /* _STDDEF_H or __need_ptrdiff_t.  */
92 
93 /* Unsigned type of `sizeof' something.  */
94 
95 /* Define this type if we are doing the whole job,
96    or if we want this type in particular.  */
97 #if defined (_STDDEF_H) || defined (__need_size_t)
98 #ifndef _SIZE_T	/* in case <sys/types.h> has defined it. */
99 #ifndef _SYS_SIZE_T_H
100 #ifndef _T_SIZE_
101 #ifndef _T_SIZE
102 #ifndef __SIZE_T
103 #ifndef _SIZE_T_
104 #ifndef ___int_size_t_h
105 #ifndef _GCC_SIZE_T
106 #ifndef _SIZET_
107 #define _SIZE_T
108 #define _SYS_SIZE_T_H
109 #define _T_SIZE_
110 #define _T_SIZE
111 #define __SIZE_T
112 #define _SIZE_T_
113 #define ___int_size_t_h
114 #define _GCC_SIZE_T
115 #define _SIZET_
116 #ifndef __SIZE_TYPE__
117 #define __SIZE_TYPE__ long unsigned int
118 #endif
119 typedef __SIZE_TYPE__ size_t;
120 #endif /* _SIZET_ */
121 #endif /* _GCC_SIZE_T */
122 #endif /* ___int_size_t_h */
123 #endif /* _SIZE_T_ */
124 #endif /* __SIZE_T */
125 #endif /* _T_SIZE */
126 #endif /* _T_SIZE_ */
127 #endif /* _SYS_SIZE_T_H */
128 #endif /* _SIZE_T */
129 #undef	__need_size_t
130 #endif /* _STDDEF_H or __need_size_t.  */
131 
132 
133 /* Wide character type.
134    Locale-writers should change this as necessary to
135    be big enough to hold unique values not between 0 and 127,
136    and not (wchar_t) -1, for each defined multibyte character.  */
137 
138 /* Define this type if we are doing the whole job,
139    or if we want this type in particular.  */
140 #if defined (_STDDEF_H) || defined (__need_wchar_t)
141 #ifndef _WCHAR_T
142 #ifndef _T_WCHAR_
143 #ifndef _T_WCHAR
144 #ifndef __WCHAR_T
145 #ifndef _WCHAR_T_
146 #ifndef ___int_wchar_t_h
147 #ifndef _GCC_WCHAR_T
148 #define _WCHAR_T
149 #define _T_WCHAR_
150 #define _T_WCHAR
151 #define __WCHAR_T
152 #define _WCHAR_T_
153 #define ___int_wchar_t_h
154 #define _GCC_WCHAR_T
155 #ifndef __WCHAR_TYPE__
156 #define __WCHAR_TYPE__ int
157 #endif
158 #ifdef __GNUG__
159 /* In C++, wchar_t is a distinct basic type,
160    and we can expect __wchar_t to be defined by cc1plus.  */
161 typedef __wchar_t wchar_t;
162 #else
163 /* In C, cpp tells us which type to make an alias for.  */
164 typedef __WCHAR_TYPE__ wchar_t;
165 #endif
166 #endif
167 #endif
168 #endif
169 #endif
170 #endif
171 #endif
172 #endif
173 #undef	__need_wchar_t
174 #endif /* _STDDEF_H or __need_wchar_t.  */
175 
176 /*  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
177     are already defined.  We need not worry about the case of wanting just
178     one of these types, not on 4.3bsd-net2, because only the GNU libc
179     header files do that.  */
180 #ifdef _ANSI_H_
181 #undef _PTRDIFF_T_
182 #ifdef _STDDEF_H /* This is a kludge.
183 		    _STDDEF_H is defined when we are using the whole file,
184 		    undefined when obstack.h wants just ptrdiff_t.  */
185 #undef _SIZE_T_
186 #undef _WCHAR_T_
187 #endif
188 #endif
189 
190 #endif /* __sys_stdtypes_h */
191 
192 /* A null pointer constant.  */
193 
194 #if defined (_STDDEF_H) || defined (__need_NULL)
195 #undef NULL		/* in case <stdio.h> has defined it. */
196 #define NULL ((void *)0)
197 #endif	/* NULL not defined and <stddef.h> or need NULL.  */
198 #undef	__need_NULL
199 
200 #ifdef _STDDEF_H
201 
202 /* Offset of member MEMBER in a struct of type TYPE.  */
203 
204 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
205 
206 #endif /* _STDDEF_H was defined this time */
207 
208 #endif /* _ANSI_STDDEF_H was not defined before */
209 #endif /* _STDDEF_H_ was not defined before */
210 #endif /* _STDDEF_H was not defined before */
211