From 0c0ea60b777f64fed7a44c1bf135266af867afa2 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 21 Feb 2016 01:00:46 +0100 Subject: Linux & MacOSX: better implementation for TC_THROW_FATAL_EXCEPTION to use __builtin_trap when available. --- src/Common/Tcdefs.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Common') diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h index 4aef2949..02744401 100644 --- a/src/Common/Tcdefs.h +++ b/src/Common/Tcdefs.h @@ -119,6 +119,10 @@ typedef union } UINT64_STRUCT; +#ifndef __has_builtin // Optional of course +#define __has_builtin(x) 0 // Compatibility with non-clang compilers +#endif + #ifdef TC_WINDOWS_BOOT # ifdef __cplusplus @@ -129,6 +133,10 @@ void ThrowFatalException (int line); # define TC_THROW_FATAL_EXCEPTION ThrowFatalException (__LINE__) #elif defined (TC_WINDOWS_DRIVER) # define TC_THROW_FATAL_EXCEPTION KeBugCheckEx (SECURITY_SYSTEM, __LINE__, 0, 0, 'VC') +#elif (defined(__clang__) && __has_builtin(__builtin_trap)) \ + || (defined(__GNUC__ ) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))) \ + || (__has_builtin(__builtin_trap)) +# define TC_THROW_FATAL_EXCEPTION __builtin_trap() #else # define TC_THROW_FATAL_EXCEPTION *(char *) 0 = 0 #endif -- cgit v1.2.3