Subversion Repositories Kolibri OS

Rev

Rev 4874 | Rev 6099 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4874 Rev 4921
Line 1... Line 1...
1
/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */
1
/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */
Line 2... Line 2...
2
 
2
 
Line 3... Line 3...
3
/* Written 2000 by Werner Almesberger */
3
/* Written 2000 by Werner Almesberger */
4
 
4
 
5
/*
5
/*-
6
 * Copyright (c) 1991, 1993
6
 * Copyright (c) 1991, 1993
7
 *	The Regents of the University of California.  All rights reserved.
7
 *	The Regents of the University of California.  All rights reserved.
8
 *
8
 *
Line 15... Line 15...
15
 * 1. Redistributions of source code must retain the above copyright
15
 * 1. Redistributions of source code must retain the above copyright
16
 *    notice, this list of conditions and the following disclaimer.
16
 *    notice, this list of conditions and the following disclaimer.
17
 * 2. Redistributions in binary form must reproduce the above copyright
17
 * 2. Redistributions in binary form must reproduce the above copyright
18
 *    notice, this list of conditions and the following disclaimer in the
18
 *    notice, this list of conditions and the following disclaimer in the
19
 *    documentation and/or other materials provided with the distribution.
19
 *    documentation and/or other materials provided with the distribution.
20
 * 3. All advertising materials mentioning features or use of this software
-
 
21
 *    must display the following acknowledgement:
-
 
22
 *	This product includes software developed by the University of
-
 
23
 *	California, Berkeley and its contributors.
-
 
24
 * 4. Neither the name of the University nor the names of its contributors
20
 * 4. Neither the name of the University nor the names of its contributors
25
 *    may be used to endorse or promote products derived from this software
21
 *    may be used to endorse or promote products derived from this software
26
 *    without specific prior written permission.
22
 *    without specific prior written permission.
27
 *
23
 *
28
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
Line 36... Line 32...
36
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38
 * SUCH DAMAGE.
34
 * SUCH DAMAGE.
39
 *
35
 *
40
 *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
36
 *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
41
 * $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $
37
 * $FreeBSD$
42
 */
38
 */
Line 43... Line 39...
43
 
39
 
44
#ifndef _SYS_CDEFS_H
40
#ifndef	_SYS_CDEFS_H_
Line 45... Line 41...
45
#define _SYS_CDEFS_H
41
#define	_SYS_CDEFS_H_
46
 
-
 
47
#define __FBSDID(x) /* nothing */
-
 
48
/*
42
 
49
 * Note: the goal here is not compatibility to K&R C. Since we know that we
43
#include 
Line 50... Line -...
50
 * have GCC which understands ANSI C perfectly well, we make use of this.
-
 
51
 */
44
#include 
52
 
-
 
53
#define __P(args)	args
-
 
54
#define __PMT(args)	args
-
 
55
#define __const		const
45
#include 
56
#define __signed	signed
46
 
Line -... Line 47...
-
 
47
#define __PMT(args)	args
-
 
48
#define __DOTS    	, ...
-
 
49
#define __THROW
-
 
50
 
-
 
51
#ifdef __GNUC__
-
 
52
# define __ASMNAME(cname)  __XSTRING (__USER_LABEL_PREFIX__) cname
-
 
53
#endif
-
 
54
 
-
 
55
#define __ptr_t void *
-
 
56
#define __long_double_t  long double
-
 
57
 
-
 
58
#define __attribute_malloc__
-
 
59
#define __attribute_pure__
-
 
60
#define __attribute_format_strfmon__(a,b)
-
 
61
#define __flexarr      [0]
-
 
62
 
-
 
63
#ifndef __BOUNDED_POINTERS__
-
 
64
# define __bounded      /* nothing */
-
 
65
# define __unbounded    /* nothing */
-
 
66
# define __ptrvalue     /* nothing */
-
 
67
#endif
-
 
68
 
-
 
69
/*
-
 
70
 * Testing against Clang-specific extensions.
-
 
71
 */
-
 
72
 
-
 
73
#ifndef	__has_extension
-
 
74
#define	__has_extension		__has_feature
-
 
75
#endif
-
 
76
#ifndef	__has_feature
-
 
77
#define	__has_feature(x)	0
-
 
78
#endif
-
 
79
#ifndef	__has_include
-
 
80
#define	__has_include(x)	0
-
 
81
#endif
-
 
82
#ifndef	__has_builtin
-
 
83
#define	__has_builtin(x)	0
-
 
84
#endif
-
 
85
 
-
 
86
#if defined(__cplusplus)
-
 
