From da9e8758e9d89dc7362be67f8e7573309efe170c Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Thu, 29 Jan 2026 03:03:56 +0000 Subject: Centralize TCC compat --- src/codegen/compat.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/codegen/compat.h') 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 -- cgit v1.2.3