VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Tcdefs.h
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-02-21 01:00:46 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-02-21 10:59:16 +0100
commit0c0ea60b777f64fed7a44c1bf135266af867afa2 (patch)
treeb4141283e73782488dee96d84a2f553074db1533 /src/Common/Tcdefs.h
parent87df2fd2fc5845a39c715217029646d385ee3e01 (diff)
downloadVeraCrypt-0c0ea60b777f64fed7a44c1bf135266af867afa2.tar.gz
VeraCrypt-0c0ea60b777f64fed7a44c1bf135266af867afa2.zip
Linux & MacOSX: better implementation for TC_THROW_FATAL_EXCEPTION to use __builtin_trap when available.
Diffstat (limited to 'src/Common/Tcdefs.h')
-rw-r--r--src/Common/Tcdefs.h8
1 files changed, 8 insertions, 0 deletions
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