HawkTracer  0.8.0
macros.h
Go to the documentation of this file.
1 #ifndef HAWKTRACER_MACROS_H
2 #define HAWKTRACER_MACROS_H
3 
4 #include <hawktracer/ht_config.h>
5 
7 #define HT_UNUSED(x) (void)(x)
8 
15 #ifdef __cplusplus
16 # define HT_DECLS_BEGIN extern "C" {
17 # define HT_DECLS_END }
18 #else
19 # define HT_DECLS_BEGIN
20 # define HT_DECLS_END
21 #endif
22 
23 #if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
24 # define HT_CPP11
25 #endif
26 
39 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
40 # define HT_LIKELY(expression) (__builtin_expect ((expression), 1))
41 # define HT_UNLIKELY(expression) (__builtin_expect ((expression), 0))
42 #else
43 # define HT_LIKELY(expr) (expr)
44 # define HT_UNLIKELY(expr) (expr)
45 #endif
46 
50 #ifndef __cplusplus
51 # if defined (_MSC_VER) && (_MSC_VER < 1900)
52 # define HT_INLINE __inline
53 # elif !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199900)
54 # define HT_INLINE __inline
55 # else
56 # define HT_INLINE inline
57 # endif
58 #else
59 # define HT_INLINE inline
60 #endif
61 
62 #ifdef _WIN32
63 # define HT_PLATFORM_WIN32
64 #endif
65 
69 #if defined(HT_PLATFORM_WIN32) && !defined(HT_COMPILE_STATIC)
70 # if defined(HT_COMPILE_SHARED_EXPORT)
71 # define HT_API __declspec(dllexport)
72 # else
73 # define HT_API __declspec(dllimport)
74 # endif
75 #else
76 # define HT_API
77 #endif
78 
79 #define HT_MACRO_CONCAT_(x, y) x ## y
80 
82 #define HT_MACRO_CONCAT(x, y) HT_MACRO_CONCAT_(x, y)
83 
85 #define HT_UNIQUE_VAR_NAME(BASE_VAR_NAME) HT_MACRO_CONCAT(BASE_VAR_NAME, __LINE__)
86 
91 #ifdef HT_CPP11
92 # define HT_THREAD_LOCAL thread_local
93 #elif __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
94 # define HT_THREAD_LOCAL _Thread_local
95 #elif defined _WIN32 && ( defined _MSC_VER || defined __ICL || defined __DMC__ || defined __BORLANDC__ )
96 # define HT_THREAD_LOCAL __declspec(thread)
97 #elif defined __GNUC__ || defined __SUNPRO_C || defined __xlC__ /* ICC (linux) and Clang are covered by __GNUC__ */
98 # define HT_THREAD_LOCAL __thread
99 #endif
100 
101 #if defined(HT_HAVE_UNISTD_H) || (defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)))
102 # define HT_HAVE_UNISTD_H
103 #endif
104 
105 #endif /* HAWKTRACER_MACROS_H */