diff options
Diffstat (limited to 'src/stdlib/util.h')
| -rw-r--r-- | src/stdlib/util.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/stdlib/util.h b/src/stdlib/util.h index db667ccf..3ab025f4 100644 --- a/src/stdlib/util.h +++ b/src/stdlib/util.h @@ -4,7 +4,6 @@ #include <assert.h> #include <err.h> -#include <gc.h> #include <stdbool.h> #include <string.h> @@ -12,9 +11,6 @@ #define starts_with(line, prefix) (strncmp(line, prefix, strlen(prefix)) == 0) #define ends_with(line, suffix) \ (strlen(line) >= strlen(suffix) && strcmp(line + strlen(line) - strlen(suffix), suffix) == 0) -#define new(t, ...) ((t *)memcpy(GC_MALLOC(sizeof(t)), &(t){__VA_ARGS__}, sizeof(t))) -#define heap(x) (__typeof(x) *)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x)) -#define stack(x) (__typeof(x) *)((__typeof(x)[1]){x}) #define check_initialized(var, init_var, name) \ *({ \ if (!init_var) fail("The variable " name " is being accessed before it has been initialized!"); \ @@ -61,3 +57,10 @@ #define MACROLIKE extern inline __attribute__((gnu_inline, always_inline)) #endif #endif + +#ifndef GC_MALLOC +extern void *GC_malloc(size_t); +#define GC_MALLOC GC_malloc +#define heap(x) (__typeof(x) *)memcpy(GC_malloc(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x)) +#define stack(x) (__typeof(x) *)((__typeof(x)[1]){x}) +#endif |