87
#define	__BEGIN_DECLS	extern "C" {
-
 
88
#define	__END_DECLS	}
-
 
89
#else
-
 
90
#define	__BEGIN_DECLS
-
 
91
#define	__END_DECLS
-
 
92
#endif
-
 
93
 
-
 
94
/*
-
 
95
 * This code has been put in place to help reduce the addition of
-
 
96
 * compiler specific defines in FreeBSD code.  It helps to aid in
-
 
97
 * having a compiler-agnostic source tree.
-
 
98
 */
-
 
99
 
-
 
100
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
-
 
101
 
-
 
102
#if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
-
 
103
#define __GNUCLIKE_ASM 3
-
 
104
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
-
 
105
#else
-
 
106
#define __GNUCLIKE_ASM 2
-
 
107
#endif
-
 
108
#define __GNUCLIKE___TYPEOF 1
-
 
109
#define __GNUCLIKE___OFFSETOF 1
-
 
110
#define __GNUCLIKE___SECTION 1
-
 
111
 
-
 
112
#ifndef __INTEL_COMPILER
-
 
113
# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
-
 
114
#endif
-
 
115
 
-
 
116
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
-
 
117
# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
-
 
118
    && __INTEL_COMPILER < 800
-
 
119
#  undef __GNUCLIKE_BUILTIN_CONSTANT_P
-
 
120
# endif
-
 
121
 
-
 
122
#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
-
 
123
# define __GNUCLIKE_BUILTIN_VARARGS 1
-
 
124
# define __GNUCLIKE_BUILTIN_STDARG 1
-
 
125
# define __GNUCLIKE_BUILTIN_VAALIST 1
-
 
126
#endif
-
 
127
 
-
 
128
#if defined(__GNUC__)
-
 
129
# define __GNUC_VA_LIST_COMPATIBILITY 1
-
 
130
#endif
-
 
131
 
-
 
132
/*
-
 
133
 * Compiler memory barriers, specific to gcc and clang.
-
 
134
 */
-
 
135
#if defined(__GNUC__)
-
 
136
#define	__compiler_membar()	__asm __volatile(" " : : : "memory")
-
 
137
#endif
-
 
138
 
-
 
139
#ifndef __INTEL_COMPILER
-
 
140
# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
-
 
141
# define __GNUCLIKE_MATH_BUILTIN_RELOPS
-
 
142
#endif
-
 
143
 
-
 
144
#define __GNUCLIKE_BUILTIN_MEMCPY 1
-
 
145
 
-
 
146
/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
-
 
147
#define __CC_SUPPORTS_INLINE 1
-
 
148
#define __CC_SUPPORTS___INLINE 1
-
 
149
#define __CC_SUPPORTS___INLINE__ 1
-
 
150
 
-
 
151
#define __CC_SUPPORTS___FUNC__ 1
-
 
152
#define __CC_SUPPORTS_WARNING 1
-
 
153
 
-
 
154
#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
-
 
155
 
57
#define __volatile	volatile
156
#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
58
#define __DOTS    	, ...
157
 
59
#define __THROW
158
#endif /* __GNUC__ || __INTEL_COMPILER */
60
 
159
 
61
/*
160
/*
Line 68... Line 167...
68
 * this only works with ANSI C.
167
 * this only works with ANSI C.
69
 *
168
 *
70
 * __XSTRING is like __STRING, but it expands any macros in its argument
169
 * __XSTRING is like __STRING, but it expands any macros in its argument
71
 * first.  It is only available with ANSI C.
170
 * first.  It is only available with ANSI C.
72
 */
171
 */
-
 
172
#if defined(__STDC__) || defined(__cplusplus)
-
 
173
#define	__P(protos)	protos		/* full-blown ANSI C */
73
#define __CONCAT1(x,y)  x ## y
174
#define __CONCAT1(x,y)  x ## y
74
#define __CONCAT(x,y)   __CONCAT1(x,y)
175
#define __CONCAT(x,y)   __CONCAT1(x,y)
75
#define __STRING(x)     #x              /* stringify without expanding x */
176
#define __STRING(x)     #x              /* stringify without expanding x */
76
#define __XSTRING(x)    __STRING(x)     /* expand x, then stringify */
177
#define __XSTRING(x)    __STRING(x)     /* expand x, then stringify */
Line -... Line 178...
-
 
178
 
-
 
179
#define	__const		const		/* define reserved names to standard */
-
 
180
#define	__signed	signed
-
 
181
#define	__volatile	volatile
-
 
182
#if defined(__cplusplus)
-
 
