Watt-32 tcp/ip  2.2 dev-rel.10
cdefs.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (c) 1991, 1993
8  * The Regents of the University of California. All rights reserved.
9  *
10  * This code is derived from software contributed to Berkeley by
11  * Berkeley Software Design, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution.
21  * 3. All advertising materials mentioning features or use of this software
22  * must display the following acknowledgement:
23  * This product includes software developed by the University of
24  * California, Berkeley and its contributors.
25  * 4. Neither the name of the University nor the names of its contributors
26  * may be used to endorse or promote products derived from this software
27  * without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  * @(#)cdefs.h 8.7 (Berkeley) 1/21/94
42  */
43 
44 #ifndef __SYS_CDEFS_H
45 #define __SYS_CDEFS_H
46 
47 #if defined(__HIGHC__)
48  /*
49  * Note to High-C users:
50  * The below pragma (to suppress warning for '#include_next' line) has no effect
51  * here. The pragma needs to be put in your CFLAGS as
52  * '-Hpragma=Offwarn(491)'.
53  *
54  * The warning w/o this pragma is something like:
55  * "w "../../inc/sys/cdefs.h",L60/C23(#491): Unrecognized preprocessor directive:"
56  */
57 #endif
58 
59 #if defined(__DJGPP__)
60  #include_next <sys/cdefs.h>
61 
62 #elif defined(__CYGWIN__)
63  #include_next <sys/cdefs.h>
64 
65 #elif defined (__MINGW64__)
66  #include_next <sys/cdefs.h>
67 
68 #else
69  #ifdef __cplusplus
70  #define __BEGIN_DECLS extern "C" {
71  #define __END_DECLS }
72  #else
73  #define __BEGIN_DECLS
74  #define __END_DECLS
75  #endif
76 #endif
77 
78 
79 #if defined(__GNUC__)
80  #define W32_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + \
81  __GNUC_PATCHLEVEL__)
82 #else
83  #define W32_GCC_VERSION 0
84 #endif
85 
86 #if defined(__CCDL__)
87  #define cdecl _cdecl
88 
89 #elif !defined(cdecl) && (defined(__MINGW32__) || defined(__CYGWIN__))
90  #define cdecl __attribute__((__cdecl__))
91 #endif
92 
93 #if (W32_GCC_VERSION >= 30100)
94  #define W32_ATTR_DEPRECATED __attribute__((__deprecated__))
95 #else
96  #if defined(_MSC_VER) && (_MSC_VER >= 1700) /* Visual Studio 2011+ ? */
97  #define W32_ATTR_DEPRECATED __declspec(deprecated)
98  #else
99  #define W32_ATTR_DEPRECATED
100  #endif
101 #endif
102 
103 #if defined(_MSC_VER) || defined(__POCC__)
104  #undef cdecl
105  #if (_MSC_VER <= 600)
106  #define cdecl _cdecl
107  #undef __STDC__
108  #define __STDC__ 1
109  #else
110  #define cdecl __cdecl
111  #endif
112  #define NO_ANSI_KEYWORDS
113 
114 #elif defined(__DMC__)
115  #define NO_UNDERSCORE __syscall
116  /* e.g. int NO_UNDERSCORE foo (void); */
117 #endif
118 
119 #ifndef cdecl
120 #define cdecl
121 #endif
122 
123 /*
124  * MinGW-w64 defines both __MINGW64__ *and* __MINGW32__, but __MINGW64__
125  * is only defined for _WIN64 targets. __MINGW64_VERSION_[MAJOR|MINOR]
126  * is defined through MingW64's <_mingw.h>.
127  *
128  * MinGW-w64. I.e. "GCC for both x64 & x86 Windows".
129  * This is not from the mingw.org folks, but from these:
130  * http://mingw-w64.sourceforge.net/
131  *
132  * It uses it's own versioning.
133  *
134  * Using the "official" 32-bit MinGW with Watt-32, the W32_MINGW_VER() macro
135  * tests for some structs and prototypes added in MinGW 3.1 (?). For newer
136  * MinGW-[32|64] versions, we just assume e.g. 'struct timezone' etc. are
137  * available.
138  */
139 #if !defined(__MINGW32__)
140  #define W32_MINGW_VER(major,minor) 0
141 #else
142  #include <_mingw.h>
143 
144  #if defined(__MINGW64_VERSION_MAJOR)
145  /* __MINGW64_VERSION_[MAJOR|MINOR] is defined through _mingw.h in MinGW-w64.
146  * Not a typo; MinGW-64 doesn't define __MINGW64_[MAJOR|MINOR]_VERSION
147  */
148  #define W32_MINGW_VER(major,minor) 1
149 
150  #elif defined(__MINGW_MAJOR_VERSION)
151  /* __MINGW_MAJOR_VERSION is defined through _mingw.h in MinGW-RT v4+.
152  */
153  #define W32_MINGW_VER(major,minor) 1
154 
155  #else /* plain old mingw.org (prior to v4.0): */
156  #define W32_MINGW_VER(major,minor) (__MINGW32_MAJOR_VERSION > (major) || \
157  (__MINGW32_MAJOR_VERSION == (major) && \
158  __MINGW32_MINOR_VERSION >= (minor)))
159  #endif
160 #endif
161 
162 #if defined(_MSC_VER) && !defined(__POCC__)
163  /*
164  * All MS compilers (Quick-C/Visual-C for DOS, VC for Windows) insists
165  * that signal-handlers, atexit functions and var-arg functions must be
166  * defined as cdecl. This is only an issue if a program is using 'fastcall'
167  * globally (cl option '-Gr').
168  * Ref. the use of 'WINAPIV' in the Windows SDKs.
169  *
170  * But Watcom's register call doesn't need this. (wcc386 -ecf)
171  */
172  #undef MS_CDECL
173  #define MS_CDECL cdecl
174 
175  /* See <sys/w32api.h> for the rationale behind 'W32_CALL'. It's
176  * currently forced to 'cdecl' on Windows. Thus 'W32_CDECL' and 'MS_CDECL'
177  * should be important for MSVC users on Windows only. But I'm not
178  * sure....
179  */
180  #define W32_CDECL cdecl
181 #else
182  #define MS_CDECL
183  #define W32_CDECL
184 #endif
185 
186 
187 /*
188  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
189  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
190  * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
191  * in between its arguments. __CONCAT can also concatenate double-quoted
192  * strings produced by the __STRING macro, but this only works with ANSI C.
193  */
194 #if ((defined(__STDC__) && __STDC__) || defined(__cplusplus) || \
195  defined(__TURBOC__)) && !defined(__CYGWIN__)
196  #undef __P
197  #define __P(protos) protos /* full-blown ANSI C */
198  #define __CONCAT(x,y) x ## y
199  #define __STRING(x) #x
200 
201  #define __const const /* define reserved names to standard */
202  #define __signed signed
203 /*#define __volatile volatile */
204  #if defined(__cplusplus)
205  #define __inline inline /* convert to C++ keyword */
206  #elif !defined(__GNUC__) && !defined(_MSC_VER) && !defined(__WATCOMC__)
207  #define __inline /* delete GCC/MSC/Watcom keyword */
208  #endif
209 
210 #else
211  #define __P(protos) () /* traditional C preprocessor */
212  #define __CONCAT(x,y) xy
213  #define __STRING(x) "x"
214 
215  #if !defined(__GNUC__) && !defined(_MSC_VER) && !defined(__WATCOMC__)
216  #define __inline
217  #endif
218 
219  #if !defined(__GNUC__)
220  #define __const /* delete pseudo-ANSI C keywords */
221  #define __signed
222  /* #define __volatile */
223 
224  /*
225  * In non-ANSI C environments, new programs will want ANSI-only C keywords
226  * deleted from the program and old programs will want them left alone.
227  * When using a compiler other than gcc, programs using the ANSI C keywords
228  * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
229  * When using "gcc -traditional", we assume that this is the intent; if
230  * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
231  */
232  #if !defined(NO_ANSI_KEYWORDS)
233  #define const /* delete ANSI C keywords */
234  #define inline
235  #define signed
236  #define volatile
237  #endif
238  #endif /* !__GNUC__ */
239 #endif /* (__STDC__ || __cpluplus) && !__CYGWIN__ */
240 
241 /*
242  * GCC1 and some versions of GCC2 declare dead (non-returning) and
243  * pure (no side effects) functions using "volatile" and "const";
244  * unfortunately, these then cause warnings under "-ansi -pedantic".
245  * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
246  * these work for GNU C++ (modulo a slight glitch in the C++ grammar
247  * in the distribution version of 2.5.5).
248  */
249 #if (W32_GCC_VERSION < 20500)
250  #undef __attribute__
251  #define __attribute__(x) /* delete __attribute__ if non-gcc */
252  #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
253  #undef __dead
254  #undef __pure
255  #define __dead __volatile
256  #define __pure __const
257  #undef __dead2
258  #define __dead2
259  #endif
260 #endif
261 
262 /*
263  * Macros for gcc 4.6+ Pragmas. Ref.:
264  * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
265  */
266 #if (W32_GCC_VERSION >= 40600)
267  #define W32_GCC_PRAGMA(x) _Pragma (#x)
268 #else
269  #define W32_GCC_PRAGMA(x)
270 #endif
271 
272 /*
273  * The above could be used as:
274  * W32_GCC_PRAGMA (message: "Fix this")
275  *
276  * or:
277  * #if (W32_GCC_VERSION >= 40600)
278  * #pragma message ("Fix this")
279  * #endif
280  *
281  * But MSVC (and others besides High-C) doesn't handle a pragma in a
282  * #define statement. Hence must enclose it in an ifdef. Like:
283  *
284  * #if defined(_MSC_VER) && (_MSC_VER >= 1500)
285  * #pragma message ("Fix this")
286  * #endif
287  */
288 
289 /*
290  * Delete pseudo-keywords wherever they are not available or needed.
291  * This seems to break MingW in mysterious ways, so leave it,
292  */
293 #ifndef __dead
294 #define __dead
295 #endif
296 
297 #ifndef __dead2
298 #define __dead2
299 #endif
300 
301 #ifndef __pure
302 #define __pure
303 #endif
304 
305 /*
306  * min() & max() macros
307  */
308 #if defined(__HIGHC__)
309  #undef min
310  #undef max
311  #define min(a,b) _min(a,b) /* intrinsic functions */
312  #define max(a,b) _max(a,b)
313 #endif
314 
315 #ifndef min
316 #define min(a,b) (((a) < (b)) ? (a) : (b))
317 #endif
318 
319 #ifndef max
320 #define max(a,b) (((a) > (b)) ? (a) : (b))
321 #endif
322 
323 /*
324  * from NetBSD's <sys/cdefs_aout.h>
325  *
326  * Written by J.T. Conklin <jtc@wimsey.com> 01/17/95.
327  * Public domain.
328  */
329 
330 /* #define _C_LABEL(x) __CONCAT(_,x) */
331 
332 #if defined(__GNUC__)
333  #define __indr_reference(sym,alias) \
334  __asm__(".stabs \"_" #alias "\",11,0,0,0");\
335  __asm__(".stabs \"_" #sym "\",1,0,0,0");
336 
337  #define __warn_references(sym,msg) \
338  __asm__(".stabs \"" msg "\",30,0,0,0"); \
339  __asm__(".stabs \"_" #sym "\",1,0,0,0");
340 
341  #define __IDSTRING(name,string) \
342  static const char name[] __attribute__((__unused__)) = string
343 #else
344  #define __indr_reference(sym,alias)
345  #define __warn_references(sym,msg)
346  #define __IDSTRING(name,string) static const char name[] = string
347 #endif
348 
349 #define __RCSID(_s) __IDSTRING(rcsid,_s)
350 #define __COPYRIGHT(_s) __IDSTRING(copyright,_s)
351 
352 #define __KERNEL_RCSID(_n,_s) __IDSTRING(__CONCAT(rcsid,_n),_s)
353 #define __KERNEL_COPYRIGHT(_n,_s) __IDSTRING(__CONCAT(copyright,_n),_s)
354 
355 #endif