From cbea14f843ffb9cd767ef2246d09f344752bf72e Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Fri, 18 Nov 2022 01:30:06 +0100 Subject: [PATCH] core: Move M2_PTR_SIZE, M2_CELL_SIZE to include file. * lib/posix/getenv.c (M2_PTR_SIZE), lib/posix/setenv.c (M2_PTR_SIZE): Move definition... * include/mes/lib-mini.h (M2_PTR_SIZE): ...here. * src/gc.c (M2_CELL_SIZE), src/symbol.c (M2_CELL_SIZE), src/test/gc.c (M2_CELL_SIZE), src/vector.c (M2_CELL_SIZE): Move definition... * include/mes/mes.h (M2_CELL_SIZE): ...here. --- include/mes/lib-mini.h | 9 +++++++++ include/mes/mes.h | 9 +++++++++ lib/posix/getenv.c | 6 ------ lib/posix/setenv.c | 6 ------ src/gc.c | 6 ------ src/symbol.c | 6 ------ src/test/gc.c | 6 ------ src/vector.c | 6 ------ 8 files changed, 18 insertions(+), 36 deletions(-) diff --git a/include/mes/lib-mini.h b/include/mes/lib-mini.h index b3f24316..eb994f79 100644 --- a/include/mes/lib-mini.h +++ b/include/mes/lib-mini.h @@ -37,6 +37,15 @@ #define STDERR 2 #endif +/* M2-Planet does not support pointer arithmetic. Explicitly compensate + for that by multiplying with M2_PTR_SIZE when using (char) + pointers. */ +#if __M2__ +#define M2_PTR_SIZE 4 +#else +#define M2_PTR_SIZE 1 +#endif + extern char **environ; extern int __stdin; extern int __stdout; diff --git a/include/mes/mes.h b/include/mes/mes.h index 337f03aa..0323b2dc 100644 --- a/include/mes/mes.h +++ b/include/mes/mes.h @@ -53,6 +53,15 @@ struct scm }; }; +/* M2-Planet does not support pointer arithmetic. Explicitly compensate + for that by multiplying with M2_CELL_SIZE when using cell + pointers. */ +#if __M2__ +#define M2_CELL_SIZE 12 +#else +#define M2_CELL_SIZE 1 +#endif + /* mes */ extern char *g_datadir; extern int g_debug; diff --git a/lib/posix/getenv.c b/lib/posix/getenv.c index 9386044b..e514f8c1 100644 --- a/lib/posix/getenv.c +++ b/lib/posix/getenv.c @@ -22,12 +22,6 @@ #include #include -#if __M2__ -#define M2_PTR_SIZE 4 -#else -#define M2_PTR_SIZE 1 -#endif - char * getenv (char const *s) { diff --git a/lib/posix/setenv.c b/lib/posix/setenv.c index 1754e6e9..bdca5a7c 100644 --- a/lib/posix/setenv.c +++ b/lib/posix/setenv.c @@ -22,12 +22,6 @@ #include #include -#if __M2__ -#define M2_PTR_SIZE 4 -#else -#define M2_PTR_SIZE 1 -#endif - int setenv (char const *s, char const *v, int overwrite_p) { diff --git a/src/gc.c b/src/gc.c index a55f24dc..8439536d 100644 --- a/src/gc.c +++ b/src/gc.c @@ -31,12 +31,6 @@ int g_dump_filedes; -#if __M2__ -#define M2_CELL_SIZE 12 -#else -#define M2_CELL_SIZE 1U -#endif - char * cell_bytes (struct scm *x) { diff --git a/src/symbol.c b/src/symbol.c index 5d0aaaa2..55330fcd 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -23,12 +23,6 @@ #include -#if __M2__ -#define M2_CELL_SIZE 12 -#else -#define M2_CELL_SIZE 1 -#endif - struct scm * init_symbol (struct scm *x, long type, char const *name) { diff --git a/src/test/gc.c b/src/test/gc.c index edafad8c..62960436 100644 --- a/src/test/gc.c +++ b/src/test/gc.c @@ -24,12 +24,6 @@ #include #include -#if __M2__ -#define M2_CELL_SIZE 12 -#else -#define M2_CELL_SIZE 1 -#endif - int g_debug; void diff --git a/src/vector.c b/src/vector.c index e4a35ead..ad6b097b 100644 --- a/src/vector.c +++ b/src/vector.c @@ -21,12 +21,6 @@ #include "mes/lib.h" #include "mes/mes.h" -#if __M2__ -#define M2_CELL_SIZE 12 -#else -#define M2_CELL_SIZE 1 -#endif - struct scm * make_vector_ (long k, struct scm *e) {