183
#define	__inline	inline		/* convert to C++ keyword */
-
 
184
#else
-
 
185
#if !(defined(__CC_SUPPORTS___INLINE))
-
 
186
#define	__inline			/* delete GCC keyword */
-
 
187
#endif /* ! __CC_SUPPORTS___INLINE */
-
 
188
#endif /* !__cplusplus */
-
 
189
 
-
 
190
#else	/* !(__STDC__ || __cplusplus) */
-
 
191
#define	__P(protos)	()		/* traditional C preprocessor */
-
 
192
#define	__CONCAT(x,y)	x/**/y
-
 
193
#define	__STRING(x)	"x"
-
 
194
 
-
 
195
#if !defined(__CC_SUPPORTS___INLINE)
-
 
196
#define	__const				/* delete pseudo-ANSI C keywords */
-
 
197
#define	__inline
-
 
198
#define	__signed
-
 
199
#define	__volatile
-
 
200
/*
-
 
201
 * In non-ANSI C environments, new programs will want ANSI-only C keywords
-
 
202
 * deleted from the program and old programs will want them left alone.
-
 
203
 * When using a compiler other than gcc, programs using the ANSI C keywords
-
 
204
 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
-
 
205
 * When using "gcc -traditional", we assume that this is the intent; if
-
 
206
 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
-
 
207
 */
-
 
208
#ifndef	NO_ANSI_KEYWORDS
-
 
209
#define	const				/* delete ANSI C keywords */
-
 
210
#define	inline
-
 
211
#define	signed
-
 
212
#define	volatile
-
 
213
#endif	/* !NO_ANSI_KEYWORDS */
-
 
214
#endif	/* !__CC_SUPPORTS___INLINE */
-
 
215
#endif	/* !(__STDC__ || __cplusplus) */
-
 
216
 
-
 
217
/*
-
 
218
 * Compiler-dependent macros to help declare dead (non-returning) and
-
 
219
 * pure (no side effects) functions, and unused variables.  They are
-
 
220
 * null except for versions of gcc that are known to support the features
-
 
221
 * properly (old versions of gcc-2 supported the dead and pure features
-
 
222
 * in a different (wrong) way).  If we do not provide an implementation
-
 
223
 * for a given compiler, let the compile fail if it is told to use
-
 
224
 * a feature that we cannot live without.
77
 
225
 */
-
 
226
#ifdef lint
-
 
227
#define	__dead2
-
 
228
#define	__pure2
-
 
229
#define	__unused
-
 
230
#define	__packed
-
 
231
#define	__aligned(x)
-
 
232
#define	__section(x)
-
 
233
#else
-
 
234
#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
-
 
235
#define	__dead2
-
 
236
#define	__pure2
-
 
237
#define	__unused
-
 
238
#endif
-
 
239
#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
-
 
240
#define	__dead2		__attribute__((__noreturn__))
-
 
241
#define	__pure2		__attribute__((__const__))
-
 
242
#define	__unused
-
 
243
/* XXX Find out what to do for __packed, __aligned and __section */
-
 
244
#endif
-
 
245
#if __GNUC_PREREQ__(2, 7)
-
 
246
#define	__dead2		__attribute__((__noreturn__))
-
 
247
#define	__pure2		__attribute__((__const__))
-
 
248
#define	__unused	__attribute__((__unused__))
-
 
249
#define	__used		__attribute__((__used__))
-
 
250
#define	__packed	__attribute__((__packed__))
-
 
251
#define	__aligned(x)	__attribute__((__aligned__(x)))
-
 
252
#define	__section(x)	__attribute__((__section__(x)))
-
 
253
#endif
-
 
254
#if defined(__INTEL_COMPILER)
-
 
255
#define __dead2		__attribute__((__noreturn__))
-
 
256
#define __pure2		__attribute__((__const__))
-
 
257
#define __unused	__attribute__((__unused__))
-
 
258
#define __used		__attribute__((__used__))
-
 
259
#define __packed	__attribute__((__packed__))
78
#ifdef __GNUC__
260
#define __aligned(x)	__attribute__((__aligned__(x)))
-
 
261
#define __section(x)	__attribute__((__section__(x)))
79
# define __ASMNAME(cname)  __XSTRING (__USER_LABEL_PREFIX__) cname
262
#endif
Line 80... Line 263...
80
#endif
263
#endif
81
 
264
 
-
 
265
#if !__GNUC_PREREQ__(2, 95)
Line -... Line 266...
-
 
266
#define	__alignof(x)	__offsetof(struct { char __a; x __b; }, __b)
82
#define __ptr_t void *
267
#endif
83
#define __long_double_t  long double
-
 
