diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index 115f8dec..5736ed9f 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/06] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/11] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index 84e8427b..31877f12 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Console.c b/bootstrap/unix-44/Console.c index 8cbc9ce9..6181cbfd 100644 --- a/bootstrap/unix-44/Console.c +++ b/bootstrap/unix-44/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Console.h b/bootstrap/unix-44/Console.h index e9913d2d..78586a68 100644 --- a/bootstrap/unix-44/Console.h +++ b/bootstrap/unix-44/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index d596986e..f98f4e55 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index b0f34806..de420c7c 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index 2bbe63b2..58be6181 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #define INTEGER int16 #define LONGINT int32 @@ -353,7 +353,7 @@ static void Heap_Mark (address q) tag = tagbits + 4; for (;;) { __GET(tag, offset, address); - if (__BIT((address)&offset, 31)) { + if (offset < 0) { __PUT(q - 4, (tag + offset) + 1, address); if (p == 0) { break; diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index 6694ef70..827a3a7c 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index e31876fb..66a8c776 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 4bd4082d..02abd713 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index 0a1a9f63..8d44024a 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index 5ffa3869..5aaa8469 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 5666c7cd..1122a8d0 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index e1fc08ec..1a9ad61f 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 461b5b85..e6d709e7 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index c60f6f98..c5192f5b 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 1ab60658..6e2d4cd0 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index ce85af11..de48c5ba 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 3a1c4787..9b3bf8f0 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index 512cfa75..8689aa3b 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index 1983daf5..0d16f8ec 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index d3b24cc6..b9e46b1a 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index a62894dd..e36e3be5 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index b10704dc..c692efd8 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 43761270..b8559160 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index 0f9c0290..868c4e52 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 5f3d11a5..c9e8e867 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index cf931556..bd36f8d6 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/SYSTEM.c b/bootstrap/unix-44/SYSTEM.c index 821a6096..d7603f8e 100644 --- a/bootstrap/unix-44/SYSTEM.c +++ b/bootstrap/unix-44/SYSTEM.c @@ -21,11 +21,34 @@ // Procedure verions of SYSTEM.H versions used when a multiply accessed // parameter has side effects. -int64 SYSTEM_XCHK(uint64 i, uint64 ub) {return __X(i, ub);} -int64 SYSTEM_RCHK(uint64 i, uint64 ub) {return __R(i, ub);} -LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);} -LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} -double SYSTEM_ABSD(double i) {return __ABS(i);} + + +LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} +double SYSTEM_ABSD(double i) {return __ABS(i);} + + +int64 SYSTEM_DIV(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x/y;} + else {return -((x-y-1)/(-y));} + else + if (y >= 0) {return -((y-x-1)/y);} + else {return (-x)/(-y);} +} + +int64 SYSTEM_MOD(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x % y;} + else {return (y+1) + ((x-1) % (-y));} + else + if (y >= 0) {return (y-1) - ((-x-1) % y);} + else {return -((-x) % (-y));} +} + void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) { @@ -57,19 +80,6 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) } } -LONGINT SYSTEM_DIV(uint64 x, uint64 y) -{ if ((int64) x >= 0) return (x / y); - else return -((y - 1 - x) / y); -} - -LONGINT SYSTEM_MOD(uint64 x, uint64 y) -{ uint64 m; - if ((int64) x >= 0) return (x % y); - else { m = (-x) % y; - if (m != 0) return (y - m); else return 0; - } -} - LONGINT SYSTEM_ENTIER(double x) { LONGINT y; diff --git a/bootstrap/unix-44/SYSTEM.h b/bootstrap/unix-44/SYSTEM.h index 6fc57309..168b0beb 100644 --- a/bootstrap/unix-44/SYSTEM.h +++ b/bootstrap/unix-44/SYSTEM.h @@ -2,9 +2,17 @@ #define SYSTEM__h +// 64 bit system detection + +#if (__SIZEOF_POINTER__ == 8) || defined (_LP64) || defined(__LP64__) || defined(_WIN64) + #define __o_64 +#endif + +// Temporary while bootstrapping and clearing up SYSTEM.c. + #ifndef LONGINT - #if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) + #if defined (__o_64) #define INTEGER int32 #define LONGINT int64 #define SET uint64 @@ -22,14 +30,17 @@ // Declare memcpy in a way compatible with C compilers intrinsic // built in implementations. -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) +#if defined (__o_64) #if defined(_WIN64) typedef unsigned long long size_t; +// typedef long long address; #else typedef unsigned long size_t; +// typedef long address; #endif #else typedef unsigned int size_t; +//typedef int address; #endif #define _SIZE_T_DECLARED // For FreeBSD @@ -40,14 +51,14 @@ void *memcpy(void *dest, const void *source, size_t size); // Declare fixed size versions of basic intger types -#if (__SIZEOF_POINTER__ < 8) || defined(_WIN64) - // ILP32 or LLP64 - typedef long long int64; - typedef unsigned long long uint64; -#else +#if defined (__o_64) && !defined(_WIN64) // LP64 typedef long int64; typedef unsigned long uint64; +#else + // ILP32 or LLP64 + typedef long long int64; + typedef unsigned long long uint64; #endif typedef int int32; @@ -59,7 +70,14 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#define address size_t + +// 'address' is a synonym for an int32 of pointer size + +#if defined (__o_64) + #define address int64 +#else + #define address int32 +#endif // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. @@ -103,18 +121,40 @@ extern address Platform_OSAllocate (address size); extern void Platform_OSFree (address addr); +// Assertions and Halts + +extern void Platform_Halt(LONGINT x); +extern void Platform_AssertFail(LONGINT x); + +#define __HALT(x) Platform_Halt(x) +#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) + + +// Index checking + +static inline int64 __XF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-2);} return i;} +#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) + + +// Range checking, and checked SHORT and CHR functions + +static inline int64 __RF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-8);} return i;} +#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) +#define __SHORT(x, ub) ((int)((uLONGINT)(x)+(ub)<(ub)+(ub)?(x):(__HALT(-8),0))) +#define __SHORTF(x, ub) ((int)(__RF((x)+(ub),(ub)+(ub))-(ub))) +#define __CHR(x) ((CHAR)__R(x, 256)) +#define __CHRF(x) ((CHAR)__RF(x, 256)) + + + // Run time system routines in SYSTEM.c -extern int64 SYSTEM_XCHK (uint64 i, uint64 ub); -extern int64 SYSTEM_RCHK (uint64 i, uint64 ub); -extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n); + extern LONGINT SYSTEM_ABS (LONGINT i); extern double SYSTEM_ABSD (double i); extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0); extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)()); extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()); -extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); -extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); @@ -131,7 +171,7 @@ extern LONGINT SYSTEM_ENTIER (double x); // String comparison -static int __str_cmp(CHAR *x, CHAR *y){ +static inline int __str_cmp(CHAR *x, CHAR *y){ LONGINT i = 0; CHAR ch1, ch2; do {ch1 = x[i]; ch2 = y[i]; i++; @@ -152,21 +192,12 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __DEL(x) Platform_OSFree((address)x) -// Index and range checks - -#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((uint64)(i), (uint64)(ub)) - -#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((uint64)(i),(uint64)(ub)) - - /* SYSTEM ops */ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(address)(a) +#define __GET(a, x, t) x=*(t*)(address)(a) #define __PUT(a, x, t) *(t*)(address)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) @@ -177,21 +208,27 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __ROTR(x, n, t) ((t)((u##t)(x)>>(n)|(u##t)(x)<<(8*sizeof(t)-(n)))) #define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASHL(x, n) ((int64)(x)<<(n)) +#define __ASHR(x, n) ((int64)(x)>>(n)) #define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) -#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) +static inline int64 SYSTEM_ASH(int64 x, int64 n) {return __ASH(x,n);} +#define __ASHF(x, n) SYSTEM_ASH((int64)(x), (int64)(n)) #define __BIT(x, n) (*(uint64*)(x)>>(n)&1) #define __MOVE(s, d, n) memcpy((char*)(address)(d),(char*)(address)(s),n) -#define __SHORT(x, y) ((int)((uLONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0))) -#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y))) -#define __CHR(x) ((CHAR)__R(x, 256)) -#define __CHRF(x) ((CHAR)__RF(x, 256)) -#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y))) -#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y)) -#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y)) -#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y)) + + +extern int64 SYSTEM_DIV(int64 x, int64 y); +#define __DIVF(x, y) SYSTEM_DIV(x, y) +#define __DIV(x, y) (((x)>0 && (y)>0) ? (x)/(y) : __DIVF(x, y)) + + +extern int64 SYSTEM_MOD(int64 x, int64 y); +#define __MODF(x, y) SYSTEM_MOD(x, y) +#define __MOD(x, y) (((x)>0 && (y)>0) ? (x)%(y) : __MODF(x, y)) + + + #define __ENTIER(x) SYSTEM_ENTIER(x) #define __ABS(x) (((x)<0)?-(x):(x)) #define __ABSF(x) SYSTEM_ABS((LONGINT)(x)) @@ -244,15 +281,6 @@ extern void Heap_FINALL(); #define __FINI Heap_FINALL(); return 0 -// Assertions and Halts - -extern void Platform_Halt(LONGINT x); -extern void Platform_AssertFail(LONGINT x); - -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) - - // Memory allocation extern SYSTEM_PTR Heap_NEWBLK (address size); diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 7e1a6845..af7a679b 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 59076121..d145001a 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 9314c178..ace0257e 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index ce868328..e52c65ca 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/Vishap.c b/bootstrap/unix-44/Vishap.c index 549268e2..b289dfa6 100644 --- a/bootstrap/unix-44/Vishap.c +++ b/bootstrap/unix-44/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkamSf */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/errors.c b/bootstrap/unix-44/errors.c index a2f7cf75..76fa35bf 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/errors.h b/bootstrap/unix-44/errors.h index bf0e9564..9d5bbe45 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index 27ef9f8f..3dbc28ba 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -64,7 +64,7 @@ void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len) { CHAR cmd[1023]; __DUP(moduleName, moduleName__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); @@ -77,7 +77,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati { CHAR cmd[1023]; __DUP(additionalopts, additionalopts__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append((CHAR*)" ", 2, (void*)cmd, 1023); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index c5d5c772..8bdd3b71 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-44/vt100.c b/bootstrap/unix-44/vt100.c index 912e5e83..2e236578 100644 --- a/bootstrap/unix-44/vt100.c +++ b/bootstrap/unix-44/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-44/vt100.h b/bootstrap/unix-44/vt100.h index 36c0bc7e..0eae5799 100644 --- a/bootstrap/unix-44/vt100.h +++ b/bootstrap/unix-44/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index 115f8dec..5736ed9f 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/06] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/11] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index 84e8427b..31877f12 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Console.c b/bootstrap/unix-48/Console.c index 8cbc9ce9..6181cbfd 100644 --- a/bootstrap/unix-48/Console.c +++ b/bootstrap/unix-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Console.h b/bootstrap/unix-48/Console.h index e9913d2d..78586a68 100644 --- a/bootstrap/unix-48/Console.h +++ b/bootstrap/unix-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index d596986e..f98f4e55 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index b0f34806..de420c7c 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index 2bbe63b2..58be6181 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #define INTEGER int16 #define LONGINT int32 @@ -353,7 +353,7 @@ static void Heap_Mark (address q) tag = tagbits + 4; for (;;) { __GET(tag, offset, address); - if (__BIT((address)&offset, 31)) { + if (offset < 0) { __PUT(q - 4, (tag + offset) + 1, address); if (p == 0) { break; diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index 6694ef70..827a3a7c 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index e31876fb..66a8c776 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 4bd4082d..02abd713 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index 0a1a9f63..8d44024a 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index 5ffa3869..5aaa8469 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 5666c7cd..1122a8d0 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index e1fc08ec..1a9ad61f 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 461b5b85..e6d709e7 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index c60f6f98..c5192f5b 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 1ab60658..6e2d4cd0 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index ce85af11..de48c5ba 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 3a1c4787..9b3bf8f0 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index 512cfa75..8689aa3b 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index 1983daf5..0d16f8ec 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index d3b24cc6..b9e46b1a 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index a62894dd..e36e3be5 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index b10704dc..c692efd8 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 43761270..b8559160 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index 0f9c0290..868c4e52 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 5f3d11a5..c9e8e867 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index cf931556..bd36f8d6 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/SYSTEM.c b/bootstrap/unix-48/SYSTEM.c index 821a6096..d7603f8e 100644 --- a/bootstrap/unix-48/SYSTEM.c +++ b/bootstrap/unix-48/SYSTEM.c @@ -21,11 +21,34 @@ // Procedure verions of SYSTEM.H versions used when a multiply accessed // parameter has side effects. -int64 SYSTEM_XCHK(uint64 i, uint64 ub) {return __X(i, ub);} -int64 SYSTEM_RCHK(uint64 i, uint64 ub) {return __R(i, ub);} -LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);} -LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} -double SYSTEM_ABSD(double i) {return __ABS(i);} + + +LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} +double SYSTEM_ABSD(double i) {return __ABS(i);} + + +int64 SYSTEM_DIV(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x/y;} + else {return -((x-y-1)/(-y));} + else + if (y >= 0) {return -((y-x-1)/y);} + else {return (-x)/(-y);} +} + +int64 SYSTEM_MOD(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x % y;} + else {return (y+1) + ((x-1) % (-y));} + else + if (y >= 0) {return (y-1) - ((-x-1) % y);} + else {return -((-x) % (-y));} +} + void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) { @@ -57,19 +80,6 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) } } -LONGINT SYSTEM_DIV(uint64 x, uint64 y) -{ if ((int64) x >= 0) return (x / y); - else return -((y - 1 - x) / y); -} - -LONGINT SYSTEM_MOD(uint64 x, uint64 y) -{ uint64 m; - if ((int64) x >= 0) return (x % y); - else { m = (-x) % y; - if (m != 0) return (y - m); else return 0; - } -} - LONGINT SYSTEM_ENTIER(double x) { LONGINT y; diff --git a/bootstrap/unix-48/SYSTEM.h b/bootstrap/unix-48/SYSTEM.h index 6fc57309..168b0beb 100644 --- a/bootstrap/unix-48/SYSTEM.h +++ b/bootstrap/unix-48/SYSTEM.h @@ -2,9 +2,17 @@ #define SYSTEM__h +// 64 bit system detection + +#if (__SIZEOF_POINTER__ == 8) || defined (_LP64) || defined(__LP64__) || defined(_WIN64) + #define __o_64 +#endif + +// Temporary while bootstrapping and clearing up SYSTEM.c. + #ifndef LONGINT - #if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) + #if defined (__o_64) #define INTEGER int32 #define LONGINT int64 #define SET uint64 @@ -22,14 +30,17 @@ // Declare memcpy in a way compatible with C compilers intrinsic // built in implementations. -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) +#if defined (__o_64) #if defined(_WIN64) typedef unsigned long long size_t; +// typedef long long address; #else typedef unsigned long size_t; +// typedef long address; #endif #else typedef unsigned int size_t; +//typedef int address; #endif #define _SIZE_T_DECLARED // For FreeBSD @@ -40,14 +51,14 @@ void *memcpy(void *dest, const void *source, size_t size); // Declare fixed size versions of basic intger types -#if (__SIZEOF_POINTER__ < 8) || defined(_WIN64) - // ILP32 or LLP64 - typedef long long int64; - typedef unsigned long long uint64; -#else +#if defined (__o_64) && !defined(_WIN64) // LP64 typedef long int64; typedef unsigned long uint64; +#else + // ILP32 or LLP64 + typedef long long int64; + typedef unsigned long long uint64; #endif typedef int int32; @@ -59,7 +70,14 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#define address size_t + +// 'address' is a synonym for an int32 of pointer size + +#if defined (__o_64) + #define address int64 +#else + #define address int32 +#endif // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. @@ -103,18 +121,40 @@ extern address Platform_OSAllocate (address size); extern void Platform_OSFree (address addr); +// Assertions and Halts + +extern void Platform_Halt(LONGINT x); +extern void Platform_AssertFail(LONGINT x); + +#define __HALT(x) Platform_Halt(x) +#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) + + +// Index checking + +static inline int64 __XF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-2);} return i;} +#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) + + +// Range checking, and checked SHORT and CHR functions + +static inline int64 __RF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-8);} return i;} +#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) +#define __SHORT(x, ub) ((int)((uLONGINT)(x)+(ub)<(ub)+(ub)?(x):(__HALT(-8),0))) +#define __SHORTF(x, ub) ((int)(__RF((x)+(ub),(ub)+(ub))-(ub))) +#define __CHR(x) ((CHAR)__R(x, 256)) +#define __CHRF(x) ((CHAR)__RF(x, 256)) + + + // Run time system routines in SYSTEM.c -extern int64 SYSTEM_XCHK (uint64 i, uint64 ub); -extern int64 SYSTEM_RCHK (uint64 i, uint64 ub); -extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n); + extern LONGINT SYSTEM_ABS (LONGINT i); extern double SYSTEM_ABSD (double i); extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0); extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)()); extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()); -extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); -extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); @@ -131,7 +171,7 @@ extern LONGINT SYSTEM_ENTIER (double x); // String comparison -static int __str_cmp(CHAR *x, CHAR *y){ +static inline int __str_cmp(CHAR *x, CHAR *y){ LONGINT i = 0; CHAR ch1, ch2; do {ch1 = x[i]; ch2 = y[i]; i++; @@ -152,21 +192,12 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __DEL(x) Platform_OSFree((address)x) -// Index and range checks - -#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((uint64)(i), (uint64)(ub)) - -#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((uint64)(i),(uint64)(ub)) - - /* SYSTEM ops */ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(address)(a) +#define __GET(a, x, t) x=*(t*)(address)(a) #define __PUT(a, x, t) *(t*)(address)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) @@ -177,21 +208,27 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __ROTR(x, n, t) ((t)((u##t)(x)>>(n)|(u##t)(x)<<(8*sizeof(t)-(n)))) #define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASHL(x, n) ((int64)(x)<<(n)) +#define __ASHR(x, n) ((int64)(x)>>(n)) #define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) -#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) +static inline int64 SYSTEM_ASH(int64 x, int64 n) {return __ASH(x,n);} +#define __ASHF(x, n) SYSTEM_ASH((int64)(x), (int64)(n)) #define __BIT(x, n) (*(uint64*)(x)>>(n)&1) #define __MOVE(s, d, n) memcpy((char*)(address)(d),(char*)(address)(s),n) -#define __SHORT(x, y) ((int)((uLONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0))) -#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y))) -#define __CHR(x) ((CHAR)__R(x, 256)) -#define __CHRF(x) ((CHAR)__RF(x, 256)) -#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y))) -#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y)) -#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y)) -#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y)) + + +extern int64 SYSTEM_DIV(int64 x, int64 y); +#define __DIVF(x, y) SYSTEM_DIV(x, y) +#define __DIV(x, y) (((x)>0 && (y)>0) ? (x)/(y) : __DIVF(x, y)) + + +extern int64 SYSTEM_MOD(int64 x, int64 y); +#define __MODF(x, y) SYSTEM_MOD(x, y) +#define __MOD(x, y) (((x)>0 && (y)>0) ? (x)%(y) : __MODF(x, y)) + + + #define __ENTIER(x) SYSTEM_ENTIER(x) #define __ABS(x) (((x)<0)?-(x):(x)) #define __ABSF(x) SYSTEM_ABS((LONGINT)(x)) @@ -244,15 +281,6 @@ extern void Heap_FINALL(); #define __FINI Heap_FINALL(); return 0 -// Assertions and Halts - -extern void Platform_Halt(LONGINT x); -extern void Platform_AssertFail(LONGINT x); - -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) - - // Memory allocation extern SYSTEM_PTR Heap_NEWBLK (address size); diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 7e1a6845..af7a679b 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 59076121..d145001a 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index a4267893..c40b975f 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index 2238689d..0aac4cc8 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/Vishap.c b/bootstrap/unix-48/Vishap.c index 549268e2..b289dfa6 100644 --- a/bootstrap/unix-48/Vishap.c +++ b/bootstrap/unix-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkamSf */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/errors.c b/bootstrap/unix-48/errors.c index a2f7cf75..76fa35bf 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/errors.h b/bootstrap/unix-48/errors.h index bf0e9564..9d5bbe45 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index 27ef9f8f..3dbc28ba 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -64,7 +64,7 @@ void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len) { CHAR cmd[1023]; __DUP(moduleName, moduleName__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); @@ -77,7 +77,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati { CHAR cmd[1023]; __DUP(additionalopts, additionalopts__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append((CHAR*)" ", 2, (void*)cmd, 1023); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index c5d5c772..8bdd3b71 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/vt100.c b/bootstrap/unix-48/vt100.c index 912e5e83..2e236578 100644 --- a/bootstrap/unix-48/vt100.c +++ b/bootstrap/unix-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/unix-48/vt100.h b/bootstrap/unix-48/vt100.h index 36c0bc7e..0eae5799 100644 --- a/bootstrap/unix-48/vt100.h +++ b/bootstrap/unix-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index cfce02b8..b5ee44a5 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/06] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/11] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index 84e8427b..31877f12 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Console.c b/bootstrap/unix-88/Console.c index 3dc7b5ab..74de0b0a 100644 --- a/bootstrap/unix-88/Console.c +++ b/bootstrap/unix-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Console.h b/bootstrap/unix-88/Console.h index 1f1182fd..1d06d0fe 100644 --- a/bootstrap/unix-88/Console.h +++ b/bootstrap/unix-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 29b0069e..aabcb14d 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 60221720..054cde33 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 1fe3ce13..d0175b87 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #define INTEGER int32 #define LONGINT int64 @@ -353,7 +353,7 @@ static void Heap_Mark (address q) tag = tagbits + 8; for (;;) { __GET(tag, offset, address); - if (__BIT((address)&offset, 63)) { + if (offset < 0) { __PUT(q - 8, (tag + offset) + 1, address); if (p == 0) { break; diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index def46dcf..fabb54ef 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index 9d93e3d2..53bf2640 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index f9e49aa7..8e54ce53 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 11b9a1a9..f22a9ab5 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index c3c5c1e8..aa26ea1c 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index e971762c..8916c00b 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index a218490a..71b95812 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 389fda93..b15aba16 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index 51042a0e..d23aed25 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index 9ab86b22..3f77df4f 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index ce85af11..de48c5ba 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 8e53d027..491faa22 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index ffbc5084..3937b6f6 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index bd27c789..da8bab08 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index 583c31ff..668c3d79 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 2d81dd31..52fc9966 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index b10704dc..c692efd8 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 70c9bcb7..9142bf02 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index 1ffe3227..e52525fd 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index 0b5761ee..185aec0b 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index dfc56cef..a2fc2612 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/SYSTEM.c b/bootstrap/unix-88/SYSTEM.c index 821a6096..d7603f8e 100644 --- a/bootstrap/unix-88/SYSTEM.c +++ b/bootstrap/unix-88/SYSTEM.c @@ -21,11 +21,34 @@ // Procedure verions of SYSTEM.H versions used when a multiply accessed // parameter has side effects. -int64 SYSTEM_XCHK(uint64 i, uint64 ub) {return __X(i, ub);} -int64 SYSTEM_RCHK(uint64 i, uint64 ub) {return __R(i, ub);} -LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);} -LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} -double SYSTEM_ABSD(double i) {return __ABS(i);} + + +LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} +double SYSTEM_ABSD(double i) {return __ABS(i);} + + +int64 SYSTEM_DIV(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x/y;} + else {return -((x-y-1)/(-y));} + else + if (y >= 0) {return -((y-x-1)/y);} + else {return (-x)/(-y);} +} + +int64 SYSTEM_MOD(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x % y;} + else {return (y+1) + ((x-1) % (-y));} + else + if (y >= 0) {return (y-1) - ((-x-1) % y);} + else {return -((-x) % (-y));} +} + void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) { @@ -57,19 +80,6 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) } } -LONGINT SYSTEM_DIV(uint64 x, uint64 y) -{ if ((int64) x >= 0) return (x / y); - else return -((y - 1 - x) / y); -} - -LONGINT SYSTEM_MOD(uint64 x, uint64 y) -{ uint64 m; - if ((int64) x >= 0) return (x % y); - else { m = (-x) % y; - if (m != 0) return (y - m); else return 0; - } -} - LONGINT SYSTEM_ENTIER(double x) { LONGINT y; diff --git a/bootstrap/unix-88/SYSTEM.h b/bootstrap/unix-88/SYSTEM.h index 6fc57309..168b0beb 100644 --- a/bootstrap/unix-88/SYSTEM.h +++ b/bootstrap/unix-88/SYSTEM.h @@ -2,9 +2,17 @@ #define SYSTEM__h +// 64 bit system detection + +#if (__SIZEOF_POINTER__ == 8) || defined (_LP64) || defined(__LP64__) || defined(_WIN64) + #define __o_64 +#endif + +// Temporary while bootstrapping and clearing up SYSTEM.c. + #ifndef LONGINT - #if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) + #if defined (__o_64) #define INTEGER int32 #define LONGINT int64 #define SET uint64 @@ -22,14 +30,17 @@ // Declare memcpy in a way compatible with C compilers intrinsic // built in implementations. -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) +#if defined (__o_64) #if defined(_WIN64) typedef unsigned long long size_t; +// typedef long long address; #else typedef unsigned long size_t; +// typedef long address; #endif #else typedef unsigned int size_t; +//typedef int address; #endif #define _SIZE_T_DECLARED // For FreeBSD @@ -40,14 +51,14 @@ void *memcpy(void *dest, const void *source, size_t size); // Declare fixed size versions of basic intger types -#if (__SIZEOF_POINTER__ < 8) || defined(_WIN64) - // ILP32 or LLP64 - typedef long long int64; - typedef unsigned long long uint64; -#else +#if defined (__o_64) && !defined(_WIN64) // LP64 typedef long int64; typedef unsigned long uint64; +#else + // ILP32 or LLP64 + typedef long long int64; + typedef unsigned long long uint64; #endif typedef int int32; @@ -59,7 +70,14 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#define address size_t + +// 'address' is a synonym for an int32 of pointer size + +#if defined (__o_64) + #define address int64 +#else + #define address int32 +#endif // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. @@ -103,18 +121,40 @@ extern address Platform_OSAllocate (address size); extern void Platform_OSFree (address addr); +// Assertions and Halts + +extern void Platform_Halt(LONGINT x); +extern void Platform_AssertFail(LONGINT x); + +#define __HALT(x) Platform_Halt(x) +#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) + + +// Index checking + +static inline int64 __XF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-2);} return i;} +#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) + + +// Range checking, and checked SHORT and CHR functions + +static inline int64 __RF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-8);} return i;} +#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) +#define __SHORT(x, ub) ((int)((uLONGINT)(x)+(ub)<(ub)+(ub)?(x):(__HALT(-8),0))) +#define __SHORTF(x, ub) ((int)(__RF((x)+(ub),(ub)+(ub))-(ub))) +#define __CHR(x) ((CHAR)__R(x, 256)) +#define __CHRF(x) ((CHAR)__RF(x, 256)) + + + // Run time system routines in SYSTEM.c -extern int64 SYSTEM_XCHK (uint64 i, uint64 ub); -extern int64 SYSTEM_RCHK (uint64 i, uint64 ub); -extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n); + extern LONGINT SYSTEM_ABS (LONGINT i); extern double SYSTEM_ABSD (double i); extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0); extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)()); extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()); -extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); -extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); @@ -131,7 +171,7 @@ extern LONGINT SYSTEM_ENTIER (double x); // String comparison -static int __str_cmp(CHAR *x, CHAR *y){ +static inline int __str_cmp(CHAR *x, CHAR *y){ LONGINT i = 0; CHAR ch1, ch2; do {ch1 = x[i]; ch2 = y[i]; i++; @@ -152,21 +192,12 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __DEL(x) Platform_OSFree((address)x) -// Index and range checks - -#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((uint64)(i), (uint64)(ub)) - -#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((uint64)(i),(uint64)(ub)) - - /* SYSTEM ops */ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(address)(a) +#define __GET(a, x, t) x=*(t*)(address)(a) #define __PUT(a, x, t) *(t*)(address)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) @@ -177,21 +208,27 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __ROTR(x, n, t) ((t)((u##t)(x)>>(n)|(u##t)(x)<<(8*sizeof(t)-(n)))) #define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASHL(x, n) ((int64)(x)<<(n)) +#define __ASHR(x, n) ((int64)(x)>>(n)) #define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) -#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) +static inline int64 SYSTEM_ASH(int64 x, int64 n) {return __ASH(x,n);} +#define __ASHF(x, n) SYSTEM_ASH((int64)(x), (int64)(n)) #define __BIT(x, n) (*(uint64*)(x)>>(n)&1) #define __MOVE(s, d, n) memcpy((char*)(address)(d),(char*)(address)(s),n) -#define __SHORT(x, y) ((int)((uLONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0))) -#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y))) -#define __CHR(x) ((CHAR)__R(x, 256)) -#define __CHRF(x) ((CHAR)__RF(x, 256)) -#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y))) -#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y)) -#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y)) -#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y)) + + +extern int64 SYSTEM_DIV(int64 x, int64 y); +#define __DIVF(x, y) SYSTEM_DIV(x, y) +#define __DIV(x, y) (((x)>0 && (y)>0) ? (x)/(y) : __DIVF(x, y)) + + +extern int64 SYSTEM_MOD(int64 x, int64 y); +#define __MODF(x, y) SYSTEM_MOD(x, y) +#define __MOD(x, y) (((x)>0 && (y)>0) ? (x)%(y) : __MODF(x, y)) + + + #define __ENTIER(x) SYSTEM_ENTIER(x) #define __ABS(x) (((x)<0)?-(x):(x)) #define __ABSF(x) SYSTEM_ABS((LONGINT)(x)) @@ -244,15 +281,6 @@ extern void Heap_FINALL(); #define __FINI Heap_FINALL(); return 0 -// Assertions and Halts - -extern void Platform_Halt(LONGINT x); -extern void Platform_AssertFail(LONGINT x); - -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) - - // Memory allocation extern SYSTEM_PTR Heap_NEWBLK (address size); diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 39f247ba..d4ecf06e 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index 2c6a801d..b664568e 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index a78b77bb..b3c1a3bf 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index 7156eb22..116ee5e3 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/Vishap.c b/bootstrap/unix-88/Vishap.c index 46a95ea9..a04ca149 100644 --- a/bootstrap/unix-88/Vishap.c +++ b/bootstrap/unix-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkamSf */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/errors.c b/bootstrap/unix-88/errors.c index 9c9ed747..5dba1a33 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/errors.h b/bootstrap/unix-88/errors.h index bf0e9564..9d5bbe45 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index c3dc490a..1080b9a3 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 @@ -64,7 +64,7 @@ void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len) { CHAR cmd[1023]; __DUP(moduleName, moduleName__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); @@ -77,7 +77,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati { CHAR cmd[1023]; __DUP(additionalopts, additionalopts__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append((CHAR*)" ", 2, (void*)cmd, 1023); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index c5d5c772..8bdd3b71 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/vt100.c b/bootstrap/unix-88/vt100.c index fac0e0ba..3efc2842 100644 --- a/bootstrap/unix-88/vt100.c +++ b/bootstrap/unix-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/unix-88/vt100.h b/bootstrap/unix-88/vt100.h index c2ebcd84..71738164 100644 --- a/bootstrap/unix-88/vt100.h +++ b/bootstrap/unix-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index 115f8dec..5736ed9f 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/06] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/11] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index 84e8427b..31877f12 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Console.c b/bootstrap/windows-48/Console.c index 0b87cb07..111663dc 100644 --- a/bootstrap/windows-48/Console.c +++ b/bootstrap/windows-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Console.h b/bootstrap/windows-48/Console.h index e9913d2d..78586a68 100644 --- a/bootstrap/windows-48/Console.h +++ b/bootstrap/windows-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 930aa8c9..b50a99c2 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index 55b2a130..54236cf4 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index 2bbe63b2..58be6181 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #define INTEGER int16 #define LONGINT int32 @@ -353,7 +353,7 @@ static void Heap_Mark (address q) tag = tagbits + 4; for (;;) { __GET(tag, offset, address); - if (__BIT((address)&offset, 31)) { + if (offset < 0) { __PUT(q - 4, (tag + offset) + 1, address); if (p == 0) { break; diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index 6694ef70..827a3a7c 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index e31876fb..66a8c776 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 4bd4082d..02abd713 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index 0a1a9f63..8d44024a 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index 5ffa3869..5aaa8469 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 5666c7cd..1122a8d0 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index e1fc08ec..1a9ad61f 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 461b5b85..e6d709e7 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index c60f6f98..c5192f5b 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 1ab60658..6e2d4cd0 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index ce85af11..de48c5ba 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 3a1c4787..9b3bf8f0 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index 512cfa75..8689aa3b 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index 1983daf5..0d16f8ec 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index d3b24cc6..b9e46b1a 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index a62894dd..e36e3be5 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index b10704dc..c692efd8 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index bdf72323..777ee3b8 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index d1466be1..587135b3 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index 5f3d11a5..c9e8e867 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index cf931556..bd36f8d6 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/SYSTEM.c b/bootstrap/windows-48/SYSTEM.c index 821a6096..d7603f8e 100644 --- a/bootstrap/windows-48/SYSTEM.c +++ b/bootstrap/windows-48/SYSTEM.c @@ -21,11 +21,34 @@ // Procedure verions of SYSTEM.H versions used when a multiply accessed // parameter has side effects. -int64 SYSTEM_XCHK(uint64 i, uint64 ub) {return __X(i, ub);} -int64 SYSTEM_RCHK(uint64 i, uint64 ub) {return __R(i, ub);} -LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);} -LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} -double SYSTEM_ABSD(double i) {return __ABS(i);} + + +LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} +double SYSTEM_ABSD(double i) {return __ABS(i);} + + +int64 SYSTEM_DIV(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x/y;} + else {return -((x-y-1)/(-y));} + else + if (y >= 0) {return -((y-x-1)/y);} + else {return (-x)/(-y);} +} + +int64 SYSTEM_MOD(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x % y;} + else {return (y+1) + ((x-1) % (-y));} + else + if (y >= 0) {return (y-1) - ((-x-1) % y);} + else {return -((-x) % (-y));} +} + void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) { @@ -57,19 +80,6 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) } } -LONGINT SYSTEM_DIV(uint64 x, uint64 y) -{ if ((int64) x >= 0) return (x / y); - else return -((y - 1 - x) / y); -} - -LONGINT SYSTEM_MOD(uint64 x, uint64 y) -{ uint64 m; - if ((int64) x >= 0) return (x % y); - else { m = (-x) % y; - if (m != 0) return (y - m); else return 0; - } -} - LONGINT SYSTEM_ENTIER(double x) { LONGINT y; diff --git a/bootstrap/windows-48/SYSTEM.h b/bootstrap/windows-48/SYSTEM.h index 6fc57309..168b0beb 100644 --- a/bootstrap/windows-48/SYSTEM.h +++ b/bootstrap/windows-48/SYSTEM.h @@ -2,9 +2,17 @@ #define SYSTEM__h +// 64 bit system detection + +#if (__SIZEOF_POINTER__ == 8) || defined (_LP64) || defined(__LP64__) || defined(_WIN64) + #define __o_64 +#endif + +// Temporary while bootstrapping and clearing up SYSTEM.c. + #ifndef LONGINT - #if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) + #if defined (__o_64) #define INTEGER int32 #define LONGINT int64 #define SET uint64 @@ -22,14 +30,17 @@ // Declare memcpy in a way compatible with C compilers intrinsic // built in implementations. -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) +#if defined (__o_64) #if defined(_WIN64) typedef unsigned long long size_t; +// typedef long long address; #else typedef unsigned long size_t; +// typedef long address; #endif #else typedef unsigned int size_t; +//typedef int address; #endif #define _SIZE_T_DECLARED // For FreeBSD @@ -40,14 +51,14 @@ void *memcpy(void *dest, const void *source, size_t size); // Declare fixed size versions of basic intger types -#if (__SIZEOF_POINTER__ < 8) || defined(_WIN64) - // ILP32 or LLP64 - typedef long long int64; - typedef unsigned long long uint64; -#else +#if defined (__o_64) && !defined(_WIN64) // LP64 typedef long int64; typedef unsigned long uint64; +#else + // ILP32 or LLP64 + typedef long long int64; + typedef unsigned long long uint64; #endif typedef int int32; @@ -59,7 +70,14 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#define address size_t + +// 'address' is a synonym for an int32 of pointer size + +#if defined (__o_64) + #define address int64 +#else + #define address int32 +#endif // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. @@ -103,18 +121,40 @@ extern address Platform_OSAllocate (address size); extern void Platform_OSFree (address addr); +// Assertions and Halts + +extern void Platform_Halt(LONGINT x); +extern void Platform_AssertFail(LONGINT x); + +#define __HALT(x) Platform_Halt(x) +#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) + + +// Index checking + +static inline int64 __XF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-2);} return i;} +#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) + + +// Range checking, and checked SHORT and CHR functions + +static inline int64 __RF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-8);} return i;} +#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) +#define __SHORT(x, ub) ((int)((uLONGINT)(x)+(ub)<(ub)+(ub)?(x):(__HALT(-8),0))) +#define __SHORTF(x, ub) ((int)(__RF((x)+(ub),(ub)+(ub))-(ub))) +#define __CHR(x) ((CHAR)__R(x, 256)) +#define __CHRF(x) ((CHAR)__RF(x, 256)) + + + // Run time system routines in SYSTEM.c -extern int64 SYSTEM_XCHK (uint64 i, uint64 ub); -extern int64 SYSTEM_RCHK (uint64 i, uint64 ub); -extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n); + extern LONGINT SYSTEM_ABS (LONGINT i); extern double SYSTEM_ABSD (double i); extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0); extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)()); extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()); -extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); -extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); @@ -131,7 +171,7 @@ extern LONGINT SYSTEM_ENTIER (double x); // String comparison -static int __str_cmp(CHAR *x, CHAR *y){ +static inline int __str_cmp(CHAR *x, CHAR *y){ LONGINT i = 0; CHAR ch1, ch2; do {ch1 = x[i]; ch2 = y[i]; i++; @@ -152,21 +192,12 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __DEL(x) Platform_OSFree((address)x) -// Index and range checks - -#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((uint64)(i), (uint64)(ub)) - -#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((uint64)(i),(uint64)(ub)) - - /* SYSTEM ops */ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(address)(a) +#define __GET(a, x, t) x=*(t*)(address)(a) #define __PUT(a, x, t) *(t*)(address)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) @@ -177,21 +208,27 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __ROTR(x, n, t) ((t)((u##t)(x)>>(n)|(u##t)(x)<<(8*sizeof(t)-(n)))) #define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASHL(x, n) ((int64)(x)<<(n)) +#define __ASHR(x, n) ((int64)(x)>>(n)) #define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) -#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) +static inline int64 SYSTEM_ASH(int64 x, int64 n) {return __ASH(x,n);} +#define __ASHF(x, n) SYSTEM_ASH((int64)(x), (int64)(n)) #define __BIT(x, n) (*(uint64*)(x)>>(n)&1) #define __MOVE(s, d, n) memcpy((char*)(address)(d),(char*)(address)(s),n) -#define __SHORT(x, y) ((int)((uLONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0))) -#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y))) -#define __CHR(x) ((CHAR)__R(x, 256)) -#define __CHRF(x) ((CHAR)__RF(x, 256)) -#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y))) -#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y)) -#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y)) -#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y)) + + +extern int64 SYSTEM_DIV(int64 x, int64 y); +#define __DIVF(x, y) SYSTEM_DIV(x, y) +#define __DIV(x, y) (((x)>0 && (y)>0) ? (x)/(y) : __DIVF(x, y)) + + +extern int64 SYSTEM_MOD(int64 x, int64 y); +#define __MODF(x, y) SYSTEM_MOD(x, y) +#define __MOD(x, y) (((x)>0 && (y)>0) ? (x)%(y) : __MODF(x, y)) + + + #define __ENTIER(x) SYSTEM_ENTIER(x) #define __ABS(x) (((x)<0)?-(x):(x)) #define __ABSF(x) SYSTEM_ABS((LONGINT)(x)) @@ -244,15 +281,6 @@ extern void Heap_FINALL(); #define __FINI Heap_FINALL(); return 0 -// Assertions and Halts - -extern void Platform_Halt(LONGINT x); -extern void Platform_AssertFail(LONGINT x); - -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) - - // Memory allocation extern SYSTEM_PTR Heap_NEWBLK (address size); diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 7e1a6845..af7a679b 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 59076121..d145001a 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index a4267893..c40b975f 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index 2238689d..0aac4cc8 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/Vishap.c b/bootstrap/windows-48/Vishap.c index 549268e2..b289dfa6 100644 --- a/bootstrap/windows-48/Vishap.c +++ b/bootstrap/windows-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkamSf */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/errors.c b/bootstrap/windows-48/errors.c index a2f7cf75..76fa35bf 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/errors.h b/bootstrap/windows-48/errors.h index bf0e9564..9d5bbe45 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index 27ef9f8f..3dbc28ba 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 @@ -64,7 +64,7 @@ void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len) { CHAR cmd[1023]; __DUP(moduleName, moduleName__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); @@ -77,7 +77,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati { CHAR cmd[1023]; __DUP(additionalopts, additionalopts__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append((CHAR*)" ", 2, (void*)cmd, 1023); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index c5d5c772..8bdd3b71 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/vt100.c b/bootstrap/windows-48/vt100.c index 912e5e83..2e236578 100644 --- a/bootstrap/windows-48/vt100.c +++ b/bootstrap/windows-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int16 #define LONGINT int32 diff --git a/bootstrap/windows-48/vt100.h b/bootstrap/windows-48/vt100.h index 36c0bc7e..0eae5799 100644 --- a/bootstrap/windows-48/vt100.h +++ b/bootstrap/windows-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index cfce02b8..b5ee44a5 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 @@ -18,6 +18,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/06] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/11] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index 84e8427b..31877f12 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Console.c b/bootstrap/windows-88/Console.c index c9058a13..e24d169a 100644 --- a/bootstrap/windows-88/Console.c +++ b/bootstrap/windows-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Console.h b/bootstrap/windows-88/Console.h index 1f1182fd..1d06d0fe 100644 --- a/bootstrap/windows-88/Console.h +++ b/bootstrap/windows-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Console__h #define Console__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index 61842215..0f262baa 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 2c581e47..58cb3b1e 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 1fe3ce13..d0175b87 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #define INTEGER int32 #define LONGINT int64 @@ -353,7 +353,7 @@ static void Heap_Mark (address q) tag = tagbits + 8; for (;;) { __GET(tag, offset, address); - if (__BIT((address)&offset, 63)) { + if (offset < 0) { __PUT(q - 8, (tag + offset) + 1, address); if (p == 0) { break; diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index def46dcf..fabb54ef 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tskSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index 9d93e3d2..53bf2640 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index f9e49aa7..8e54ce53 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 11b9a1a9..f22a9ab5 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index c3c5c1e8..aa26ea1c 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index e971762c..8916c00b 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index a218490a..71b95812 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 389fda93..b15aba16 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index 51042a0e..d23aed25 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index 9ab86b22..3f77df4f 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index ce85af11..de48c5ba 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 8e53d027..491faa22 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index ffbc5084..3937b6f6 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin tspkaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index bd27c789..da8bab08 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index 583c31ff..668c3d79 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 2d81dd31..52fc9966 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index b10704dc..c692efd8 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index dda7a46a..b862e3ee 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index 472cf2f1..d74f41bc 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index 0b5761ee..185aec0b 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index dfc56cef..a2fc2612 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/SYSTEM.c b/bootstrap/windows-88/SYSTEM.c index 821a6096..d7603f8e 100644 --- a/bootstrap/windows-88/SYSTEM.c +++ b/bootstrap/windows-88/SYSTEM.c @@ -21,11 +21,34 @@ // Procedure verions of SYSTEM.H versions used when a multiply accessed // parameter has side effects. -int64 SYSTEM_XCHK(uint64 i, uint64 ub) {return __X(i, ub);} -int64 SYSTEM_RCHK(uint64 i, uint64 ub) {return __R(i, ub);} -LONGINT SYSTEM_ASH (LONGINT i, LONGINT n) {return __ASH(i, n);} -LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} -double SYSTEM_ABSD(double i) {return __ABS(i);} + + +LONGINT SYSTEM_ABS (LONGINT i) {return __ABS(i);} +double SYSTEM_ABSD(double i) {return __ABS(i);} + + +int64 SYSTEM_DIV(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x/y;} + else {return -((x-y-1)/(-y));} + else + if (y >= 0) {return -((y-x-1)/y);} + else {return (-x)/(-y);} +} + +int64 SYSTEM_MOD(int64 x, int64 y) +{ + if (x == 0) return 0; + if (x >= 0) + if (y >= 0) {return x % y;} + else {return (y+1) + ((x-1) % (-y));} + else + if (y >= 0) {return (y-1) - ((-x-1) % y);} + else {return -((-x) % (-y));} +} + void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) { @@ -57,19 +80,6 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) } } -LONGINT SYSTEM_DIV(uint64 x, uint64 y) -{ if ((int64) x >= 0) return (x / y); - else return -((y - 1 - x) / y); -} - -LONGINT SYSTEM_MOD(uint64 x, uint64 y) -{ uint64 m; - if ((int64) x >= 0) return (x % y); - else { m = (-x) % y; - if (m != 0) return (y - m); else return 0; - } -} - LONGINT SYSTEM_ENTIER(double x) { LONGINT y; diff --git a/bootstrap/windows-88/SYSTEM.h b/bootstrap/windows-88/SYSTEM.h index 6fc57309..168b0beb 100644 --- a/bootstrap/windows-88/SYSTEM.h +++ b/bootstrap/windows-88/SYSTEM.h @@ -2,9 +2,17 @@ #define SYSTEM__h +// 64 bit system detection + +#if (__SIZEOF_POINTER__ == 8) || defined (_LP64) || defined(__LP64__) || defined(_WIN64) + #define __o_64 +#endif + +// Temporary while bootstrapping and clearing up SYSTEM.c. + #ifndef LONGINT - #if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) + #if defined (__o_64) #define INTEGER int32 #define LONGINT int64 #define SET uint64 @@ -22,14 +30,17 @@ // Declare memcpy in a way compatible with C compilers intrinsic // built in implementations. -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) +#if defined (__o_64) #if defined(_WIN64) typedef unsigned long long size_t; +// typedef long long address; #else typedef unsigned long size_t; +// typedef long address; #endif #else typedef unsigned int size_t; +//typedef int address; #endif #define _SIZE_T_DECLARED // For FreeBSD @@ -40,14 +51,14 @@ void *memcpy(void *dest, const void *source, size_t size); // Declare fixed size versions of basic intger types -#if (__SIZEOF_POINTER__ < 8) || defined(_WIN64) - // ILP32 or LLP64 - typedef long long int64; - typedef unsigned long long uint64; -#else +#if defined (__o_64) && !defined(_WIN64) // LP64 typedef long int64; typedef unsigned long uint64; +#else + // ILP32 or LLP64 + typedef long long int64; + typedef unsigned long long uint64; #endif typedef int int32; @@ -59,7 +70,14 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#define address size_t + +// 'address' is a synonym for an int32 of pointer size + +#if defined (__o_64) + #define address int64 +#else + #define address int32 +#endif // The compiler uses 'import' and 'export' which translate to 'extern' and // nothing respectively. @@ -103,18 +121,40 @@ extern address Platform_OSAllocate (address size); extern void Platform_OSFree (address addr); +// Assertions and Halts + +extern void Platform_Halt(LONGINT x); +extern void Platform_AssertFail(LONGINT x); + +#define __HALT(x) Platform_Halt(x) +#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) + + +// Index checking + +static inline int64 __XF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-2);} return i;} +#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) + + +// Range checking, and checked SHORT and CHR functions + +static inline int64 __RF(uint64 i, uint64 ub) {if (i >= ub) {__HALT(-8);} return i;} +#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) +#define __SHORT(x, ub) ((int)((uLONGINT)(x)+(ub)<(ub)+(ub)?(x):(__HALT(-8),0))) +#define __SHORTF(x, ub) ((int)(__RF((x)+(ub),(ub)+(ub))-(ub))) +#define __CHR(x) ((CHAR)__R(x, 256)) +#define __CHRF(x) ((CHAR)__RF(x, 256)) + + + // Run time system routines in SYSTEM.c -extern int64 SYSTEM_XCHK (uint64 i, uint64 ub); -extern int64 SYSTEM_RCHK (uint64 i, uint64 ub); -extern LONGINT SYSTEM_ASH (LONGINT i, LONGINT n); + extern LONGINT SYSTEM_ABS (LONGINT i); extern double SYSTEM_ABSD (double i); extern void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0); extern void SYSTEM_ENUMP (void *adr, LONGINT n, void (*P)()); extern void SYSTEM_ENUMR (void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()); -extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); -extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); @@ -131,7 +171,7 @@ extern LONGINT SYSTEM_ENTIER (double x); // String comparison -static int __str_cmp(CHAR *x, CHAR *y){ +static inline int __str_cmp(CHAR *x, CHAR *y){ LONGINT i = 0; CHAR ch1, ch2; do {ch1 = x[i]; ch2 = y[i]; i++; @@ -152,21 +192,12 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __DEL(x) Platform_OSFree((address)x) -// Index and range checks - -#define __X(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((uint64)(i), (uint64)(ub)) - -#define __R(i, ub) (((uint64)(i)<(uint64)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((uint64)(i),(uint64)(ub)) - - /* SYSTEM ops */ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(address)(a) +#define __GET(a, x, t) x=*(t*)(address)(a) #define __PUT(a, x, t) *(t*)(address)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) @@ -177,21 +208,27 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __ROTR(x, n, t) ((t)((u##t)(x)>>(n)|(u##t)(x)<<(8*sizeof(t)-(n)))) #define __ROT(x, n, t) ((n)>=0? __ROTL(x, n, t): __ROTR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASHL(x, n) ((int64)(x)<<(n)) +#define __ASHR(x, n) ((int64)(x)>>(n)) #define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) -#define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) +static inline int64 SYSTEM_ASH(int64 x, int64 n) {return __ASH(x,n);} +#define __ASHF(x, n) SYSTEM_ASH((int64)(x), (int64)(n)) #define __BIT(x, n) (*(uint64*)(x)>>(n)&1) #define __MOVE(s, d, n) memcpy((char*)(address)(d),(char*)(address)(s),n) -#define __SHORT(x, y) ((int)((uLONGINT)(x)+(y)<(y)+(y)?(x):(__HALT(-8),0))) -#define __SHORTF(x, y) ((int)(__RF((x)+(y),(y)+(y))-(y))) -#define __CHR(x) ((CHAR)__R(x, 256)) -#define __CHRF(x) ((CHAR)__RF(x, 256)) -#define __DIV(x, y) ((x)>=0?(x)/(y):-(((y)-1-(x))/(y))) -#define __DIVF(x, y) SYSTEM_DIV((LONGINT)(x),(LONGINT)(y)) -#define __MOD(x, y) ((x)>=0?(x)%(y):__MODF(x,y)) -#define __MODF(x, y) SYSTEM_MOD((LONGINT)(x),(LONGINT)(y)) + + +extern int64 SYSTEM_DIV(int64 x, int64 y); +#define __DIVF(x, y) SYSTEM_DIV(x, y) +#define __DIV(x, y) (((x)>0 && (y)>0) ? (x)/(y) : __DIVF(x, y)) + + +extern int64 SYSTEM_MOD(int64 x, int64 y); +#define __MODF(x, y) SYSTEM_MOD(x, y) +#define __MOD(x, y) (((x)>0 && (y)>0) ? (x)%(y) : __MODF(x, y)) + + + #define __ENTIER(x) SYSTEM_ENTIER(x) #define __ABS(x) (((x)<0)?-(x):(x)) #define __ABSF(x) SYSTEM_ABS((LONGINT)(x)) @@ -244,15 +281,6 @@ extern void Heap_FINALL(); #define __FINI Heap_FINALL(); return 0 -// Assertions and Halts - -extern void Platform_Halt(LONGINT x); -extern void Platform_AssertFail(LONGINT x); - -#define __HALT(x) Platform_Halt(x) -#define __ASSERT(cond, x) if (!(cond)) Platform_AssertFail((LONGINT)(x)) - - // Memory allocation extern SYSTEM_PTR Heap_NEWBLK (address size); diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 39f247ba..d4ecf06e 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index 2c6a801d..b664568e 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index a78b77bb..b3c1a3bf 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index 7156eb22..116ee5e3 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/Vishap.c b/bootstrap/windows-88/Vishap.c index 46a95ea9..a04ca149 100644 --- a/bootstrap/windows-88/Vishap.c +++ b/bootstrap/windows-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkamSf */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/errors.c b/bootstrap/windows-88/errors.c index 9c9ed747..5dba1a33 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/errors.h b/bootstrap/windows-88/errors.h index bf0e9564..9d5bbe45 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index c3dc490a..1080b9a3 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 @@ -64,7 +64,7 @@ void extTools_Assemble (CHAR *moduleName, LONGINT moduleName__len) { CHAR cmd[1023]; __DUP(moduleName, moduleName__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append((CHAR*)"-c ", 4, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); @@ -77,7 +77,7 @@ void extTools_LinkMain (CHAR *moduleName, LONGINT moduleName__len, BOOLEAN stati { CHAR cmd[1023]; __DUP(additionalopts, additionalopts__len, CHAR); - __MOVE("gcc -g", cmd, 7); + __MOVE("gcc -g -O1", cmd, 11); Strings_Append((CHAR*)" ", 2, (void*)cmd, 1023); Strings_Append(extTools_compilationOptions, 1023, (void*)cmd, 1023); Strings_Append(moduleName, moduleName__len, (void*)cmd, 1023); diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index c5d5c772..8bdd3b71 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/vt100.c b/bootstrap/windows-88/vt100.c index fac0e0ba..3efc2842 100644 --- a/bootstrap/windows-88/vt100.c +++ b/bootstrap/windows-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #define INTEGER int32 #define LONGINT int64 diff --git a/bootstrap/windows-88/vt100.h b/bootstrap/windows-88/vt100.h index c2ebcd84..71738164 100644 --- a/bootstrap/windows-88/vt100.h +++ b/bootstrap/windows-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/06] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/11] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h