From f9cb198aa889b011b45f14bb8a79ceba843a1700 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Mon, 26 Feb 2024 07:18:07 +0100 Subject: [PATCH] tccrun: update for apple and openbsd Apple needs CONFIG_RUNMEM_RO=1 I now only set CONFIG_RUNMEM_RO=0 on _WIN32 Openbsd does not have malloc.h so remove some code Also fix some warnings when compiling lib with gcc --- lib/runmain.c | 1 + tccrun.c | 19 +++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/runmain.c b/lib/runmain.c index 53cbe6de..1cbf6dda 100644 --- a/lib/runmain.c +++ b/lib/runmain.c @@ -69,6 +69,7 @@ void exit(int code) f.fp = 0; f.ip = exit; __rt_exit(&f, code); + for (;;); // avoid noreturn warning } #ifndef _WIN32 diff --git a/tccrun.c b/tccrun.c index 94c61ceb..b27ccc59 100644 --- a/tccrun.c +++ b/tccrun.c @@ -91,17 +91,6 @@ static void *win64_add_function_table(TCCState *s1); static void win64_del_function_table(void *); #endif -#ifdef __APPLE__ -# define CONFIG_RUNMEM_ALIGNED 0 -#else -# ifndef CONFIG_RUNMEM_ALIGNED -# define CONFIG_RUNMEM_ALIGNED 1 -# endif -# if CONFIG_RUNMEM_ALIGNED -# include /* memalign() */ -# endif -#endif - #if !_WIN32 && !__APPLE__ //#define HAVE_SELINUX 1 #endif @@ -286,7 +275,11 @@ static void cleanup_sections(TCCState *s1) /* 0 = .text rwx other rw */ /* 1 = .text rx .rdata r .data/.bss rw */ #ifndef CONFIG_RUNMEM_RO -# define CONFIG_RUNMEM_RO 0 +# ifdef _WIN32 +# define CONFIG_RUNMEM_RO 0 +# else +# define CONFIG_RUNMEM_RO 1 +# endif #endif /* relocate code. Return -1 on error, required size if ptr is NULL, @@ -1184,7 +1177,9 @@ int _tcc_backtrace(rt_frame *f, const char *fmt, va_list ap) } rt_printf("\n"); +#ifndef CONFIG_TCC_BACKTRACE_ONLY check_break: +#endif if (rc2 && bi.func_pc && bi.func_pc == (addr_t)rc2->top_func)