84
 
-
 
85
#define __attribute_malloc__
268
 
Line -... Line 269...
-
 
269
/*
-
 
270
 * Keywords added in C11.
86
#define __attribute_pure__
271
 */
87
#define __attribute_format_strfmon__(a,b)
272
 
-
 
273
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
88
#define __flexarr      [0]
274
 
89
 
275
#if !__has_extension(c_alignas)
-
 
276
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
90
#ifdef  __cplusplus
277
    __has_extension(cxx_alignas)
91
# define __BEGIN_DECLS  extern "C" {
278
#define	_Alignas(x)		alignas(x)
92
# define __END_DECLS    }
279
#else
Line 93... Line -...
93
#else
-
 
94
# define __BEGIN_DECLS
280
/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
95
# define __END_DECLS
281
#define	_Alignas(x)		__aligned(x)
-
 
282
#endif
96
#endif
283
#endif
97
 
284
 
Line -... Line 285...
-
 
285
#if defined(__cplusplus) && __cplusplus >= 201103L
-
 
286
#define	_Alignof(x)		alignof(x)
-
 
287
#else
-
 
288
#define	_Alignof(x)		__alignof(x)
-
 
289
#endif
-
 
290
 
-
 
291
#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
-
 
292
/*
-
 
293
 * No native support for _Atomic(). Place object in structure to prevent
-
 
294
 * most forms of direct non-atomic access.
-
 
295
 */
-
 
296
#define	_Atomic(T)		struct { T volatile __val; }
-
 
297
#endif
-
 
298
 
-
 
299
#if defined(__cplusplus) && __cplusplus >= 201103L
-
 
300
#define	_Noreturn		[[noreturn]]
-
 
301
#else
-
 
302
#define	_Noreturn		__dead2
-
 
303
#endif
-
 
304
 
-
 
305
#if __GNUC_PREREQ__(4, 6) && !defined(__cplusplus)
-
 
306
/*  Do nothing: _Static_assert() works as per C11 */
-
 
307
#elif !__has_extension(c_static_assert)
-
 
308
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
-
 
309
    __has_extension(cxx_static_assert)
-
 
310
#define	_Static_assert(x, y)	static_assert(x, y)
-
 
311
#elif defined(__COUNTER__)
-
 
312
#define	_Static_assert(x, y)	__Static_assert(x, __COUNTER__)
-
 
313
#define	__Static_assert(x, y)	___Static_assert(x, y)
-
 
314
#define	___Static_assert(x, y)	typedef char __assert_ ## y[(x) ? 1 : -1]
-
 
315
#else
-
 
316
#define	_Static_assert(x, y)	struct __hack
-
 
317
#endif
-
 
318
#endif
-
 
319
 
-
 
320
#if !__has_extension(c_thread_local)
-
 
321
/* XXX: Change this to test against C++11 when clang in base supports it. */
-
 
322
#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
-
 
323
    __has_extension(cxx_thread_local)
-
 
324
#define	_Thread_local		thread_local
-
 
325
#else
-
 
326
#define	_Thread_local		__thread
-
 
327
#endif
-
 
328
#endif
-
 
329
 
-
 
330
#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
-
 
331
 
-
 
332
/*
-
 
333
 * Emulation of C11 _Generic().  Unlike the previously defined C11
-
 
334
 * keywords, it is not possible to implement this using exactly the same
-
 
335
 * syntax.  Therefore implement something similar under the name
-
 
336
 * __generic().  Unlike _Generic(), this macro can only distinguish
-
 
337
 * between a single type, so it requires nested invocations to
-
 
338
 * distinguish multiple cases.
-
 
339
 */
-
 
340
 
-
 
341
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
-
 
342
#define	__generic(expr, t, yes, no)					\
-
 
343
	_Generic(expr, t: yes, default: no)
-
 
344
#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
-
 
345
#define	__generic(expr, t, yes, no)					\
-
 
346
	__builtin_choose_expr(						\
-
 
347
	    __builtin_types_compatible_p(__typeof(expr), t), yes, no)
-
 
348
#endif
-
 
349
 
-
 
350
#if __GNUC_PREREQ__(2, 96)
-
 
351
#define	__malloc_like	__attribute__((__malloc__))
-
 
352
#define	__pure		__attribute__((__pure__))
-
 
353
#else
-
 
354
#define	__malloc_like
-
 
355
#define	__pure
-
 
356
#endif
-
 
357
 
-
 
358
#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
-
 
359
#define	__always_inline	__attribute__((__always_inline__))
-
 
360
#else
-
 
