|
1 /* |
|
2 ** cdefs.h: ISO C interface |
|
3 ** Most of this file was developed by Sendmail, Incorporated, so: |
|
4 ** |
|
5 ** Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers. |
|
6 ** |
|
7 ** Permission to use, copy, modify, and distribute this software for |
|
8 ** any purpose with or without fee is hereby granted, provided that |
|
9 ** the above copyright notice and this permission notice appear in all |
|
10 ** copies. |
|
11 ** |
|
12 ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
|
13 ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
14 ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
15 ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
|
16 ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
17 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
18 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
19 ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
20 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
21 ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
22 ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
23 ** SUCH DAMAGE. |
|
24 ** |
|
25 */ |
|
26 |
|
27 /* |
|
28 ** BSD and Linux already have <sys/cdefs.h> which defines a set of C |
|
29 ** language portability macros that are a defacto standard in the open |
|
30 ** source community. This file allows for building on platforms lacking |
|
31 ** these definitions. |
|
32 */ |
|
33 #ifndef HOND_CDEFS_H |
|
34 # define HOND_CDEFS_H |
|
35 |
|
36 # if defined(__cplusplus) |
|
37 # define __BEGIN_DECLS extern "C" { |
|
38 # define __END_DECLS }; |
|
39 # else /* defined(__cplusplus) */ |
|
40 # define __BEGIN_DECLS |
|
41 # define __END_DECLS |
|
42 # endif /* defined(__cplusplus) */ |
|
43 # if defined(__STDC__) || defined(__cplusplus) |
|
44 # ifndef __P |
|
45 # define __P(protos) protos |
|
46 # endif /* __P */ |
|
47 # define __CONCAT(x,y) x ## y |
|
48 # define __STRING(x) #x |
|
49 # else /* defined(__STDC__) || defined(__cplusplus) */ |
|
50 # define __P(protos) () |
|
51 # define __CONCAT(x,y) x/**/y |
|
52 # define __STRING(x) "x" |
|
53 # define const |
|
54 # define signed |
|
55 # define volatile |
|
56 # endif /* defined(__STDC__) || defined(__cplusplus) */ |
|
57 |
|
58 /* |
|
59 ** Define HOND_DEAD, a macro used to declare functions that do not return |
|
60 ** to their caller. |
|
61 */ |
|
62 # ifndef HOND_DEAD |
|
63 # if __GNUC__ >= 2 |
|
64 # if __GNUC__ == 2 && __GNUC_MINOR__ < 5 |
|
65 # define HOND_DEAD(proto) volatile proto |
|
66 # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ |
|
67 # define HOND_DEAD(proto) proto __attribute__((__noreturn__)) |
|
68 # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 5 */ |
|
69 # else /* __GNUC__ >= 2 */ |
|
70 # define HOND_DEAD(proto) proto |
|
71 # endif /* __GNUC__ >= 2 */ |
|
72 # endif /* HOND_DEAD */ |
|
73 |
|
74 /* |
|
75 ** Define HOND_UNUSED, a macro used to declare variables that may be unused. |
|
76 */ |
|
77 # ifndef HOND_UNUSED |
|
78 # if __GNUC__ >= 2 |
|
79 # if __GNUC__ == 2 && __GNUC_MINOR__ < 7 |
|
80 # define HOND_UNUSED(decl) decl |
|
81 # else /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ |
|
82 # define HOND_UNUSED(decl) decl __attribute__((__unused__)) |
|
83 # endif /* __GNUC__ == 2 && __GNUC_MINOR__ < 7 */ |
|
84 # else /* __GNUC__ >= 2 */ |
|
85 # define HOND_UNUSED(decl) decl |
|
86 # endif /* __GNUC__ >= 2 */ |
|
87 # endif /* HOND_UNUSED */ |
|
88 |
|
89 /* |
|
90 ** The HOND_NONVOLATILE macro is used to declare variables that are not |
|
91 ** volatile, but which must be declared volatile when compiling with |
|
92 ** gcc -O -Wall in order to suppress bogus warning messages. |
|
93 ** |
|
94 ** Variables that actually are volatile should be declared volatile |
|
95 ** using the "volatile" keyword. If a variable actually is volatile, |
|
96 ** then HOND_NONVOLATILE should not be used. |
|
97 ** |
|
98 ** To compile source code with gcc and see all non-bogus warnings use: |
|
99 ** |
|
100 ** gcc -O -Wall -DHOND_OMIT_BOGUS_WARNINGS ... |
|
101 ** |
|
102 ** Do not use -DHOND_OMIT_BOGUS_WARNINGS when compiling production |
|
103 ** software, because there is a performance hit. |
|
104 */ |
|
105 # ifdef HOND_OMIT_BOGUS_WARNINGS |
|
106 # define HOND_NONVOLATILE volatile |
|
107 # else /* HOND_OMIT_BOGUS_WARNINGS */ |
|
108 # define HOND_NONVOLATILE |
|
109 # endif /* HOND_OMIT_BOGUS_WARNINGS */ |
|
110 |
|
111 /* |
|
112 ** Turn on format string argument checking. |
|
113 */ |
|
114 # ifndef HOND_CONF_FORMAT_TEST |
|
115 # if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 |
|
116 # define HOND_CONF_FORMAT_TEST 1 |
|
117 # else /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ |
|
118 # define HOND_CONF_FORMAT_TEST 0 |
|
119 # endif /* __GNUC__ == 2 && __GNUC_MINOR__ >= 7 */ |
|
120 # endif /* HOND_CONF_FORMAT_TEST */ |
|
121 |
|
122 # ifndef PRINTFLIKE |
|
123 # if HOND_CONF_FORMAT_TEST |
|
124 # define PRINTFLIKE(x,y) __attribute__ ((__format__ (__printf__, x, y))) |
|
125 # else /* HOND_CONF_FORMAT_TEST */ |
|
126 # define PRINTFLIKE(x,y) |
|
127 # endif /* HOND_CONF_FORMAT_TEST */ |
|
128 # endif /* ! PRINTFLIKE */ |
|
129 |
|
130 # ifndef SCANFLIKE |
|
131 # if HOND_CONF_FORMAT_TEST |
|
132 # define SCANFLIKE(x,y) __attribute__ ((__format__ (__scanf__, x, y))) |
|
133 # else /* HOND_CONF_FORMAT_TEST */ |
|
134 # define SCANFLIKE(x,y) |
|
135 # endif /* HOND_CONF_FORMAT_TEST */ |
|
136 # endif /* ! SCANFLIKE */ |
|
137 |
|
138 #endif /* ! HOND_CDEFS_H */ |
|
139 |