#ifndef _SYS_CDEFS_H_
#define _SYS_CDEFS_H_
#if defined(_KERNEL) && defined(_STANDALONE)
#error "_KERNEL and _STANDALONE are mutually exclusive"
#endif
#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 }
#else
#define __BEGIN_DECLS
#define __END_DECLS
#endif
#if defined(__GNUC__)
#define __GNUC_PREREQ__(ma, mi) \
(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
#else
#define __GNUC_PREREQ__(ma, mi) 0
#endif
#if defined(__GNUC__)
#define __compiler_membar() __asm __volatile(" " : : : "memory")
#define __CC_SUPPORTS___INLINE 1
#define __CC_SUPPORTS_SYMVER 1
#endif
#ifdef __TINYC__
#undef __CC_SUPPORTS_SYMVER
#endif
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos
#define __CONCAT1(x,y) x ## y
#define __CONCAT(x,y) __CONCAT1(x,y)
#define __STRING(x) #x
#define __XSTRING(x) __STRING(x)
#define __volatile volatile
#if defined(__cplusplus)
#define __inline inline
#else
#if !(defined(__CC_SUPPORTS___INLINE))
#define __inline
#endif
#endif
#else
#define __P(protos) ()
#define __CONCAT(x,y) xy
#define __STRING(x) "x"
#if !defined(__CC_SUPPORTS___INLINE)
#define __inline
#define __volatile
#endif
#endif
#define __weak_symbol __attribute__((__weak__))
#define __dead2 __attribute__((__noreturn__))
#define __pure2 __attribute__((__const__))
#define __unused __attribute__((__unused__))
#define __used __attribute__((__used__))
#define __deprecated __attribute__((__deprecated__))
#define __deprecated1(msg) __attribute__((__deprecated__(msg)))
#define __packed __attribute__((__packed__))
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#define __writeonly __unused
#define __alloc_size(x) __attribute__((__alloc_size__(x)))
#define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x)))
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
#if !__has_extension(c_alignas)
#if (defined(__cplusplus) && __cplusplus >= 201103L) || \
__has_extension(cxx_alignas)
#define _Alignas(x) alignas(x)
#else
#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 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)
#endif
#endif
#if !__has_extension(c_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
#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 !defined(__cplusplus)
#define __generic(expr, t, yes, no) \
__builtin_choose_expr(__builtin_types_compatible_p( \
__typeof(((void)0, (expr))), t), yes, no)
#endif
#if !defined(__cplusplus) && \
(!defined(__STDC_VERSION__) || (__STDC_VERSION__ >= 199901))
#define __min_size(x) static (x)
#else
#define __min_size(x) (x)
#endif
#define __malloc_like __attribute__((__malloc__))
#define __pure __attribute__((__pure__))
#define __always_inline __inline __attribute__((__always_inline__))
#define __noinline __attribute__ ((__noinline__))
#define __fastcall __attribute__((__fastcall__))
#define __result_use_check __attribute__((__warn_unused_result__))
#define __returns_twice __attribute__((__returns_twice__))
#define __unreachable() __builtin_unreachable()
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
#define __LONG_LONG_SUPPORTED
#endif
#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
#if defined(__cplusplus) && __cplusplus >= 201103L
#define __noexcept noexcept
#define __noexcept_if(__c) noexcept(__c)
#else
#define __noexcept
#define __noexcept_if(__c)
#endif
#if defined(__cplusplus) && defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard)
#define __nodiscard [[nodiscard]]
#endif
#elif defined(__STDC_VERSION__) && defined(__has_c_attribute)
#if __has_c_attribute(__nodiscard__)
#define __nodiscard [[__nodiscard__]]
#endif
#endif
#ifndef __nodiscard
#ifdef __clang__
#define __nodiscard __attribute__((__warn_unused_result__))
#else
#define __nodiscard
#endif
#endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901
#define __restrict restrict
#endif
#define __predict_true(exp) __builtin_expect((exp), 1)
#define __predict_false(exp) __builtin_expect((exp), 0)
#define __null_sentinel __attribute__((__sentinel__))
#define __exported __attribute__((__visibility__("default")))
#define __hidden __attribute__((__visibility__("hidden")))
#define __offsetof(type, field) __builtin_offsetof(type, field)
#define __rangeof(type, start, end) \
(__offsetof(type, end) - __offsetof(type, start))
#define __containerof(x, s, m) ({ \
const volatile __typeof(((s *)0)->m) *__x = (x); \
__DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\
})
#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)))
#if defined(__clang__) || (defined(__GNUC__) && defined (__FreeBSD_cc_version))
#define __printf0like(fmtarg, firstvararg) \
__attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
#else
#define __printf0like(fmtarg, firstvararg)
#endif
#if __has_attribute(__nonstring__)
#define __nonstring __attribute__((__nonstring__))
#else
#define __nonstring
#endif
#define __strong_reference(sym,aliassym) \
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
#ifdef __STDC__
#define __weak_reference(sym,alias) \
__asm__(".weak " #alias); \
__asm__(".equ " #alias ", " #sym)
#define __warn_references(sym,msg) \
__asm__(".section .gnu.warning." #sym); \
__asm__(".asciz \"" msg "\""); \
__asm__(".previous")
#ifdef __CC_SUPPORTS_SYMVER
#define __sym_compat(sym,impl,verid) \
__asm__(".symver " #impl ", " #sym "@" #verid)
#define __sym_default(sym,impl,verid) \
__asm__(".symver " #impl ", " #sym "@@@" #verid)
#endif
#else
#define __weak_reference(sym,alias) \
__asm__(".weak alias"); \
__asm__(".equ alias, sym")
#define __warn_references(sym,msg) \
__asm__(".section .gnu.warning.sym"); \
__asm__(".asciz \"msg\""); \
__asm__(".previous")
#ifdef __CC_SUPPORTS_SYMVER
#define __sym_compat(sym,impl,verid) \
__asm__(".symver impl, sym@verid")
#define __sym_default(impl,sym,verid) \
__asm__(".symver impl, sym@@@verid")
#endif
#endif
#define __GLOBL(sym) __asm__(".globl " __XSTRING(sym))
#define __WEAK(sym) __asm__(".weak " __XSTRING(sym))
#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
#ifndef __FBSDID
#if !defined(STRIP_FBSDID)
#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
#else
#define __FBSDID(s) struct __hack
#endif
#endif
#ifndef __RCSID
#ifndef NO__RCSID
#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
#else
#define __RCSID(s) struct __hack
#endif
#endif
#ifndef __RCSID_SOURCE
#ifndef NO__RCSID_SOURCE
#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
#else
#define __RCSID_SOURCE(s) struct __hack
#endif
#endif
#ifndef __SCCSID
#ifndef NO__SCCSID
#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
#else
#define __SCCSID(s) struct __hack
#endif
#endif
#ifndef __COPYRIGHT
#ifndef NO__COPYRIGHT
#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
#else
#define __COPYRIGHT(s) struct __hack
#endif
#endif
#ifndef __DECONST
#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var))
#endif
#ifndef __DEVOLATILE
#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var))
#endif
#ifndef __DEQUALIFY
#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var))
#endif
#if !defined(_STANDALONE) && !defined(_KERNEL)
#define __RENAME(x) __asm(__STRING(x))
#else
#define __RENAME(x) no renaming in kernel/standalone environment
#endif
#include <sys/_visible.h>
#if !(defined(__clang__) && __has_feature(nullability))
#define _Nonnull
#define _Nullable
#define _Null_unspecified
#define __NULLABILITY_PRAGMA_PUSH
#define __NULLABILITY_PRAGMA_POP
#else
#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop")
#endif
#if __has_attribute(__argument_with_type_tag__) && \
__has_attribute(__type_tag_for_datatype__)
#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
#if __has_extension(c_thread_safety_attributes)
#define __lock_annotate(x) __attribute__((x))
#else
#define __lock_annotate(x)
#endif
#define __lockable __lock_annotate(lockable)
#define __locks_exclusive(...) \
__lock_annotate(exclusive_lock_function(__VA_ARGS__))
#define __locks_shared(...) \
__lock_annotate(shared_lock_function(__VA_ARGS__))
#define __trylocks_exclusive(...) \
__lock_annotate(exclusive_trylock_function(__VA_ARGS__))
#define __trylocks_shared(...) \
__lock_annotate(shared_trylock_function(__VA_ARGS__))
#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
#define __asserts_exclusive(...) \
__lock_annotate(assert_exclusive_lock(__VA_ARGS__))
#define __asserts_shared(...) \
__lock_annotate(assert_shared_lock(__VA_ARGS__))
#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__))
#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
#if __has_feature(address_sanitizer) && defined(__clang__)
#ifdef _KERNEL
#define __nosanitizeaddress __attribute__((no_sanitize("kernel-address")))
#else
#define __nosanitizeaddress __attribute__((no_sanitize("address")))
#endif
#else
#define __nosanitizeaddress
#endif
#if __has_feature(coverage_sanitizer) && defined(__clang__)
#define __nosanitizecoverage __attribute__((no_sanitize("coverage")))
#else
#define __nosanitizecoverage
#endif
#if __has_feature(memory_sanitizer) && defined(__clang__)
#ifdef _KERNEL
#define __nosanitizememory __attribute__((no_sanitize("kernel-memory")))
#else
#define __nosanitizememory __attribute__((no_sanitize("memory")))
#endif
#else
#define __nosanitizememory
#endif
#if __has_feature(thread_sanitizer) && defined(__clang__)
#define __nosanitizethread __attribute__((no_sanitize("thread")))
#else
#define __nosanitizethread
#endif
#if __has_attribute(no_stack_protector)
#define __nostackprotector __attribute__((no_stack_protector))
#else
#define __nostackprotector \
__attribute__((__optimize__("-fno-stack-protector")))
#endif
#define __guarded_by(x) __lock_annotate(guarded_by(x))
#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
#if !__has_builtin(__builtin_is_aligned)
#define __builtin_is_aligned(x, align) \
(((__uintptr_t)(x) & ((align) - 1)) == 0)
#endif
#if !__has_builtin(__builtin_align_up)
#define __builtin_align_up(x, align) \
((__typeof__(x))(((__uintptr_t)(x)+((align)-1))&(~((align)-1))))
#endif
#if !__has_builtin(__builtin_align_down)
#define __builtin_align_down(x, align) \
((__typeof__(x))((__uintptr_t)(x)&(~((align)-1))))
#endif
#define __align_up(x, y) __builtin_align_up(x, y)
#define __align_down(x, y) __builtin_align_down(x, y)
#define __is_aligned(x, y) __builtin_is_aligned(x, y)
#endif