-
Notifications
You must be signed in to change notification settings - Fork 26
/
macros.h
36 lines (24 loc) · 964 Bytes
/
macros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#define USE_VARINT_ENCODING
#define LG_CACHELINE_SIZE __builtin_ctz(CACHELINE_SIZE)
// some helpers for cacheline alignment
#define CACHE_ALIGNED __attribute__((aligned(CACHELINE_SIZE)))
#define __XCONCAT2(a, b) a ## b
#define __XCONCAT(a, b) __XCONCAT2(a, b)
#define CACHE_PADOUT \
char __XCONCAT(__padout, __COUNTER__)[0] __attribute__((aligned(CACHELINE_SIZE)))
#define PACKED __attribute__((packed))
#ifndef ALWAYS_INLINE
#define ALWAYS_INLINE __attribute__((always_inline)) inline
#endif
#ifndef ALWAYS_ASSERT
#define ALWAYS_ASSERT(expr) (likely((expr)) ? (void)0 : abort())
#endif
#define MARK_REFERENCED(x) (void)x
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define COMPILER_MEMORY_FENCE asm volatile("" ::: "memory")
#define ARRAY_NELEMS(a) (sizeof(a)/sizeof((a)[0]))
#define VERBOSE(expr) ((void)0)
//#define VERBOSE(expr) (expr)
#define NOP_PAUSE asm volatile("pause" : :)