summaryrefslogtreecommitdiff
path: root/src/codegen/compat.h
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-29 03:03:56 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-29 03:03:56 +0000
commitda9e8758e9d89dc7362be67f8e7573309efe170c (patch)
tree02250ce42b825c35453c7fde576120eef9d3537d /src/codegen/compat.h
parent4049809f230e5e27adaf19aa57e7e9b69da5a4f0 (diff)
Centralize TCC compat
Diffstat (limited to 'src/codegen/compat.h')
-rw-r--r--src/codegen/compat.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/codegen/compat.h b/src/codegen/compat.h
index f2d221a..26b0df5 100644
--- a/src/codegen/compat.h
+++ b/src/codegen/compat.h
@@ -22,6 +22,37 @@
#define ZC_EXTERN_C_END
#endif
+#ifdef __TINYC__
+/* TCC compatibility */
+#ifndef __auto_type
+#define __auto_type __typeof__
+#endif
+
+#ifndef __builtin_expect
+#define __builtin_expect(x, v) (x)
+#endif
+
+#ifndef __builtin_unreachable
+#define __builtin_unreachable()
+#endif
+#endif
+
+/* Centralized string definition for codegen emission */
+#define ZC_TCC_COMPAT_STR \
+ "#ifdef __TINYC__\n" \
+ "#ifndef __auto_type\n" \
+ "#define __auto_type __typeof__\n" \
+ "#endif\n" \
+ "\n" \
+ "#ifndef __builtin_expect\n" \
+ "#define __builtin_expect(x, v) (x)\n" \
+ "#endif\n" \
+ "\n" \
+ "#ifndef __builtin_unreachable\n" \
+ "#define __builtin_unreachable()\n" \
+ "#endif\n" \
+ "#endif\n"
+
#ifdef __cplusplus
#include <type_traits>