361
#define	__always_inline
-
 
362
#endif
-
 
363
 
-
 
364
#if __GNUC_PREREQ__(3, 1)
-
 
365
#define	__noinline	__attribute__ ((__noinline__))
-
 
366
#else
-
 
367
#define	__noinline
-
 
368
#endif
-
 
369
 
-
 
370
#if __GNUC_PREREQ__(3, 3)
-
 
371
#define __nonnull(x)	__attribute__((__nonnull__(x)))
-
 
372
#else
-
 
373
#define __nonnull(x)
-
 
374
#endif
-
 
375
 
-
 
376
#if __GNUC_PREREQ__(3, 4)
-
 
377
#define	__fastcall	__attribute__((__fastcall__))
-
 
378
#else
-
 
379
#define	__fastcall
-
 
380
#endif
-
 
381
 
-
 
382
#if __GNUC_PREREQ__(4, 1)
-
 
383
#define	__returns_twice	__attribute__((__returns_twice__))
-
 
384
#else
-
 
385
#define	__returns_twice
-
 
386
#endif
-
 
387
 
-
 
388
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
-
 
389
#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
-
 
390
#define	__func__	NULL
-
 
391
#endif
-
 
392
 
-
 
393
/*
-
 
394
 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
-
 
395
 * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
-
 
396
 * a way to define the `restrict' type qualifier without disturbing older
-
 
397
 * software that is unaware of C99 keywords.
-
 
398
 */
-
 
399
#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
-
 
400
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint)
-
 
401
#define	__restrict
-
 
402
#else
-
 
403
#define	__restrict	restrict
-
 
404
#endif
-
 
405
#endif
-
 
406
 
-
 
407
/*
-
 
408
 * GNU C version 2.96 adds explicit branch prediction so that
-
 
409
 * the CPU back-end can hint the processor and also so that
-
 
410
 * code blocks can be reordered such that the predicted path
-
 
411
 * sees a more linear flow, thus improving cache behavior, etc.
-
 
412
 *
-
 
413
 * The following two macros provide us with a way to utilize this
-
 
414
 * compiler feature.  Use __predict_true() if you expect the expression
-
 
415
 * to evaluate to true, and __predict_false() if you expect the
-
 
416
 * expression to evaluate to false.
-
 
417
 *
-
 
418
 * A few notes about usage:
-
 
419
 *
-
 
420
 *	* Generally, __predict_false() error condition checks (unless
-
 
421
 *	  you have some _strong_ reason to do otherwise, in which case
-
 
422
 *	  document it), and/or __predict_true() `no-error' condition
-
 
423
 *	  checks, assuming you want to optimize for the no-error case.
-
 
424
 *
-
 
425
 *	* Other than that, if you don't know the likelihood of a test
-
 
426
 *	  succeeding from empirical or other `hard' evidence, don't
-
 
427
 *	  make predictions.
-
 
428
 *
-
 
429
 *	* These are meant to be used in places that are run `a lot'.
-
 
430
 *	  It is wasteful to make predictions in code that is run
-
 
431
 *	  seldomly (e.g. at subsystem initialization time) as the
-
 
432
 *	  basic block reordering that this affects can often generate
-
 
433
 *	  larger code.
-
 
434
 */
-
 
435
#if __GNUC_PREREQ__(2, 96)
-
 
436
#define __predict_true(exp)     __builtin_expect((exp), 1)
-
 
437
#define __predict_false(exp)    __builtin_expect((exp), 0)
-
 
438
#else
-
 
439
#define __predict_true(exp)     (exp)
-
 
440
#define __predict_false(exp)    (exp)
-
 
441
#endif
-
 
442
 
-
 
443
#if __GNUC_PREREQ__(4, 2)
-
 
444
#define	__hidden	__attribute__((__visibility__("hidden")))
-
 
445
#define	__exported	__attribute__((__visibility__("default")))
-
 
446
#else
-
 
447
#define	__hidden
-
 
448
#define	__exported
-
 
449
#endif
-
 
450
 
-
 
451
#define __offsetof(type, field)	offsetof(type, field)
-
 
452
#define	__rangeof(type, start, end) \
-
 
453
	(__offsetof(type, end) - __offsetof(type, start))
-
 
454
 
-
 
455
/*
-
 
456
 * Given the pointer x to the member m of the struct s, return
-
 
457
 * a pointer to the containing structure.  When using GCC, we first
-
 
458
 * assign pointer x to a local variable, to check that its type is
-
 
459
 * compatible with member m.
-
 
460
 */
-
 
461
#if __GNUC_PREREQ__(3, 1)
-
 
