1 | /* |
2 | * |
3 | Copyright 1989, 1991, 1998 The Open Group |
4 | |
5 | Permission to use, copy, modify, distribute, and sell this software and its |
6 | documentation for any purpose is hereby granted without fee, provided that |
7 | the above copyright notice appear in all copies and that both that |
8 | copyright notice and this permission notice appear in supporting |
9 | documentation. |
10 | |
11 | The above copyright notice and this permission notice shall be included in |
12 | all copies or substantial portions of the Software. |
13 | |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
18 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
20 | |
21 | Except as contained in this notice, the name of The Open Group shall not be |
22 | used in advertising or otherwise to promote the sale, use or other dealings |
23 | in this Software without prior written authorization from The Open Group. |
24 | * |
25 | */ |
26 | |
27 | /* Definitions to make function prototypes manageable */ |
28 | |
29 | #ifndef _XFUNCPROTO_H_ |
30 | #define _XFUNCPROTO_H_ |
31 | |
32 | #ifndef NeedFunctionPrototypes |
33 | #define NeedFunctionPrototypes 1 |
34 | #endif /* NeedFunctionPrototypes */ |
35 | |
36 | #ifndef NeedVarargsPrototypes |
37 | #define NeedVarargsPrototypes 1 |
38 | #endif /* NeedVarargsPrototypes */ |
39 | |
40 | #if NeedFunctionPrototypes |
41 | |
42 | #ifndef NeedNestedPrototypes |
43 | #define NeedNestedPrototypes 1 |
44 | #endif /* NeedNestedPrototypes */ |
45 | |
46 | #ifndef _Xconst |
47 | #define _Xconst const |
48 | #endif /* _Xconst */ |
49 | |
50 | /* Function prototype configuration (see configure for more info) */ |
51 | #if !defined(NARROWPROTO) && \ |
52 | (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) |
53 | #define NARROWPROTO |
54 | #endif |
55 | #ifndef FUNCPROTO |
56 | #define FUNCPROTO 15 |
57 | #endif |
58 | |
59 | #ifndef NeedWidePrototypes |
60 | #ifdef NARROWPROTO |
61 | #define NeedWidePrototypes 0 |
62 | #else |
63 | #define NeedWidePrototypes 1 /* default to make interropt. easier */ |
64 | #endif |
65 | #endif /* NeedWidePrototypes */ |
66 | |
67 | #endif /* NeedFunctionPrototypes */ |
68 | |
69 | #ifndef _XFUNCPROTOBEGIN |
70 | #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */ |
71 | #define _XFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */ |
72 | #define _XFUNCPROTOEND } |
73 | #else |
74 | #define _XFUNCPROTOBEGIN |
75 | #define _XFUNCPROTOEND |
76 | #endif |
77 | #endif /* _XFUNCPROTOBEGIN */ |
78 | |
79 | /* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */ |
80 | #ifndef __has_attribute |
81 | # define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ |
82 | #endif |
83 | #ifndef __has_feature |
84 | # define __has_feature(x) 0 /* Compatibility with non-clang compilers. */ |
85 | #endif |
86 | #ifndef __has_extension |
87 | # define __has_extension(x) 0 /* Compatibility with non-clang compilers. */ |
88 | #endif |
89 | |
90 | /* Added in X11R6.9, so available in any version of modular xproto */ |
91 | #if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4)) |
92 | # define _X_SENTINEL(x) __attribute__ ((__sentinel__(x))) |
93 | #else |
94 | # define _X_SENTINEL(x) |
95 | #endif /* GNUC >= 4 */ |
96 | |
97 | /* Added in X11R6.9, so available in any version of modular xproto */ |
98 | #if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \ |
99 | && !defined(__CYGWIN__) && !defined(__MINGW32__) |
100 | # define _X_EXPORT __attribute__((visibility("default"))) |
101 | # define _X_HIDDEN __attribute__((visibility("hidden"))) |
102 | # define _X_INTERNAL __attribute__((visibility("internal"))) |
103 | #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) |
104 | # define _X_EXPORT __global |
105 | # define _X_HIDDEN __hidden |
106 | # define _X_INTERNAL __hidden |
107 | #else /* not gcc >= 4 and not Sun Studio >= 8 */ |
108 | # define _X_EXPORT |
109 | # define _X_HIDDEN |
110 | # define _X_INTERNAL |
111 | #endif /* GNUC >= 4 */ |
112 | |
113 | /* Branch prediction hints for individual conditionals */ |
114 | /* requires xproto >= 7.0.9 */ |
115 | #if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303) |
116 | # define _X_LIKELY(x) __builtin_expect(!!(x), 1) |
117 | # define _X_UNLIKELY(x) __builtin_expect(!!(x), 0) |
118 | #else /* not gcc >= 3.3 */ |
119 | # define _X_LIKELY(x) (x) |
120 | # define _X_UNLIKELY(x) (x) |
121 | #endif |
122 | |
123 | /* Bulk branch prediction hints via marking error path functions as "cold" */ |
124 | /* requires xproto >= 7.0.25 */ |
125 | #if __has_attribute(__cold__) || \ |
126 | (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */ |
127 | # define _X_COLD __attribute__((__cold__)) |
128 | #else |
129 | # define _X_COLD /* nothing */ |
130 | #endif |
131 | |
132 | /* Added in X11R6.9, so available in any version of modular xproto */ |
133 | #if __has_attribute(deprecated) \ |
134 | || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \ |
135 | || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130)) |
136 | # define _X_DEPRECATED __attribute__((deprecated)) |
137 | #else /* not gcc >= 3.1 */ |
138 | # define _X_DEPRECATED |
139 | #endif |
140 | |
141 | /* requires xproto >= 7.0.30 */ |
142 | #if __has_extension(attribute_deprecated_with_message) || \ |
143 | (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)))) |
144 | # define _X_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg))) |
145 | #else |
146 | # define _X_DEPRECATED_MSG(_msg) _X_DEPRECATED |
147 | #endif |
148 | |
149 | /* requires xproto >= 7.0.17 */ |
150 | #if __has_attribute(noreturn) \ |
151 | || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \ |
152 | || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) |
153 | # define _X_NORETURN __attribute((noreturn)) |
154 | #else |
155 | # define _X_NORETURN |
156 | #endif /* GNUC */ |
157 | |
158 | /* Added in X11R6.9, so available in any version of modular xproto */ |
159 | #if __has_attribute(__format__) \ |
160 | || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203) |
161 | # define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y))) |
162 | #else /* not gcc >= 2.3 */ |
163 | # define _X_ATTRIBUTE_PRINTF(x,y) |
164 | #endif |
165 | |
166 | /* requires xproto >= 7.0.22 */ |
167 | #if __has_attribute(__unused__) \ |
168 | || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205) |
169 | #define _X_UNUSED __attribute__((__unused__)) |
170 | #else |
171 | #define _X_UNUSED /* */ |
172 | #endif |
173 | |
174 | /* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */ |
175 | /* requires xproto >= 7.0.9 |
176 | (introduced in 7.0.8 but didn't support all compilers until 7.0.9) */ |
177 | #if defined(inline) /* assume autoconf set it correctly */ || \ |
178 | (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \ |
179 | (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)) |
180 | # define _X_INLINE inline |
181 | #elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */ |
182 | # define _X_INLINE __inline__ |
183 | #else |
184 | # define _X_INLINE |
185 | #endif |
186 | |
187 | /* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */ |
188 | /* requires xproto >= 7.0.21 */ |
189 | #ifndef _X_RESTRICT_KYWD |
190 | # if defined(restrict) /* assume autoconf set it correctly */ || \ |
191 | (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \ |
192 | && !defined(__cplusplus)) /* Workaround g++ issue on Solaris */ |
193 | # define _X_RESTRICT_KYWD restrict |
194 | # elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */ |
195 | # define _X_RESTRICT_KYWD __restrict__ |
196 | # else |
197 | # define _X_RESTRICT_KYWD |
198 | # endif |
199 | #endif |
200 | |
201 | /* requires xproto >= 7.0.30 */ |
202 | #if __has_attribute(no_sanitize_thread) |
203 | # define _X_NOTSAN __attribute__((no_sanitize_thread)) |
204 | #else |
205 | # define _X_NOTSAN |
206 | #endif |
207 | |
208 | /* Mark a char array/pointer as not containing a NUL-terminated string */ |
209 | /* requires xproto >= 7.0.33 */ |
210 | #if __has_attribute(nonstring) |
211 | # define _X_NONSTRING __attribute__((nonstring)) |
212 | #else |
213 | # define _X_NONSTRING |
214 | #endif |
215 | |
216 | #endif /* _XFUNCPROTO_H_ */ |
217 | |