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.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-11-18 01:30:06 +01:00 committed by Janneke Nieuwenhuizen
parent 7725574935
commit cbea14f843
8 changed files with 18 additions and 36 deletions

View file

@ -37,6 +37,15 @@
#define STDERR 2 #define STDERR 2
#endif #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 char **environ;
extern int __stdin; extern int __stdin;
extern int __stdout; extern int __stdout;

View file

@ -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 */ /* mes */
extern char *g_datadir; extern char *g_datadir;
extern int g_debug; extern int g_debug;

View file

@ -22,12 +22,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if __M2__
#define M2_PTR_SIZE 4
#else
#define M2_PTR_SIZE 1
#endif
char * char *
getenv (char const *s) getenv (char const *s)
{ {

View file

@ -22,12 +22,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if __M2__
#define M2_PTR_SIZE 4
#else
#define M2_PTR_SIZE 1
#endif
int int
setenv (char const *s, char const *v, int overwrite_p) setenv (char const *s, char const *v, int overwrite_p)
{ {

View file

@ -31,12 +31,6 @@
int g_dump_filedes; int g_dump_filedes;
#if __M2__
#define M2_CELL_SIZE 12
#else
#define M2_CELL_SIZE 1U
#endif
char * char *
cell_bytes (struct scm *x) cell_bytes (struct scm *x)
{ {

View file

@ -23,12 +23,6 @@
#include <string.h> #include <string.h>
#if __M2__
#define M2_CELL_SIZE 12
#else
#define M2_CELL_SIZE 1
#endif
struct scm * struct scm *
init_symbol (struct scm *x, long type, char const *name) init_symbol (struct scm *x, long type, char const *name)
{ {

View file

@ -24,12 +24,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if __M2__
#define M2_CELL_SIZE 12
#else
#define M2_CELL_SIZE 1
#endif
int g_debug; int g_debug;
void void

View file

@ -21,12 +21,6 @@
#include "mes/lib.h" #include "mes/lib.h"
#include "mes/mes.h" #include "mes/mes.h"
#if __M2__
#define M2_CELL_SIZE 12
#else
#define M2_CELL_SIZE 1
#endif
struct scm * struct scm *
make_vector_ (long k, struct scm *e) make_vector_ (long k, struct scm *e)
{ {