Provide a portability macro for __builtin_trap.
authorDavid Blaikie <dblaikie@gmail.com>
Tue, 21 Aug 2012 18:54:21 +0000 (18:54 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Tue, 21 Aug 2012 18:54:21 +0000 (18:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162300 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Compiler.h

index 4469ae31de09601be9ea6e15844b292acda6f9ca..ea0a4da27f155597dda80add94797fa9963b65b4 100644 (file)
 # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
 #endif
 
+// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression
+// which causes the program to exit abnormally.
+#if defined(__clang__) || (__GNUC__ > 4) \
+ || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+# define LLVM_BUILTIN_TRAP __builtin_trap()
+#else
+# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
+#endif
+
 #endif