462
#define	__containerof(x, s, m) ({					\
-
 
463
	const volatile __typeof__(((s *)0)->m) *__x = (x);		\
-
 
464
	__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
-
 
465
})
-
 
466
#else
-
 
467
#define	__containerof(x, s, m)						\
-
 
468
	__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
-
 
469
#endif
-
 
470
 
-
 
471
/*
-
 
472
 * Compiler-dependent macros to declare that functions take printf-like
-
 
473
 * or scanf-like arguments.  They are null except for versions of gcc
-
 
474
 * that are known to support the features properly (old versions of gcc-2
-
 
475
 * didn't permit keeping the keywords out of the application namespace).
-
 
476
 */
-
 
477
#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
-
 
478
#define	__printflike(fmtarg, firstvararg)
-
 
479
#define	__scanflike(fmtarg, firstvararg)
-
 
480
#define	__format_arg(fmtarg)
-
 
481
#define	__strfmonlike(fmtarg, firstvararg)
-
 
482
#define	__strftimelike(fmtarg, firstvararg)
-
 
483
#else
-
 
484
#define	__printflike(fmtarg, firstvararg) \
-
 
485
	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
-
 
486
#define	__scanflike(fmtarg, firstvararg) \
-
 
487
	    __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
-
 
488
#define	__format_arg(fmtarg)	__attribute__((__format_arg__ (fmtarg)))
-
 
489
#define	__strfmonlike(fmtarg, firstvararg) \
-
 
490
	    __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
-
 
491
#define	__strftimelike(fmtarg, firstvararg) \
-
 
492
	    __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
-
 
493
#endif
-
 
494
 
-
 
495
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
-
 
496
#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
-
 
497
    defined(__GNUC__) && !defined(__INTEL_COMPILER)
-
 
498
#define	__printf0like(fmtarg, firstvararg) \
98
#ifndef __BOUNDED_POINTERS__
499
	    __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
99
# define __bounded      /* nothing */
500
#else
100
# define __unbounded    /* nothing */
501
#define	__printf0like(fmtarg, firstvararg)
-
 
502
#endif
101
# define __ptrvalue     /* nothing */
503
 
102
#endif
504
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
103
 
505
#ifndef __INTEL_COMPILER
104
#ifdef __GNUC__
506
#define	__strong_reference(sym,aliassym)	\
105
#define	__strong_reference(sym,aliassym)	\
507
	extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
106
	extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
508
#endif
107
#ifdef __ELF__
509
#ifdef __ELF__
108
#ifdef __STDC__
510
#ifdef __STDC__
109
#define	__weak_reference(sym,alias)	\
511
#define	__weak_reference(sym,alias)	\
-
 
