From bc0388714821eea6dd8a4e72bc24f2a899e9123f Mon Sep 17 00:00:00 2001 From: Martin Fouilleul Date: Sun, 25 Jun 2023 20:17:01 +0200 Subject: [PATCH] Added ORCA_IMPORT to mark symbols imported from the runtime --- src/platform/orca_log.c | 16 ++++++++-------- src/platform/orca_memory.c | 2 +- src/platform/platform.h | 5 +++++ src/platform/platform_assert.h | 2 +- src/platform/platform_math.h | 8 ++++---- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/platform/orca_log.c b/src/platform/orca_log.c index 5e1e24c..5bf1068 100644 --- a/src/platform/orca_log.c +++ b/src/platform/orca_log.c @@ -24,14 +24,14 @@ typedef struct log_output static log_output _logDefaultOutput = {.kind = ORCA_LOG_OUTPUT_CONSOLE}; log_output* LOG_DEFAULT_OUTPUT = &_logDefaultOutput; -extern void orca_log(log_level level, - int fileLen, - const char* file, - int functionLen, - const char* function, - int line, - int msgLen, - const char* msg); +void ORCA_IMPORT(orca_log)(log_level level, + int fileLen, + const char* file, + int functionLen, + const char* function, + int line, + int msgLen, + const char* msg); typedef struct orca_log_context { diff --git a/src/platform/orca_memory.c b/src/platform/orca_memory.c index c5248c1..6b52925 100644 --- a/src/platform/orca_memory.c +++ b/src/platform/orca_memory.c @@ -8,7 +8,7 @@ #include"platform_memory.h" -extern void* orca_mem_grow(u64 size); +void* ORCA_IMPORT(orca_mem_grow)(u64 size); void* orca_mem_base_reserve(mem_base_allocator* context, u64 size) { diff --git a/src/platform/platform.h b/src/platform/platform.h index 471081a..05c1637 100644 --- a/src/platform/platform.h +++ b/src/platform/platform.h @@ -94,4 +94,9 @@ #define mp_thread_local __thread #endif + +#if PLATFORM_ORCA + #define ORCA_IMPORT(f) __attribute__((import_name(#f))) f +#endif + #endif // __PLATFORM_H_ diff --git a/src/platform/platform_assert.h b/src/platform/platform_assert.h index 39ff43c..9d9f6d2 100644 --- a/src/platform/platform_assert.h +++ b/src/platform/platform_assert.h @@ -13,7 +13,7 @@ //NOTE: assert macros #ifndef NO_ASSERT #ifdef PLATFORM_ORCA - extern int orca_assert(const char* file, const char* function, int line, const char* src, const char* msg); + int ORCA_IMPORT(orca_assert)(const char* file, const char* function, int line, const char* src, const char* msg); #define _ASSERT_(x, msg) ((x) || orca_assert(__FILE__, __FUNCTION__, __LINE__, #x, msg)) #else #include diff --git a/src/platform/platform_math.h b/src/platform/platform_math.h index 442fd48..032a711 100644 --- a/src/platform/platform_math.h +++ b/src/platform/platform_math.h @@ -17,10 +17,10 @@ #define M_PI 3.14159265358979323846 -double fabs(double x); -double sqrt(double sqrt); -double cos(double x); -double sin(double x); +double ORCA_IMPORT(fabs)(double x); +double ORCA_IMPORT(sqrt)(double sqrt); +double ORCA_IMPORT(cos)(double x); +double ORCA_IMPORT(sin)(double x); #endif