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) {