|  | @@ -30,12 +30,31 @@
 | 
	
		
			
				|  |  |   * SUCH DAMAGE.
 | 
	
		
			
				|  |  |   *
 | 
	
		
			
				|  |  |   *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
 | 
	
		
			
				|  |  | - * $FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $
 | 
	
		
			
				|  |  | + * $FreeBSD$
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifndef	_SYS_CDEFS_H_
 | 
	
		
			
				|  |  |  #define	_SYS_CDEFS_H_
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Testing against Clang-specific extensions.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +#ifndef	__has_attribute
 | 
	
		
			
				|  |  | +#define	__has_attribute(x)	0
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#ifndef	__has_extension
 | 
	
		
			
				|  |  | +#define	__has_extension		__has_feature
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#ifndef	__has_feature
 | 
	
		
			
				|  |  | +#define	__has_feature(x)	0
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#ifndef	__has_include
 | 
	
		
			
				|  |  | +#define	__has_include(x)	0
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#ifndef	__has_builtin
 | 
	
		
			
				|  |  | +#define	__has_builtin(x)	0
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  #if defined(__cplusplus)
 | 
	
		
			
				|  |  |  #define	__BEGIN_DECLS	extern "C" {
 | 
	
		
			
				|  |  |  #define	__END_DECLS	}
 | 
	
	
		
			
				|  | @@ -53,53 +72,60 @@
 | 
	
		
			
				|  |  |  #if defined(__GNUC__) || defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  | -#define __GNUCLIKE_ASM 3
 | 
	
		
			
				|  |  | -#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_ASM 3
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_MATH_BUILTIN_CONSTANTS
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  | -#define __GNUCLIKE_ASM 2
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_ASM 2
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  | -#define __GNUCLIKE___TYPEOF 1
 | 
	
		
			
				|  |  | -#define __GNUCLIKE___OFFSETOF 1
 | 
	
		
			
				|  |  | -#define __GNUCLIKE___SECTION 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE___TYPEOF 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE___OFFSETOF 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE___SECTION 1
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifndef __INTEL_COMPILER
 | 
	
		
			
				|  |  | -# define __GNUCLIKE_CTOR_SECTION_HANDLING 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_CTOR_SECTION_HANDLING 1
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
 | 
	
		
			
				|  |  | -# if defined(__INTEL_COMPILER) && defined(__cplusplus) \
 | 
	
		
			
				|  |  | -    && __INTEL_COMPILER < 800
 | 
	
		
			
				|  |  | -#  undef __GNUCLIKE_BUILTIN_CONSTANT_P
 | 
	
		
			
				|  |  | -# endif
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_BUILTIN_CONSTANT_P 1
 | 
	
		
			
				|  |  | +#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \
 | 
	
		
			
				|  |  | +   __INTEL_COMPILER < 800
 | 
	
		
			
				|  |  | +#undef __GNUCLIKE_BUILTIN_CONSTANT_P
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  | -# define __GNUCLIKE_BUILTIN_VARARGS 1
 | 
	
		
			
				|  |  | -# define __GNUCLIKE_BUILTIN_STDARG 1
 | 
	
		
			
				|  |  | -# define __GNUCLIKE_BUILTIN_VAALIST 1
 | 
	
		
			
				|  |  | +#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_BUILTIN_VARARGS 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_BUILTIN_STDARG 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_BUILTIN_VAALIST 1
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #if defined(__GNUC__)
 | 
	
		
			
				|  |  | -# define __GNUC_VA_LIST_COMPATIBILITY 1
 | 
	
		
			
				|  |  | +#define	__GNUC_VA_LIST_COMPATIBILITY 1
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Compiler memory barriers, specific to gcc and clang.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +#if defined(__GNUC__)
 | 
	
		
			
				|  |  | +#define	__compiler_membar()	__asm __volatile(" " : : : "memory")
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifndef __INTEL_COMPILER
 | 
	
		
			
				|  |  | -# define __GNUCLIKE_BUILTIN_NEXT_ARG 1
 | 
	
		
			
				|  |  | -# define __GNUCLIKE_MATH_BUILTIN_RELOPS
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_BUILTIN_NEXT_ARG 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_MATH_BUILTIN_RELOPS
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define __GNUCLIKE_BUILTIN_MEMCPY 1
 | 
	
		
			
				|  |  | +#define	__GNUCLIKE_BUILTIN_MEMCPY 1
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS_INLINE 1
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS___INLINE 1
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS___INLINE__ 1
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS_INLINE 1
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS___INLINE 1
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS___INLINE__ 1
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS___FUNC__ 1
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS_WARNING 1
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS___FUNC__ 1
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS_WARNING 1
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
 | 
	
		
			
				|  |  | +#define	__CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #endif /* __GNUC__ || __INTEL_COMPILER */
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -185,8 +211,12 @@
 | 
	
		
			
				|  |  |  #define	__unused
 | 
	
		
			
				|  |  |  #define	__packed
 | 
	
		
			
				|  |  |  #define	__aligned(x)
 | 
	
		
			
				|  |  | +#define	__alloc_align(x)
 | 
	
		
			
				|  |  | +#define	__alloc_size(x)
 | 
	
		
			
				|  |  |  #define	__section(x)
 | 
	
		
			
				|  |  | +#define	__weak_symbol
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  | +#define	__weak_symbol	__attribute__((__weak__))
 | 
	
		
			
				|  |  |  #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  |  #define	__dead2
 | 
	
		
			
				|  |  |  #define	__pure2
 | 
	
	
		
			
				|  | @@ -198,7 +228,7 @@
 | 
	
		
			
				|  |  |  #define	__unused
 | 
	
		
			
				|  |  |  /* XXX Find out what to do for __packed, __aligned and __section */
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  | -#if __GNUC_PREREQ__(2, 7)
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  |  #define	__dead2		__attribute__((__noreturn__))
 | 
	
		
			
				|  |  |  #define	__pure2		__attribute__((__const__))
 | 
	
		
			
				|  |  |  #define	__unused	__attribute__((__unused__))
 | 
	
	
		
			
				|  | @@ -207,17 +237,109 @@
 | 
	
		
			
				|  |  |  #define	__aligned(x)	__attribute__((__aligned__(x)))
 | 
	
		
			
				|  |  |  #define	__section(x)	__attribute__((__section__(x)))
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  | -#if defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  | -#define __dead2		__attribute__((__noreturn__))
 | 
	
		
			
				|  |  | -#define __pure2		__attribute__((__const__))
 | 
	
		
			
				|  |  | -#define __unused	__attribute__((__unused__))
 | 
	
		
			
				|  |  | -#define __used		__attribute__((__used__))
 | 
	
		
			
				|  |  | -#define __packed	__attribute__((__packed__))
 | 
	
		
			
				|  |  | -#define __aligned(x)	__attribute__((__aligned__(x)))
 | 
	
		
			
				|  |  | -#define __section(x)	__attribute__((__section__(x)))
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(4, 3) || __has_attribute(__alloc_size__)
 | 
	
		
			
				|  |  | +#define	__alloc_size(x)	__attribute__((__alloc_size__(x)))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__alloc_size(x)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(4, 9) || __has_attribute(__alloc_align__)
 | 
	
		
			
				|  |  | +#define	__alloc_align(x)	__attribute__((__alloc_align__(x)))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__alloc_align(x)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#endif /* lint */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if !__GNUC_PREREQ__(2, 95)
 | 
	
		
			
				|  |  | +#define	__alignof(x)	__offsetof(struct { char __a; x __b; }, __b)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Keywords added in C11.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if !__has_extension(c_alignas)
 | 
	
		
			
				|  |  | +#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
 | 
	
		
			
				|  |  | +    __has_extension(cxx_alignas)
 | 
	
		
			
				|  |  | +#define	_Alignas(x)		alignas(x)
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */
 | 
	
		
			
				|  |  | +#define	_Alignas(x)		__aligned(x)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if defined(__cplusplus) && __cplusplus >= 201103L
 | 
	
		
			
				|  |  | +#define	_Alignof(x)		alignof(x)
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	_Alignof(x)		__alignof(x)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic)
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * No native support for _Atomic(). Place object in structure to prevent
 | 
	
		
			
				|  |  | + * most forms of direct non-atomic access.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +#define	_Atomic(T)		struct { T volatile __val; }
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if defined(__cplusplus) && __cplusplus >= 201103L
 | 
	
		
			
				|  |  | +#define	_Noreturn		[[noreturn]]
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	_Noreturn		__dead2
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if !__has_extension(c_static_assert)
 | 
	
		
			
				|  |  | +#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
 | 
	
		
			
				|  |  | +    __has_extension(cxx_static_assert)
 | 
	
		
			
				|  |  | +#define	_Static_assert(x, y)	static_assert(x, y)
 | 
	
		
			
				|  |  | +#elif __GNUC_PREREQ__(4,6)
 | 
	
		
			
				|  |  | +/* Nothing, gcc 4.6 and higher has _Static_assert built-in */
 | 
	
		
			
				|  |  | +#elif defined(__COUNTER__)
 | 
	
		
			
				|  |  | +#define	_Static_assert(x, y)	__Static_assert(x, __COUNTER__)
 | 
	
		
			
				|  |  | +#define	__Static_assert(x, y)	___Static_assert(x, y)
 | 
	
		
			
				|  |  | +#define	___Static_assert(x, y)	typedef char __assert_ ## y[(x) ? 1 : -1] \
 | 
	
		
			
				|  |  | +				__unused
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	_Static_assert(x, y)	struct __hack
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#if !__has_extension(c_thread_local)
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode
 | 
	
		
			
				|  |  | + * without actually supporting the thread_local keyword. Don't check for
 | 
	
		
			
				|  |  | + * the presence of C++11 when defining _Thread_local.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \
 | 
	
		
			
				|  |  | +    __has_extension(cxx_thread_local)
 | 
	
		
			
				|  |  | +#define	_Thread_local		thread_local
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	_Thread_local		__thread
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Emulation of C11 _Generic().  Unlike the previously defined C11
 | 
	
		
			
				|  |  | + * keywords, it is not possible to implement this using exactly the same
 | 
	
		
			
				|  |  | + * syntax.  Therefore implement something similar under the name
 | 
	
		
			
				|  |  | + * __generic().  Unlike _Generic(), this macro can only distinguish
 | 
	
		
			
				|  |  | + * between a single type, so it requires nested invocations to
 | 
	
		
			
				|  |  | + * distinguish multiple cases.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
 | 
	
		
			
				|  |  | +    __has_extension(c_generic_selections)
 | 
	
		
			
				|  |  | +#define	__generic(expr, t, yes, no)					\
 | 
	
		
			
				|  |  | +	_Generic(expr, t: yes, default: no)
 | 
	
		
			
				|  |  | +#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
 | 
	
		
			
				|  |  | +#define	__generic(expr, t, yes, no)					\
 | 
	
		
			
				|  |  | +	__builtin_choose_expr(						\
 | 
	
		
			
				|  |  | +	    __builtin_types_compatible_p(__typeof(expr), t), yes, no)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  #if __GNUC_PREREQ__(2, 96)
 | 
	
		
			
				|  |  |  #define	__malloc_like	__attribute__((__malloc__))
 | 
	
		
			
				|  |  |  #define	__pure		__attribute__((__pure__))
 | 
	
	
		
			
				|  | @@ -239,9 +361,31 @@
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #if __GNUC_PREREQ__(3, 3)
 | 
	
		
			
				|  |  | -#define __nonnull(x)	__attribute__((__nonnull__(x)))
 | 
	
		
			
				|  |  | +#define	__nonnull(x)	__attribute__((__nonnull__(x)))
 | 
	
		
			
				|  |  | +#define	__nonnull_all	__attribute__((__nonnull__))
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  | -#define __nonnull(x)
 | 
	
		
			
				|  |  | +#define	__nonnull(x)
 | 
	
		
			
				|  |  | +#define	__nonnull_all
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(3, 4)
 | 
	
		
			
				|  |  | +#define	__fastcall	__attribute__((__fastcall__))
 | 
	
		
			
				|  |  | +#define	__result_use_check	__attribute__((__warn_unused_result__))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__fastcall
 | 
	
		
			
				|  |  | +#define	__result_use_check
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(4, 1)
 | 
	
		
			
				|  |  | +#define	__returns_twice	__attribute__((__returns_twice__))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__returns_twice
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(4, 6) || __has_builtin(__builtin_unreachable)
 | 
	
		
			
				|  |  | +#define	__unreachable()	__builtin_unreachable()
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__unreachable()	((void)0)
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
 | 
	
	
		
			
				|  | @@ -253,6 +397,17 @@
 | 
	
		
			
				|  |  |  #define	__LONG_LONG_SUPPORTED
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/* C++11 exposes a load of C99 stuff */
 | 
	
		
			
				|  |  | +#if defined(__cplusplus) && __cplusplus >= 201103L
 | 
	
		
			
				|  |  | +#define	__LONG_LONG_SUPPORTED
 | 
	
		
			
				|  |  | +#ifndef	__STDC_LIMIT_MACROS
 | 
	
		
			
				|  |  | +#define	__STDC_LIMIT_MACROS
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#ifndef	__STDC_CONSTANT_MACROS
 | 
	
		
			
				|  |  | +#define	__STDC_CONSTANT_MACROS
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /*
 | 
	
		
			
				|  |  |   * GCC 2.95 provides `__restrict' as an extension to C90 to support the
 | 
	
		
			
				|  |  |   * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
 | 
	
	
		
			
				|  | @@ -296,19 +451,21 @@
 | 
	
		
			
				|  |  |   *	  larger code.
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  #if __GNUC_PREREQ__(2, 96)
 | 
	
		
			
				|  |  | -#define __predict_true(exp)     __builtin_expect((exp), 1)
 | 
	
		
			
				|  |  | -#define __predict_false(exp)    __builtin_expect((exp), 0)
 | 
	
		
			
				|  |  | +#define	__predict_true(exp)     __builtin_expect((exp), 1)
 | 
	
		
			
				|  |  | +#define	__predict_false(exp)    __builtin_expect((exp), 0)
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  | -#define __predict_true(exp)     (exp)
 | 
	
		
			
				|  |  | -#define __predict_false(exp)    (exp)
 | 
	
		
			
				|  |  | +#define	__predict_true(exp)     (exp)
 | 
	
		
			
				|  |  | +#define	__predict_false(exp)    (exp)
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -#if __GNUC_PREREQ__(4, 2)
 | 
	
		
			
				|  |  | -#define	__hidden	__attribute__((__visibility__("hidden")))
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(4, 0)
 | 
	
		
			
				|  |  | +#define	__null_sentinel	__attribute__((__sentinel__))
 | 
	
		
			
				|  |  |  #define	__exported	__attribute__((__visibility__("default")))
 | 
	
		
			
				|  |  | +#define	__hidden	__attribute__((__visibility__("hidden")))
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  | -#define	__hidden
 | 
	
		
			
				|  |  | +#define	__null_sentinel
 | 
	
		
			
				|  |  |  #define	__exported
 | 
	
		
			
				|  |  | +#define	__hidden
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /*
 | 
	
	
		
			
				|  | @@ -316,13 +473,14 @@
 | 
	
		
			
				|  |  |   * require it.
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  #if __GNUC_PREREQ__(4, 1)
 | 
	
		
			
				|  |  | -#define __offsetof(type, field)	 __builtin_offsetof(type, field)
 | 
	
		
			
				|  |  | +#define	__offsetof(type, field)	 __builtin_offsetof(type, field)
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  |  #ifndef __cplusplus
 | 
	
		
			
				|  |  | -#define	__offsetof(type, field)	((size_t)(&((type *)0)->field))
 | 
	
		
			
				|  |  | +#define	__offsetof(type, field) \
 | 
	
		
			
				|  |  | +	((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field))
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  | -#define __offsetof(type, field)					\
 | 
	
		
			
				|  |  | -  (__offsetof__ (reinterpret_cast <size_t>			\
 | 
	
		
			
				|  |  | +#define	__offsetof(type, field)					\
 | 
	
		
			
				|  |  | +  (__offsetof__ (reinterpret_cast <__size_t>			\
 | 
	
		
			
				|  |  |                   (&reinterpret_cast <const volatile char &>	\
 | 
	
		
			
				|  |  |                    (static_cast<type *> (0)->field))))
 | 
	
		
			
				|  |  |  #endif
 | 
	
	
		
			
				|  | @@ -330,6 +488,22 @@
 | 
	
		
			
				|  |  |  #define	__rangeof(type, start, end) \
 | 
	
		
			
				|  |  |  	(__offsetof(type, end) - __offsetof(type, start))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Given the pointer x to the member m of the struct s, return
 | 
	
		
			
				|  |  | + * a pointer to the containing structure.  When using GCC, we first
 | 
	
		
			
				|  |  | + * assign pointer x to a local variable, to check that its type is
 | 
	
		
			
				|  |  | + * compatible with member m.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(3, 1)
 | 
	
		
			
				|  |  | +#define	__containerof(x, s, m) ({					\
 | 
	
		
			
				|  |  | +	const volatile __typeof(((s *)0)->m) *__x = (x);		\
 | 
	
		
			
				|  |  | +	__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
 | 
	
		
			
				|  |  | +})
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__containerof(x, s, m)						\
 | 
	
		
			
				|  |  | +	__DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m))
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  /*
 | 
	
		
			
				|  |  |   * Compiler-dependent macros to declare that functions take printf-like
 | 
	
		
			
				|  |  |   * or scanf-like arguments.  They are null except for versions of gcc
 | 
	
	
		
			
				|  | @@ -340,16 +514,39 @@
 | 
	
		
			
				|  |  |  #define	__printflike(fmtarg, firstvararg)
 | 
	
		
			
				|  |  |  #define	__scanflike(fmtarg, firstvararg)
 | 
	
		
			
				|  |  |  #define	__format_arg(fmtarg)
 | 
	
		
			
				|  |  | +#define	__strfmonlike(fmtarg, firstvararg)
 | 
	
		
			
				|  |  | +#define	__strftimelike(fmtarg, firstvararg)
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  |  #define	__printflike(fmtarg, firstvararg) \
 | 
	
		
			
				|  |  |  	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 | 
	
		
			
				|  |  |  #define	__scanflike(fmtarg, firstvararg) \
 | 
	
		
			
				|  |  |  	    __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
 | 
	
		
			
				|  |  |  #define	__format_arg(fmtarg)	__attribute__((__format_arg__ (fmtarg)))
 | 
	
		
			
				|  |  | +#define	__strfmonlike(fmtarg, firstvararg) \
 | 
	
		
			
				|  |  | +	    __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
 | 
	
		
			
				|  |  | +#define	__strftimelike(fmtarg, firstvararg) \
 | 
	
		
			
				|  |  | +	    __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
 | 
	
		
			
				|  |  | + * the use of non-standard inlining.  In general we should try to avoid
 | 
	
		
			
				|  |  | + * using these but GCC-compatible compilers tend to support the extensions
 | 
	
		
			
				|  |  | + * well enough to use them in limited cases.
 | 
	
		
			
				|  |  | + */ 
 | 
	
		
			
				|  |  | +#if defined(__GNUC_GNU_INLINE__) || defined(__GNUC_STDC_INLINE__)
 | 
	
		
			
				|  |  | +#if __GNUC_PREREQ__(4, 3) || __has_attribute(__artificial__)
 | 
	
		
			
				|  |  | +#define	__gnu_inline	__attribute__((__gnu_inline__, __artificial__))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__gnu_inline	__attribute__((__gnu_inline__))
 | 
	
		
			
				|  |  | +#endif /* artificial */
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__gnu_inline
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
 | 
	
		
			
				|  |  | -#if __FreeBSD_cc_version >= 300001 && defined(__GNUC__) && !defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  | +#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
 | 
	
		
			
				|  |  | +    defined(__GNUC__) && !defined(__INTEL_COMPILER)
 | 
	
		
			
				|  |  |  #define	__printf0like(fmtarg, firstvararg) \
 | 
	
		
			
				|  |  |  	    __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
 | 
	
		
			
				|  |  |  #else
 | 
	
	
		
			
				|  | @@ -398,7 +595,7 @@
 | 
	
		
			
				|  |  |   * The following definition might not work well if used in header files,
 | 
	
		
			
				|  |  |   * but it should be better than nothing.  If you want a "do nothing"
 | 
	
		
			
				|  |  |   * version, then it should generate some harmless declaration, such as:
 | 
	
		
			
				|  |  | - *    #define __IDSTRING(name,string)	struct __hack
 | 
	
		
			
				|  |  | + *    #define	__IDSTRING(name,string)	struct __hack
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  #define	__IDSTRING(name,string)	static const char name[] __unused = string
 | 
	
		
			
				|  |  |  #endif
 | 
	
	
		
			
				|  | @@ -407,7 +604,7 @@
 | 
	
		
			
				|  |  |   * Embed the rcs id of a source file in the resulting library.  Note that in
 | 
	
		
			
				|  |  |   * more recent ELF binutils, we use .ident allowing the ID to be stripped.
 | 
	
		
			
				|  |  |   * Usage:
 | 
	
		
			
				|  |  | - *	__FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $");
 | 
	
		
			
				|  |  | + *	__FBSDID("$FreeBSD$");
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  #ifndef	__FBSDID
 | 
	
		
			
				|  |  |  #if !defined(lint) && !defined(STRIP_FBSDID)
 | 
	
	
		
			
				|  | @@ -450,15 +647,15 @@
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifndef	__DECONST
 | 
	
		
			
				|  |  | -#define	__DECONST(type, var)	((type)(uintptr_t)(const void *)(var))
 | 
	
		
			
				|  |  | +#define	__DECONST(type, var)	((type)(__uintptr_t)(const void *)(var))
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifndef	__DEVOLATILE
 | 
	
		
			
				|  |  | -#define	__DEVOLATILE(type, var)	((type)(uintptr_t)(volatile void *)(var))
 | 
	
		
			
				|  |  | +#define	__DEVOLATILE(type, var)	((type)(__uintptr_t)(volatile void *)(var))
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  #ifndef	__DEQUALIFY
 | 
	
		
			
				|  |  | -#define	__DEQUALIFY(type, var)	((type)(uintptr_t)(const volatile void *)(var))
 | 
	
		
			
				|  |  | +#define	__DEQUALIFY(type, var)	((type)(__uintptr_t)(const volatile void *)(var))
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /*-
 | 
	
	
		
			
				|  | @@ -566,12 +763,96 @@
 | 
	
		
			
				|  |  |  #define	__XSI_VISIBLE		0
 | 
	
		
			
				|  |  |  #define	__BSD_VISIBLE		0
 | 
	
		
			
				|  |  |  #define	__ISO_C_VISIBLE		1999
 | 
	
		
			
				|  |  | +#elif defined(_C11_SOURCE)	/* Localism to specify strict C11 env. */
 | 
	
		
			
				|  |  | +#define	__POSIX_VISIBLE		0
 | 
	
		
			
				|  |  | +#define	__XSI_VISIBLE		0
 | 
	
		
			
				|  |  | +#define	__BSD_VISIBLE		0
 | 
	
		
			
				|  |  | +#define	__ISO_C_VISIBLE		2011
 | 
	
		
			
				|  |  |  #else				/* Default environment: show everything. */
 | 
	
		
			
				|  |  |  #define	__POSIX_VISIBLE		200809
 | 
	
		
			
				|  |  |  #define	__XSI_VISIBLE		700
 | 
	
		
			
				|  |  |  #define	__BSD_VISIBLE		1
 | 
	
		
			
				|  |  | -#define	__ISO_C_VISIBLE		1999
 | 
	
		
			
				|  |  | +#define	__ISO_C_VISIBLE		2011
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if defined(__mips) || defined(__powerpc64__) || defined(__riscv__)
 | 
	
		
			
				|  |  | +#define	__NO_TLS 1
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Type Safety Checking
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Clang provides additional attributes to enable checking type safety
 | 
	
		
			
				|  |  | + * properties that cannot be enforced by the C type system. 
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if __has_attribute(__argument_with_type_tag__) && \
 | 
	
		
			
				|  |  | +    __has_attribute(__type_tag_for_datatype__) && !defined(lint)
 | 
	
		
			
				|  |  | +#define	__arg_type_tag(arg_kind, arg_idx, type_tag_idx) \
 | 
	
		
			
				|  |  | +	    __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx)))
 | 
	
		
			
				|  |  | +#define	__datatype_type_tag(kind, type) \
 | 
	
		
			
				|  |  | +	    __attribute__((__type_tag_for_datatype__(kind, type)))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__arg_type_tag(arg_kind, arg_idx, type_tag_idx)
 | 
	
		
			
				|  |  | +#define	__datatype_type_tag(kind, type)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/*
 | 
	
		
			
				|  |  | + * Lock annotations.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Clang provides support for doing basic thread-safety tests at
 | 
	
		
			
				|  |  | + * compile-time, by marking which locks will/should be held when
 | 
	
		
			
				|  |  | + * entering/leaving a functions.
 | 
	
		
			
				|  |  | + *
 | 
	
		
			
				|  |  | + * Furthermore, it is also possible to annotate variables and structure
 | 
	
		
			
				|  |  | + * members to enforce that they are only accessed when certain locks are
 | 
	
		
			
				|  |  | + * held.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +#if __has_extension(c_thread_safety_attributes)
 | 
	
		
			
				|  |  | +#define	__lock_annotate(x)	__attribute__((x))
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +#define	__lock_annotate(x)
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Structure implements a lock. */
 | 
	
		
			
				|  |  | +#define	__lockable		__lock_annotate(lockable)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Function acquires an exclusive or shared lock. */
 | 
	
		
			
				|  |  | +#define	__locks_exclusive(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(exclusive_lock_function(__VA_ARGS__))
 | 
	
		
			
				|  |  | +#define	__locks_shared(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(shared_lock_function(__VA_ARGS__))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Function attempts to acquire an exclusive or shared lock. */
 | 
	
		
			
				|  |  | +#define	__trylocks_exclusive(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
 | 
	
		
			
				|  |  | +#define	__trylocks_shared(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(shared_trylock_function(__VA_ARGS__))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Function releases a lock. */
 | 
	
		
			
				|  |  | +#define	__unlocks(...)		__lock_annotate(unlock_function(__VA_ARGS__))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Function asserts that an exclusive or shared lock is held. */
 | 
	
		
			
				|  |  | +#define	__asserts_exclusive(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
 | 
	
		
			
				|  |  | +#define	__asserts_shared(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(assert_shared_lock(__VA_ARGS__))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Function requires that an exclusive or shared lock is or is not held. */
 | 
	
		
			
				|  |  | +#define	__requires_exclusive(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(exclusive_locks_required(__VA_ARGS__))
 | 
	
		
			
				|  |  | +#define	__requires_shared(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(shared_locks_required(__VA_ARGS__))
 | 
	
		
			
				|  |  | +#define	__requires_unlocked(...) \
 | 
	
		
			
				|  |  | +	__lock_annotate(locks_excluded(__VA_ARGS__))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Function should not be analyzed. */
 | 
	
		
			
				|  |  | +#define	__no_lock_analysis	__lock_annotate(no_thread_safety_analysis)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* Guard variables and structure members by lock. */
 | 
	
		
			
				|  |  | +#define	__guarded_by(x)		__lock_annotate(guarded_by(x))
 | 
	
		
			
				|  |  | +#define	__pt_guarded_by(x)	__lock_annotate(pt_guarded_by(x))
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  #endif /* !_SYS_CDEFS_H_ */
 |