xref: /illumos-gate/usr/src/compat/bhyve/sys/cdefs.h (revision 069e6b7e31ba5dcbc5441b98af272714d9a5455c)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2013 Pluribus Networks Inc.
14  * Copyright 2017 Joyent, Inc.
15  */
16 
17 #ifndef _COMPAT_FREEBSD_SYS_CDEFS_H_
18 #define	_COMPAT_FREEBSD_SYS_CDEFS_H_
19 
20 /*
21  * Testing against Clang-specific extensions.
22  */
23 #ifndef __has_extension
24 #define	__has_extension		__has_feature
25 #endif
26 #ifndef __has_feature
27 #define	__has_feature(x)	0
28 #endif
29 
30 /*
31  * Macro to test if we're using a specific version of gcc or later.
32  */
33 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
34 #define __GNUC_PREREQ__(ma, mi) \
35 	(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
36 #else
37 #define __GNUC_PREREQ__(ma, mi) 0
38 #endif
39 
40 #define	__FBSDID(s)
41 
42 #ifdef	__GNUC__
43 #define	asm		__asm
44 #define	inline		__inline
45 
46 #define	__GNUCLIKE___SECTION		1
47 
48 #define	__dead2		__attribute__((__noreturn__))
49 #define	__used		__attribute__((__used__))
50 #define	__packed	__attribute__((__packed__))
51 #define	__aligned(x)	__attribute__((__aligned__(x)))
52 #define	__section(x)	__attribute__((__section__(x)))
53 #define	__weak_symbol   __attribute__((__weak__))
54 #endif
55 
56 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
57 
58 #if !__has_extension(c_static_assert)
59 #if (defined(__cplusplus) && __cplusplus >= 201103L) || \
60     __has_extension(cxx_static_assert)
61 #define _Static_assert(x, y)    static_assert(x, y)
62 #elif __GNUC_PREREQ__(4,6)
63 /* Nothing, gcc 4.6 and higher has _Static_assert built-in */
64 #elif defined(__COUNTER__)
65 #define _Static_assert(x, y)    __Static_assert(x, __COUNTER__)
66 #define __Static_assert(x, y)   ___Static_assert(x, y)
67 #define ___Static_assert(x, y)  typedef char __assert_ ## y[(x) ? 1 : -1] \
68                                 __unused
69 #else
70 #define _Static_assert(x, y)    struct __hack
71 #endif
72 #endif
73 #define	static_assert(x, y)	_Static_assert(x, y)
74 
75 #endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
76 
77 #endif	/* _COMPAT_FREEBSD_SYS_CDEFS_H_ */
78