summaryrefslogtreecommitdiffhomepage
path: root/compat/macros1.h
blob: 148e1a77239f8ce32ba1c80f51b33a3618b521ee (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once

#if defined _MSC_VER
#   define cc_noinline __declspec(noinline)
#else
#   define cc_noinline __attribute__((noinline))
#endif

#if defined _MSC_VER
#   define cc_forceinline __forceinline
#else
#   define cc_forceinline __attribute__((always_inline))
#endif

#if !defined likely
#   if defined __GNUC__
#      define likely(x)       __builtin_expect(!!(x),1)
#      define unlikely(x)     __builtin_expect(!!(x),0)
#   else
#      define likely(x) (x)
#      define unlikely(x) (x)
#   endif
#endif

#if defined _MSC_VER
#   define cc_function_name __FUNCSIG__
#else
#   define cc_function_name __PRETTY_FUNCTION__
#endif

#if !defined PP_CAT
#   define PP_CAT(x,y) PP_CAT1(x,y)
#   define PP_CAT1(x,y) PP_CAT2(x,y)
#   define PP_CAT2(x,y) x ## y
#endif

#ifndef PP_EXPAND
#   define PP_EXPAND(x) PP_EXPAND2(x)
#   define PP_EXPAND2(x) PP_EXPAND3(x) x
#   define PP_EXPAND3(x) x
#endif

#ifdef _MSC_VER
//#   include <windows.h>
//#   define FULL_BARRIER MemoryBarrier()
#   define COMPILER_BARRIER() _ReadWriteBarrier()
#else
//#   define FULL_BARRIER() __sync_synchronize()
#   define COMPILER_BARRIER() asm volatile("" ::: "memory")
#endif

#ifdef _MSC_VER
#   define unreachable() __assume(0)
#else
#   define unreachable() __builtin_unreachable()
#endif