512
	__asm__(".weak " #alias);	\
-
 
513
	__asm__(".equ "  #alias ", " #sym)
-
 
514
#define	__warn_references(sym,msg)	\
-
 
515
	__asm__(".section .gnu.warning." #sym);	\
110
	__asm__(".weak " #alias);	\
516
	__asm__(".asciz \"" msg "\"");	\
111
	__asm__(".equ "  #alias ", " #sym)
517
	__asm__(".previous")
112
#define	__warn_references(sym,msg)	\
518
#define	__sym_compat(sym,impl,verid)	\
113
	__asm__(".section .gnu.warning." #sym);	\
519
	__asm__(".symver " #impl ", " #sym "@" #verid)
114
	__asm__(".asciz \"" msg "\"");	\
520
#define	__sym_default(sym,impl,verid)	\
115
	__asm__(".previous")
521
	__asm__(".symver " #impl ", " #sym "@@" #verid)
116
#else
522
#else
117
#define	__weak_reference(sym,alias)	\
523
#define	__weak_reference(sym,alias)	\
-
 
524
	__asm__(".weak alias");		\
-
 
525
	__asm__(".equ alias, sym")
-
 
526
#define	__warn_references(sym,msg)	\
-
 
527
	__asm__(".section .gnu.warning.sym"); \
118
	__asm__(".weak alias");		\
528
	__asm__(".asciz \"msg\"");	\
119
	__asm__(".equ alias, sym")
529
	__asm__(".previous")
120
#define	__warn_references(sym,msg)	\
530
#define	__sym_compat(sym,impl,verid)	\
121
	__asm__(".section .gnu.warning.sym"); \
531
	__asm__(".symver impl, sym@verid")
122
	__asm__(".asciz \"msg\"");	\
532
#define	__sym_default(impl,sym,verid)	\
Line 137... Line 547...
137
#define	__warn_references(sym,msg)	\
547
#define	__warn_references(sym,msg)	\
138
	__asm__(".stabs msg,30,0,0,0");			\
548
	__asm__(".stabs msg,30,0,0,0");			\
139
	__asm__(".stabs \"_/**/sym\",1,0,0,0")
549
	__asm__(".stabs \"_/**/sym\",1,0,0,0")
140
#endif	/* __STDC__ */
550
#endif	/* __STDC__ */
141
#endif	/* __ELF__ */
551
#endif	/* __ELF__ */
-
 
552
#endif	/* __GNUC__ || __INTEL_COMPILER */
-
 
553
 
-
 
554
#ifndef	__FBSDID
-
 
555
#define	__FBSDID(s)	struct __hack
-
 
556
#endif
-
 
557
 
-
 
558
#ifndef	__RCSID
-
 
559
#define	__RCSID(s)	struct __hack
-
 
560
#endif
-
 
561
 
-
 
562
#ifndef	__RCSID_SOURCE
-
 
563
#define	__RCSID_SOURCE(s)	struct __hack
-
 
564
#endif
-
 
565
 
-
 
566
#ifndef	__SCCSID
-
 
567
#define	__SCCSID(s)	struct __hack
-
 
568
#endif
-
 
569
 
-
 
570
#ifndef	__COPYRIGHT
-
 
571
#define	__COPYRIGHT(s)	struct __hack
-
 
572
#endif
-
 
573
 
-
 
574
#ifndef	__DECONST
-
 
575
#define	__DECONST(type, var)	((type)(__uintptr_t)(const void *)(var))
-
 
576
#endif
-
 
577
 
-
 
578
#ifndef	__DEVOLATILE
-
 
579
#define	__DEVOLATILE(type, var)	((type)(__uintptr_t)(volatile void *)(var))
-
 
580
#endif
-
 
581
 
-
 
582
#ifndef	__DEQUALIFY
-
 
583
#define	__DEQUALIFY(type, var)	((type)(__uintptr_t)(const volatile void *)(var))
-
 
584
#endif
-
 
585
 
-
 
586
/*-
-
 
587
 * The following definitions are an extension of the behavior originally
-
 
588
 * implemented in , but with a different level of granularity.
-
 
589
 * POSIX.1 requires that the macros we test be defined before any standard
-
 
590
 * header file is included.
-
 
591
 *
-
 
592
 * Here's a quick run-down of the versions:
-
 
593
 *  defined(_POSIX_SOURCE)		1003.1-1988
-
 
594
 *  _POSIX_C_SOURCE == 1		1003.1-1990
-
 
595
 *  _POSIX_C_SOURCE == 2		1003.2-1992 C Language Binding Option
-
 
596
 *  _POSIX_C_SOURCE == 199309		1003.1b-1993
-
 
597
 *  _POSIX_C_SOURCE == 199506		1003.1c-1995, 1003.1i-1995,
-
 
598
 *					and the omnibus ISO/IEC 9945-1: 1996
-
 
599
 *  _POSIX_C_SOURCE == 200112		1003.1-2001
-
 
600
 *  _POSIX_C_SOURCE == 200809		1003.1-2008
-
 
601
 *
-
 
602
 * In addition, the X/Open Portability Guide, which is now the Single UNIX
-
 
603
 * Specification, defines a feature-test macro which indicates the version of
-
 
604
 * that specification, and which subsumes _POSIX_C_SOURCE.
-
 
605
 *
-
 
606
 * Our macros begin with two underscores to avoid namespace screwage.
-
 
607
 */
-
 
608
 
-
 
609
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
-
 
610
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
-
 
611
#undef _POSIX_C_SOURCE		/* Probably illegal, but beyond caring now. */
-
 
612
#define	_POSIX_C_SOURCE		199009
-
 
613
#endif
-
 
614
 
-
 
615
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
-
 
616
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
-
 
617
#undef _POSIX_C_SOURCE
-
 
618
#define	_POSIX_C_SOURCE		199209
-
 
619
#endif
-
 
620
 
-
 
621
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
-
 
622
#ifdef _XOPEN_SOURCE
-
 
623
#if _XOPEN_SOURCE - 0 >= 700
-
 
624
#define	__XSI_VISIBLE		700
-
 
625
#undef _POSIX_C_SOURCE
-
 
626
#define	_POSIX_C_SOURCE		200809
-
 
627
#elif _XOPEN_SOURCE - 0 >= 600
-
 
628
#define	__XSI_VISIBLE		600
-
 
629
#undef _POSIX_C_SOURCE
-
 
630
#define	_POSIX_C_SOURCE		200112
-
 
631
#elif _XOPEN_SOURCE - 0 >= 500
-
 
632
#define	__XSI_VISIBLE		500
-
 
633
#undef _POSIX_C_SOURCE
-
 
634
#define	_POSIX_C_SOURCE		199506
-
 
635
#endif
-
 
636
#endif
-
 
637
 
-
 
638
/*
-
 
639
 * Deal with all versions of POSIX.  The ordering relative to the tests above is
-
 
640
 * important.
-
 
641
 */
-
 
642
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
-
 
643
#define	_POSIX_C_SOURCE		198808
-
 
644
#endif
-
 
645
#ifdef _POSIX_C_SOURCE
-
 
646
#if _POSIX_C_SOURCE >= 200809
-
 
647
#define	__POSIX_VISIBLE		200809
-
 
648
#define	__ISO_C_VISIBLE		1999
-
 
649
#elif _POSIX_C_SOURCE >= 200112
-
 
650
#define	__POSIX_VISIBLE		200112
-
 
651
#define	__ISO_C_VISIBLE		1999
-
 
652
#elif _POSIX_C_SOURCE >= 199506
-
 
653
#define	__POSIX_VISIBLE		199506
-
 
654
#define	__ISO_C_VISIBLE		1990
-
 
655
#elif _POSIX_C_SOURCE >= 199309
-
 
656
#define	__POSIX_VISIBLE		199309
-
 
657
#define	__ISO_C_VISIBLE		1990
-
 
658
#elif _POSIX_C_SOURCE >= 199209
-
 
659
#define	__POSIX_VISIBLE		199209
-
 
660
#define	__ISO_C_VISIBLE		1990
-
 
661
#elif _POSIX_C_SOURCE >= 199009
-
 
662
#define	__POSIX_VISIBLE		199009
-
 
663
#define	__ISO_C_VISIBLE		1990
-
 
664
#else
-
 
665
#define	__POSIX_VISIBLE		198808
-
 
666
#define	__ISO_C_VISIBLE		0
142
#endif	/* __GNUC__ */
667
#endif /* _POSIX_C_SOURCE */
-
 
668
#else
-
 
669
/*-
-
 
670
 * Deal with _ANSI_SOURCE:
-
 
671
 * If it is defined, and no other compilation environment is explicitly
-
 
672
 * requested, then define our internal feature-test macros to zero.  This
-
 
673
 * makes no difference to the preprocessor (undefined symbols in preprocessing
-
 
674
 * expressions are defined to have value zero), but makes it more convenient for
-
 
675
 * a test program to print out the values.
-
 
676
 *
-
 
677
 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
-
 
678
 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
-
 
679
 * environment (and in fact we will never get here).
-
 
680
 */
-
 
681
#if defined(_ANSI_SOURCE)	/* Hide almost everything. */
-
 
682
#define	__POSIX_VISIBLE		0
-
 
683
#define	__XSI_VISIBLE		0
-
 
684
#define	__BSD_VISIBLE		0
-
 
685
#define	__ISO_C_VISIBLE		1990
-
 
686
#elif defined(_C99_SOURCE)	/* Localism to specify strict C99 env. */
-
 
687
#define	__POSIX_VISIBLE		0
-
 
688
#define	__XSI_VISIBLE		0
-
 
689
#define	__BSD_VISIBLE		0
-
 
690
#define	__ISO_C_VISIBLE		1999
-
 
691
#elif defined(_C11_SOURCE)	/* Localism to specify strict C11 env. */
-
 
692
#define	__POSIX_VISIBLE		0
-
 
693
#define	__XSI_VISIBLE		0
-
 
694
#define	__BSD_VISIBLE		0
-
 
695
#define	__ISO_C_VISIBLE		2011
-
 
696
#elif defined(_GNU_SOURCE)	/* Everything and the kitchen sink. */
-
 
697
#define	__POSIX_VISIBLE		200809
-
 
698
#define	__XSI_VISIBLE		700
-
 
699
#define	__BSD_VISIBLE		1
-
 
700
#define	__ISO_C_VISIBLE		2011
-
 
701
#define	__GNU_VISIBLE		1
-
 
702
#else				/* Default: everything except __GNU_VISIBLE. */
-
 
703
#define	__POSIX_VISIBLE		200809
-
 
704
#define	__XSI_VISIBLE		700
-
 
705
#define	__BSD_VISIBLE		1
-
 
706
#define	__ISO_C_VISIBLE		2011
-
 
707
#endif
-
 
708
#endif
Line 143... Line 709...
143
 
709