Go to the documentation of this file.
19 #ifndef viskores_Unreachable_h
20 #define viskores_Unreachable_h
39 #define VISKORES_UNREACHABLE(msg) \
40 VISKORES_SWALLOW_SEMICOLON_PRE_BLOCK \
42 VISKORES_UNREACHABLE_IMPL(); \
43 VISKORES_UNREACHABLE_PRINT(msg); \
44 VISKORES_UNREACHABLE_ABORT(); \
46 VISKORES_SWALLOW_SEMICOLON_POST_BLOCK
49 #if defined(VISKORES_CUDA_DEVICE_PASS)
51 #define VISKORES_UNREACHABLE_IMPL() (void)0
53 #if defined(NDEBUG) || defined(VISKORES_NO_ASSERT)
55 #define VISKORES_UNREACHABLE_PRINT(msg) (void)0
56 #define VISKORES_UNREACHABLE_ABORT() (void)0
58 #else // NDEBUG || VISKORES_NO_ASSERT
60 #define VISKORES_UNREACHABLE_PRINT(msg) \
61 printf("Unreachable location reached: %s\nLocation: %s:%d\n", msg, __FILE__, __LINE__)
62 #define VISKORES_UNREACHABLE_ABORT() \
65 #endif // NDEBUG || VISKORES_NO_ASSERT
70 #if defined(NDEBUG) || defined(VISKORES_NO_ASSERT)
72 #define VISKORES_UNREACHABLE_PRINT(msg) (void)0
73 #define VISKORES_UNREACHABLE_ABORT() (void)0
75 #if defined(VISKORES_MSVC)
76 #define VISKORES_UNREACHABLE_IMPL() __assume(false)
77 #elif defined(VISKORES_ICC) && !defined(__GNUC__)
78 #define VISKORES_UNREACHABLE_IMPL() __assume(false)
79 #elif (defined(VISKORES_GCC) || defined(VISKORES_ICC)) && \
80 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
82 #define VISKORES_UNREACHABLE_IMPL() __builtin_unreachable()
83 #elif defined(VISKORES_CLANG)
84 #define VISKORES_UNREACHABLE_IMPL() __builtin_unreachable()
86 #define VISKORES_UNREACHABLE_IMPL() (void)0
89 #else // NDEBUG || VISKORES_NO_ASSERT
91 #define VISKORES_UNREACHABLE_IMPL() (void)0
92 #define VISKORES_UNREACHABLE_PRINT(msg) \
93 std::cerr << "Unreachable location reached: " << msg << "\n" \
94 << "Location: " << __FILE__ << ":" << __LINE__ << "\n"
95 #define VISKORES_UNREACHABLE_ABORT() abort()
97 #endif // NDEBUG && !VISKORES_NO_ASSERT
101 #endif //viskores_Unreachable_h