summaryrefslogtreecommitdiff
path: root/src/codegen/codegen_decl.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-13 12:58:55 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-13 12:58:55 +0000
commit8d7e628878aac07d0380463196f823502d1816ce (patch)
tree276e19725a5c89e65b6fea30b358f64644212e6a /src/codegen/codegen_decl.c
parentd561a63d8b5f6beadca30ab7b7846b387d67929a (diff)
Fix for #10
Diffstat (limited to 'src/codegen/codegen_decl.c')
-rw-r--r--src/codegen/codegen_decl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/codegen/codegen_decl.c b/src/codegen/codegen_decl.c
index ac4ae14..4979236 100644
--- a/src/codegen/codegen_decl.c
+++ b/src/codegen/codegen_decl.c
@@ -8,7 +8,7 @@
#include <string.h>
// Emit C preamble with standard includes and type definitions.
-void emit_preamble(FILE *out)
+void emit_preamble(ParserContext *ctx, FILE *out)
{
if (g_config.is_freestanding)
{
@@ -54,8 +54,11 @@ void emit_preamble(FILE *out)
fputs("#include <unistd.h>\n#include <fcntl.h>\n", out); // POSIX functions
fputs("#ifdef __TINYC__\n#define __auto_type __typeof__\n#endif\n", out);
fputs("typedef size_t usize;\ntypedef char* string;\n", out);
- fputs("#include <pthread.h>\n", out);
- fputs("typedef struct { pthread_t thread; void *result; } Async;\n", out);
+ if (ctx->has_async)
+ {
+ fputs("#include <pthread.h>\n", out);
+ fputs("typedef struct { pthread_t thread; void *result; } Async;\n", out);
+ }
fputs("typedef struct { void *func; void *ctx; } z_closure_T;\n", out);
fputs("#define U0 void\n#define I8 int8_t\n#define U8 uint8_t\n#define I16 "
"int16_t\n#define U16 uint16_t\n",