#ifndef UCS_COMPILER_H_
#define UCS_COMPILER_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "preprocessor.h"
#include "compiler_def.h"
#include <ucs/debug/assert.h>
#include <stddef.h>
#include <stdarg.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifndef ULLONG_MAX
#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1)
#endif
#ifdef __ICC
# pragma warning(disable: 268)
#endif
#if defined(HAVE_ATTRIBUTE_NOOPTIMIZE) && (HAVE_ATTRIBUTE_NOOPTIMIZE == 1)
#define UCS_F_NOOPTIMIZE __attribute__((optimize("O0")))
#else
#define UCS_F_NOOPTIMIZE
#endif
#define UCS_WORD_COPY(_dst_type, _dst, _src_type, _src, _size) \
{ \
unsigned _i; \
UCS_STATIC_ASSERT(sizeof(_src_type) == sizeof(_dst_type)); \
for (_i = 0; _i < (_size) / sizeof(_src_type); ++_i) { \
*((_dst_type*)(_dst) + _i) = *((_src_type*)(_src) + _i); \
} \
}
#define ucs_alloca(_size) \
({ \
ucs_assertv((_size) <= UCS_ALLOCA_MAX_SIZE, "alloca(%zu)", (size_t)(_size)); \
alloca(_size); \
})
#define ucs_unaligned_ptr(_ptr) ({void *_p = (void*)(_ptr); _p;})
#define UCS_CACHELINE_PADDING(...) \
char UCS_PP_APPEND_UNIQUE_ID(pad)[UCS_SYS_CACHE_LINE_SIZE - \
UCS_CACHELINE_PADDING_MISALIGN(__VA_ARGS__)]
#define UCS_CACHELINE_PADDING_SIZEOF(_, _x) \
+ sizeof(_x)
#define UCS_CACHELINE_PADDING_MISALIGN(...) \
((UCS_PP_FOREACH(UCS_CACHELINE_PADDING_SIZEOF, _, __VA_ARGS__)) % UCS_SYS_CACHE_LINE_SIZE)
#endif