Hi Alex, I've decided to try and extend miniPicoLisp with networking(or perhaps just the capability to call into external program) to make it useful as a scripting system that I can share with my colleagues. Please do let me know if that's not a good idea.
Towards that, as a first step, I tried to compile miniPicoLIsp with 64bit C compiler and ran into some errors. Could you please take a look at this patch and confirm if these changes are sufficient? I essentially changed the use of long to long long in a couple of places :) diff --git a/io.c b/io.c index 7b86c60..bb0f77c 100644 --- a/io.c +++ b/io.c @@ -282,7 +282,7 @@ static any rdList(void) { static any anonymous(any s) { int c, i; word w; - unsigned long n; + unsigned WORD_TYPE n; heap *h; if ((c = getByte1(&i, &w, &s)) != '$') diff --git a/main.c b/main.c index 9c3e588..19f3647 100644 --- a/main.c +++ b/main.c @@ -64,7 +64,7 @@ void heapAlloc(void) { heap *h; cell *p; - h = (heap*)((long)alloc(NULL, sizeof(heap) + sizeof(cell)) + (sizeof(cell)-1) & ~(sizeof(cell)-1)); + h = (heap*)((WORD_TYPE)alloc(NULL, sizeof(heap) + sizeof(cell)) + (sizeof(cell)-1) & ~(sizeof(cell)-1)); h->next = Heaps, Heaps = h; p = h->cells + CELLS-1; do @@ -295,7 +295,7 @@ long compare(any x, any y) { return -1; a = name(x), b = name(y); if (a == txt(0) && b == txt(0)) - return (long)x - (long)y; + return (WORD_TYPE)x - (WORD_TYPE)y; if ((c = getByte1(&i, &w, &a)) == (d = getByte1(&j, &v, &b))) do if (c == 0) diff --git a/math.c b/math.c index acf5e66..a2e9e62 100644 --- a/math.c +++ b/math.c @@ -264,7 +264,7 @@ any doMul(any ex) { // (*/ 'num1 ['num2 ..] 'num3) -> num any doMulDiv(any ex) { any x, y; - long long n; + WORD_TYPE n; x = cdr(ex); if (isNil(y = EVAL(car(x)))) @@ -457,7 +457,7 @@ any doBitXor(any ex) { // (sqrt 'num ['flg|num]) -> num any doSqrt(any ex) { any x; - long m, n, r; + WORD_TYPE m, n, r; x = cdr(ex); if (isNil(x = EVAL(car(x)))) @@ -468,7 +468,7 @@ any doSqrt(any ex) { x = cddr(ex); if (isNum(x = EVAL(car(x)))) n *= unBox(x); - m = 1L << BITS-4; + m = (WORD_TYPE)1 << BITS-4; r = 0; do { if ((r += m) > n) diff --git a/pico.h b/pico.h index 687b493..c5d483d 100644 --- a/pico.h +++ b/pico.h @@ -15,10 +15,13 @@ #define CELLS (1024*1024/sizeof(cell)) #endif -#define WORD ((int)sizeof(long)) +#ifndef WORD_TYPE +#define WORD_TYPE long long +#endif +#define WORD ((int)sizeof(WORD_TYPE)) #define BITS (8*WORD) -typedef unsigned long word; +typedef unsigned long long word; typedef unsigned char byte; typedef unsigned char *ptr; @@ -88,7 +91,7 @@ typedef struct catchFrame { #define Free(p) ((p)->car=Avail, Avail=(p)) /* Number access */ -#define num(x) ((long)(x)) +#define num(x) ((WORD_TYPE)(x)) #define txt(n) ((any)(num(n)<<1|1)) #define box(n) ((any)(num(n)<<2|2)) #define unBox(n) (num(n)>>2)