aboutsummaryrefslogtreecommitdiff
path: root/src/langext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/langext.h')
-rw-r--r--src/langext.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/langext.h b/src/langext.h
index d2d9a23..0624b71 100644
--- a/src/langext.h
+++ b/src/langext.h
@@ -17,6 +17,7 @@
#define unreachable __builtin_unreachable()
#define assume(x) ((void)(!!(x) || (unreachable, 0)))
#define cold __attribute((__cold__, __noinline__))
+#define asm_only __attribute((__naked__)) // N.B.: may not actually work in GCC?
#else
#define if_hot(x) if (x)
#define if_cold(x) if (x)
@@ -25,11 +26,13 @@
#define unreachable __assume(0)
#define assume(x) ((void)(__assume(x), 0))
#define cold __declspec(noinline)
+#define asm_only __declspec(naked)
#else
static inline _Noreturn void _invoke_ub() {}
#define unreachable (_invoke_ub())
#define assume(x) ((void)(!!(x) || (_invoke_ub(), 0)))
#define cold
+//#define asm_only // Can't use this without Clang/GCC/MSVC. Too bad.
#endif
#endif
@@ -63,6 +66,17 @@ static inline _Noreturn void _invoke_ub() {}
#endif
#endif
+#ifdef __clang__
+#define tailcall \
+ /* Clang forces us to use void return and THEN warns about it ._. */ \
+ _Pragma("clang diagnostic push") \
+ _Pragma("clang diagnostic ignored \"-Wpedantic\"") \
+ __attribute((musttail)) return \
+ _Pragma("clang diagnostic pop")
+#else
+//#define tailcall // Can't use this without Clang.
+#endif
+
#endif
// vi: sw=4 ts=4 noet tw=80 cc=80