framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
common_macros.hpp
Go to the documentation of this file.
1 // Copyright (C) 2012 iwg molw5
2 // For conditions of distribution and use, see copyright notice in COPYING
3 
13 #pragma once
14 
21 #define MAX_GNUC_VERSION(major, minor, patchlevel) \
22  defined(__GNUC__) && !defined(__clang__) && \
23  (__GNUC__ < major || (__GNUC__ == major && \
24  (__GNUC_MINOR__ < minor || (__GNUC_MINOR__ == minor && \
25  __GNUC_PATCHLEVEL__ <= patchlevel))))
26 
33 #define MIN_GNUC_VERSION(major, minor, patchlevel) \
34  defined(__GNUC__) && !defined(__clang__) && \
35  (__GNUC__ > major || (__GNUC__ == major && \
36  (__GNUC_MINOR__ > minor || (__GNUC_MINOR__ == minor && \
37  __GNUC_PATCHLEVEL__ >= patchlevel))))
38 
45 #define MAX_CLANG_VERSION(major, minor, patchlevel) \
46  defined(__clang__) && \
47  (__clang__ < major || (__clang__ == major && \
48  (__clang_minor__ < minor || (__clang_minor__ == minor && \
49  __clang_patchlevel__ <= patchlevel))))
50 
57 #define MIN_CLANG_VERSION(major, minor, patchlevel) \
58  defined(__clang__) && \
59  (__clang__ > major || (__clang__ == major && \
60  (__clang_minor__ > minor || (__clang_minor__ == minor && \
61  __clang_patchlevel__ >= patchlevel))))
62 
68 #ifndef FRAMEWORK_DISABLE_EXPECT
69  #if defined(__GNUC__)
70  #define FRAMEWORK_EXPECT_TRUE(...) __builtin_expect(!!(__VA_ARGS__), 1)
71  #define FRAMEWORK_EXPECT_FALSE(...) __builtin_expect(!!(__VA_ARGS__), 0)
72  #else
73  #define FRAMEWORK_EXPECT_TRUE(...) !!(__VA_ARGS__)
74  #define FRAMEWORK_EXPECT_FALSE(...) !!(__VA_ARGS__)
75  #endif
76 #else
77  #define FRAMEWORK_EXPECT_TRUE(...) !!(__VA_ARGS__)
78  #define FRAMEWORK_EXPECT_FALSE(...) !!(__VA_ARGS__)
79 #endif
80 
86 #ifndef FRAMEWORK_DISABLE_ALWAYS_INLINE
87  #if defined(__GNUC__)
88  #define FRAMEWORK_ALWAYS_INLINE __attribute__ ((always_inline)) inline
89  #elif defined(_MSC_VER)
90  #define FRAMEWORK_ALWAYS_INLINE __inline
91  #else
92  #define FRAMEWORK_ALWAYS_INLINE inline
93  #endif
94 #else
95  #define FRAMEWORK_ALWAYS_INLINE
96 #endif