#ifndef UCS_COMPILER_DEF_H
#define UCS_COMPILER_DEF_H
#ifdef __cplusplus
# define BEGIN_C_DECLS extern "C" {
# define END_C_DECLS }
#else
# define BEGIN_C_DECLS
# define END_C_DECLS
#endif
#define UCS_STATIC_ASSERT(_cond) \
switch(0) {case 0:case (_cond):;}
#define UCS_ALLOCA_MAX_SIZE 1200
#define UCS_S_MAY_ALIAS __attribute__((may_alias))
#define UCS_F_PURE __attribute__((pure))
#define UCS_F_NORETURN __attribute__((noreturn))
#define UCS_S_PACKED __attribute__((packed))
#define UCS_F_NOINLINE __attribute__ ((noinline))
#define UCS_F_CTOR __attribute__((constructor))
#define UCS_F_DTOR __attribute__((destructor))
#define UCS_F_MAYBE_UNUSED __attribute__((used))
#define UCS_F_NON_NULL __attribute__((nonnull))
#ifdef __GNUC__
#define UCS_F_ALWAYS_INLINE inline __attribute__ ((always_inline))
#else
#define UCS_F_ALWAYS_INLINE inline
#endif
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ == 1)) || !defined(__OPTIMIZE__))
# define UCS_V_INITIALIZED(_v) (_v = (ucs_typeof(_v))0)
#else
# define UCS_V_INITIALIZED(_v) ((void)0)
#endif
#define UCS_BIT(i) (1ul << (i))
#define UCS_MASK(i) (UCS_BIT(i) - 1)
#define UCS_F_PRINTF(fmtargN, vargN) __attribute__((format(printf, fmtargN, vargN)))
#define UCS_V_UNUSED __attribute__((unused))
#define UCS_V_ALIGNED(_align) __attribute__((aligned(_align)))
#define UCS_EMPTY_STATEMENT {}
#define UCS_PTR_BYTE_OFFSET(_ptr, _offset) \
((void *)((intptr_t)(_ptr) + (intptr_t)(_offset)))
#define UCS_PTR_TYPE_OFFSET(_ptr, _type) \
((void *)((ucs_typeof(_type) *)(_ptr) + 1))
#define UCS_PTR_BYTE_DIFF(_start, _end) \
((ptrdiff_t)((uintptr_t)(_end) - (uintptr_t)(_start)))
#define ucs_static_array_size(_array) \
(sizeof(_array) / sizeof((_array)[0]))
#define ucs_offsetof(_type, _member) \
((unsigned long)&( ((_type*)0)->_member ))
#define ucs_container_of(_ptr, _type, _member) \
( (_type*)( (char*)(void*)(_ptr) - ucs_offsetof(_type, _member) ) )
#define ucs_typeof(_type) \
__typeof__(_type)
#define ucs_derived_of(_ptr, _type) \
({\
UCS_STATIC_ASSERT(offsetof(_type, super) == 0) \
ucs_container_of(_ptr, _type, super); \
})
#define ucs_field_sizeof(_type, _field) \
sizeof(((_type*)0)->_field)
#define ucs_field_type(_type, _field) \
ucs_typeof(((_type*)0)->_field)
#define ucs_compiler_fence() asm volatile(""::: "memory")
#define ucs_prefetch(p) __builtin_prefetch(p)
#define ucs_likely(x) __builtin_expect(x, 1)
#define ucs_unlikely(x) __builtin_expect(x, 0)
#define ucs_is_constant(expr) __builtin_constant_p(expr)
#define UCS_STATIC_INIT \
static void UCS_F_CTOR UCS_PP_APPEND_UNIQUE_ID(ucs_initializer_ctor)()
#define UCS_STATIC_CLEANUP \
static void UCS_F_DTOR UCS_PP_APPEND_UNIQUE_ID(ucs_initializer_dtor)()
#define ucs_same_type(_type1, _type2) \
__builtin_types_compatible_p(_type1, _type2)
#endif