summaryrefslogtreecommitdiffhomepage
path: root/compat/macros.hpp
blob: b0c7a51de8038dec2e769f867ba92fa838cd5a98 (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
#pragma once

#if defined _MSC_VER
#   define MEMORY_BARRIER() _ReadWriteBarrier()
#else
#   define MEMORY_BARRIER() asm volatile("" ::: "memory")
#endif

#if defined _MSC_VER
#   define never_inline __declspec(noinline)
#elif defined __GNUG__
#   define never_inline __attribute__((noinline))
#else
#   define never_inline
#endif

#if defined __cplusplus
#   define restrict_ptr __restrict
#endif

#if defined _MSC_VER
#   define force_inline __forceinline
#else
#   define force_inline __attribute__((always_inline, gnu_inline)) inline
#endif

#ifdef Q_CREATOR_RUN
#   define warn_result_unused
#elif defined _MSC_VER
#   define warn_result_unused _Check_return_
#else
#   define warn_result_unused __attribute__((warn_unused_result))
#endif

#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

#if defined _MSC_VER
#   define OTR_FUNNAME (__FUNCSIG__)
#else
#   define OTR_FUNNAME (__PRETTY_FUNCTION__)
#endif

#if defined __cplusplus
#   define thunk(...) ([&]() { __VA_ARGS__; })
#endif