From fb700978ac6a415f23e398071057416b13d9b219 Mon Sep 17 00:00:00 2001 From: Naman Dixit Date: Sat, 6 Jun 2020 18:57:44 +0530 Subject: [PATCH] Moved the libc override macros to settings.h, and removed __VA_ARGS__ --- aarch64.c | 11 ----------- amd64.c | 11 ----------- arm.c | 11 ----------- ppc.c | 6 ------ ppc64v2.c | 6 ------ settings.h | 12 ++++++++++++ x86.c | 11 ----------- 7 files changed, 12 insertions(+), 56 deletions(-) diff --git a/aarch64.c b/aarch64.c index a77bb075..980686b8 100644 --- a/aarch64.c +++ b/aarch64.c @@ -2,17 +2,6 @@ #include "libco.h" #include "settings.h" -#if !defined(LIBCO_ASSERT) - #include - #define LIBCO_ASSERT(...) assert(__VA_ARGS__) -#endif - -#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) - #include - #define LIBCO_MALLOC(...) malloc(__VA_ARGS__) - #define LIBCO_FREE(...) free(__VA_ARGS__) -#endif - #include #ifdef LIBCO_MPROTECT #include diff --git a/amd64.c b/amd64.c index 833b5e2e..fa454809 100644 --- a/amd64.c +++ b/amd64.c @@ -2,17 +2,6 @@ #include "libco.h" #include "settings.h" -#if !defined(LIBCO_ASSERT) - #include - #define LIBCO_ASSERT(...) assert(__VA_ARGS__) -#endif - -#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) - #include - #define LIBCO_MALLOC(...) malloc(__VA_ARGS__) - #define LIBCO_FREE(...) free(__VA_ARGS__) -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/arm.c b/arm.c index 4a4aef51..6f0aa24d 100644 --- a/arm.c +++ b/arm.c @@ -2,17 +2,6 @@ #include "libco.h" #include "settings.h" -#if !defined(LIBCO_ASSERT) - #include - #define LIBCO_ASSERT(...) assert(__VA_ARGS__) -#endif - -#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) - #include - #define LIBCO_MALLOC(...) malloc(__VA_ARGS__) - #define LIBCO_FREE(...) free(__VA_ARGS__) -#endif - #ifdef LIBCO_MPROTECT #include #include diff --git a/ppc.c b/ppc.c index bcbdf966..a39d558e 100644 --- a/ppc.c +++ b/ppc.c @@ -4,12 +4,6 @@ #include "libco.h" #include "settings.h" -#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) - #include - #define LIBCO_MALLOC(...) malloc(__VA_ARGS__) - #define LIBCO_FREE(...) free(__VA_ARGS__) -#endif - #include #include diff --git a/ppc64v2.c b/ppc64v2.c index 1cac8843..d302a28a 100644 --- a/ppc64v2.c +++ b/ppc64v2.c @@ -6,12 +6,6 @@ #include -#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) - #include - #define LIBCO_MALLOC(...) malloc(__VA_ARGS__) - #define LIBCO_FREE(...) free(__VA_ARGS__) -#endif - #ifdef __cplusplus extern "C" { #endif diff --git a/settings.h b/settings.h index d8037bc4..695ebfb7 100644 --- a/settings.h +++ b/settings.h @@ -26,6 +26,17 @@ #define alignas(bytes) #endif +#if !defined(LIBCO_ASSERT) + #include + #define LIBCO_ASSERT assert +#endif + +#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) + #include + #define LIBCO_MALLOC malloc + #define LIBCO_FREE free +#endif + #if defined(_MSC_VER) #define section(name) __declspec(allocate("." #name)) #elif defined(__APPLE__) @@ -34,5 +45,6 @@ #define section(name) __attribute__((section("." #name "#"))) #endif + /* if defined(LIBCO_C) */ #endif diff --git a/x86.c b/x86.c index d2c760ad..d31b4ac3 100644 --- a/x86.c +++ b/x86.c @@ -2,17 +2,6 @@ #include "libco.h" #include "settings.h" -#if !defined(LIBCO_ASSERT) - #include - #define LIBCO_ASSERT(...) assert(__VA_ARGS__) -#endif - -#if !defined(LIBCO_MALLOC) || !defined(LIBCO_FREE) - #include - #define LIBCO_MALLOC(...) malloc(__VA_ARGS__) - #define LIBCO_FREE(...) free(__VA_ARGS__) -#endif - #ifdef __cplusplus extern "C" { #endif