aboutsummaryrefslogtreecommitdiff
path: root/src/langext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/langext.h')
-rw-r--r--src/langext.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/langext.h b/src/langext.h
index de96ef5..0624b71 100644
--- a/src/langext.h
+++ b/src/langext.h
@@ -16,7 +16,8 @@
#define if_random(x) if (__builtin_expect_with_probability(!!(x), 1, 0.5))
#define unreachable __builtin_unreachable()
#define assume(x) ((void)(!!(x) || (unreachable, 0)))
-#define cold __attribute__((__cold__, __noinline__))
+#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
@@ -57,12 +60,23 @@ static inline _Noreturn void _invoke_ub() {}
#define import
#ifdef __GNUC__
// N.B. we assume -fvisibility=hidden
-#define export __attribute__((visibility("default"))
+#define export __attribute((visibility("default"))
#else
#define export int exp[-!!"compiler needs a way to export symbols!"];
#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