mirror of https://github.com/CGAL/cgal
separate macros and macro function
This commit is contained in:
parent
604d2fd1ff
commit
85c00352c3
|
|
@ -369,17 +369,17 @@ using std::max;
|
||||||
# define CGAL_NO_UNIQUE_ADDRESS
|
# define CGAL_NO_UNIQUE_ADDRESS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Macro CGAL_ASSUME and CGAL_unreachable
|
// Macro CGAL_ASSUME and CGAL_UNREACHABLE
|
||||||
// Call a builtin of the compiler to pass a hint to the compiler
|
// Call a builtin of the compiler to pass a hint to the compiler
|
||||||
#if __has_builtin(__builtin_unreachable) || (CGAL_GCC_VERSION > 0 && !__STRICT_ANSI__)
|
#if __has_builtin(__builtin_unreachable) || (CGAL_GCC_VERSION > 0 && !__STRICT_ANSI__)
|
||||||
// From g++ 4.5, there exists a __builtin_unreachable()
|
// From g++ 4.5, there exists a __builtin_unreachable()
|
||||||
// Also in LLVM/clang
|
// Also in LLVM/clang
|
||||||
# define CGAL_ASSUME(EX) if(!(EX)) { __builtin_unreachable(); }
|
# define CGAL_ASSUME(EX) if(!(EX)) { __builtin_unreachable(); }
|
||||||
# define CGAL_unreachable() __builtin_unreachable()
|
# define CGAL_UNREACHABLE() __builtin_unreachable()
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
// MSVC has __assume
|
// MSVC has __assume
|
||||||
# define CGAL_ASSUME(EX) __assume(EX)
|
# define CGAL_ASSUME(EX) __assume(EX)
|
||||||
# define CGAL_unreachable() __assume(0)
|
# define CGAL_UNREACHABLE() __assume(0)
|
||||||
#endif
|
#endif
|
||||||
// If CGAL_ASSUME is not defined, then CGAL_assume and CGAL_assume_code are
|
// If CGAL_ASSUME is not defined, then CGAL_assume and CGAL_assume_code are
|
||||||
// defined differently, in <CGAL/assertions.h>
|
// defined differently, in <CGAL/assertions.h>
|
||||||
|
|
|
||||||
|
|
@ -79,14 +79,6 @@ inline bool possibly(Uncertain<bool> c);
|
||||||
# define CGAL_destructor_assertion_catch(CODE) CODE
|
# define CGAL_destructor_assertion_catch(CODE) CODE
|
||||||
# define CGAL_assertion_msg(EX,MSG) (static_cast<void>(0))
|
# define CGAL_assertion_msg(EX,MSG) (static_cast<void>(0))
|
||||||
# define CGAL_assertion_code(CODE)
|
# define CGAL_assertion_code(CODE)
|
||||||
# ifdef CGAL_ASSUME
|
|
||||||
# define CGAL_assume(EX) CGAL_ASSUME(EX)
|
|
||||||
# define CGAL_assume_code(CODE) CODE
|
|
||||||
# else // not def CGAL_ASSUME
|
|
||||||
# define CGAL_assume(EX) CGAL_assertion(EX)
|
|
||||||
# define CGAL_unreachable() CGAL_assertion(false)
|
|
||||||
# define CGAL_assume_code(CODE) CGAL_assertion_code(CODE)
|
|
||||||
# endif // not def CGAL_ASSUME
|
|
||||||
#else // no CGAL_NO_ASSERTIONS
|
#else // no CGAL_NO_ASSERTIONS
|
||||||
# define CGAL_ASSERTIONS_ENABLED true
|
# define CGAL_ASSERTIONS_ENABLED true
|
||||||
# define CGAL_assertion(EX) \
|
# define CGAL_assertion(EX) \
|
||||||
|
|
@ -103,9 +95,21 @@ inline bool possibly(Uncertain<bool> c);
|
||||||
# define CGAL_assertion_msg(EX,MSG) \
|
# define CGAL_assertion_msg(EX,MSG) \
|
||||||
(CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
|
(CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
|
||||||
# define CGAL_assertion_code(CODE) CODE
|
# define CGAL_assertion_code(CODE) CODE
|
||||||
|
#endif // no CGAL_NO_ASSERTIONS
|
||||||
|
|
||||||
|
# ifdef CGAL_ASSUME
|
||||||
|
# define CGAL_assume(EX) CGAL_ASSUME(EX)
|
||||||
|
# define CGAL_assume_code(CODE) CODE
|
||||||
|
# else // not def CGAL_ASSUME
|
||||||
# define CGAL_assume(EX) CGAL_assertion(EX)
|
# define CGAL_assume(EX) CGAL_assertion(EX)
|
||||||
# define CGAL_assume_code(CODE) CGAL_assertion_code(CODE)
|
# define CGAL_assume_code(CODE) CGAL_assertion_code(CODE)
|
||||||
#endif // no CGAL_NO_ASSERTIONS
|
# endif // CGAL_ASSUME
|
||||||
|
|
||||||
|
# ifdef CGAL_UNREACHABLE
|
||||||
|
# define CGAL_unreachable() CGAL_UNREACHABLE()
|
||||||
|
# else // not def CGAL_UNREACHABLE
|
||||||
|
# define CGAL_unreachable() CGAL_assertion(false)
|
||||||
|
# endif // CGAL_UNREACHABLE
|
||||||
|
|
||||||
# define CGAL_static_assertion(EX) \
|
# define CGAL_static_assertion(EX) \
|
||||||
static_assert(EX, #EX)
|
static_assert(EX, #EX)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue