diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index fb7df026..194e9da8 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" @@ -13,6 +13,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/01] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/02] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index 61b33bc5..fbca10e0 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8c9c6910..baf934fc 100644 --- a/bootstrap/unix-44/Console.c +++ b/bootstrap/unix-44/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Platform.h" diff --git a/bootstrap/unix-44/Console.h b/bootstrap/unix-44/Console.h index 16287a76..3823dacc 100644 --- a/bootstrap/unix-44/Console.h +++ b/bootstrap/unix-44/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 3c6594af..c971536e 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index d84672d4..f5c55397 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a252264a..2315b64e 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tskSfF */ #include "SYSTEM.h" struct Heap__1 { @@ -100,7 +100,7 @@ export void Heap_Unlock (void); extern void *Heap__init(); extern LONGINT Platform_MainStackFrame; -extern LONGINT Platform_OSAllocate(LONGINT size); +extern uintptr Platform_OSAllocate(uintptr size); #define Heap_FetchAddress(pointer) (LONGINT)(SYSTEM_ADRINT)(*((void**)((SYSTEM_ADRINT)pointer))) #define Heap_HeapModuleInit() Heap__init() #define Heap_OSAllocate(size) Platform_OSAllocate(size) diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index a89f18fc..83733c20 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] 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 7969f68f..e7006b76 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Console.h" #include "Heap.h" diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 8b271308..632138b5 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 bc74dd1d..fa8f98fe 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index a4ccc86e..8b2baa5f 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 08469d42..93d60530 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "OPM.h" @@ -200,8 +200,12 @@ void OPC_Ident (OPT_Object obj) } } } else if ((mode == 5 && obj->typ->form == 4)) { - OPM_WriteString((CHAR*)"int", 4); - OPM_WriteInt(__ASHL(obj->typ->size, 3)); + if (obj->typ == OPT_pinttyp || obj->typ == OPT_ainttyp) { + OPM_WriteString((CHAR*)"uintptr", 8); + } else { + OPM_WriteString((CHAR*)"int", 4); + OPM_WriteInt(__ASHL(obj->typ->size, 3)); + } } else { if (mode != 5 || obj->linkadr != 2) { if (mode == 13) { @@ -215,7 +219,7 @@ void OPC_Ident (OPT_Object obj) OPM_WriteStringVar((void*)OPM_modName, 32); } OPM_Write('_'); - } else if ((obj == OPT_sysptrtyp->strobj || obj == OPT_ainttyp->strobj) || obj == OPT_bytetyp->strobj) { + } else if (obj == OPT_sysptrtyp->strobj || obj == OPT_bytetyp->strobj) { OPM_WriteString((CHAR*)"SYSTEM_", 8); } OPM_WriteStringVar((void*)obj->name, 256); @@ -2080,6 +2084,7 @@ static void OPC_InitKeywords (void) Enter__49((CHAR*)"struct", 7); Enter__49((CHAR*)"switch", 7); Enter__49((CHAR*)"typedef", 8); + Enter__49((CHAR*)"uintptr", 8); Enter__49((CHAR*)"uint16", 7); Enter__49((CHAR*)"uint32", 7); Enter__49((CHAR*)"uint64", 7); diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 05c34fcc..78a60ed9 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8bf863b3..19ad29af 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index 36eb4165..44fe5275 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a366ef24..b0cd8613 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPB.h" #include "OPM.h" diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index 8bed9493..423013a4 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 2b29372f..36b37592 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index e40119f7..dec9c209 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 7fbad791..16dfc5b1 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" @@ -83,7 +83,7 @@ typedef export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; -export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export int8 OPT_nofGmod; export OPT_Object OPT_GlbMod[64]; export OPS_Name OPT_SelfName; @@ -1767,6 +1767,7 @@ static void EnumPtrs(void (*P)(void*)) P(OPT_sinttyp); P(OPT_inttyp); P(OPT_linttyp); + P(OPT_pinttyp); P(OPT_ainttyp); P(OPT_int8typ); P(OPT_int16typ); @@ -1849,6 +1850,7 @@ export void *OPT__init(void) OPT_InitStruct(&OPT_niltyp, 9); OPT_EnterTyp((CHAR*)"BYTE", 1, OPM_ByteSize, &OPT_bytetyp); OPT_EnterTyp((CHAR*)"PTR", 11, OPM_PointerSize, &OPT_sysptrtyp); + OPT_EnterTyp((CHAR*)"UINTPTR", 4, OPM_PointerSize, &OPT_pinttyp); OPT_EnterTyp((CHAR*)"ADRINT", 4, OPM_PointerSize, &OPT_ainttyp); OPT_EnterTyp((CHAR*)"INT8", 4, 1, &OPT_int8typ); OPT_EnterTyp((CHAR*)"INT16", 4, 2, &OPT_int16typ); diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index 480267cc..c290d3de 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h @@ -67,7 +67,7 @@ typedef import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; -import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import int8 OPT_nofGmod; import OPT_Object OPT_GlbMod[64]; import OPS_Name OPT_SelfName; diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 5ef539df..aeef6224 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPC.h" #include "OPM.h" @@ -285,6 +285,7 @@ void OPV_AdrAndSize (OPT_Object topScope) OPT_realtyp->strobj->linkadr = 2; OPT_inttyp->strobj->linkadr = 2; OPT_linttyp->strobj->linkadr = 2; + OPT_pinttyp->strobj->linkadr = 2; OPT_ainttyp->strobj->linkadr = 2; OPT_int8typ->strobj->linkadr = 2; OPT_int16typ->strobj->linkadr = 2; diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index 06bc39f1..8fd772f8 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c247eb06..f8dc8de8 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef @@ -26,11 +26,12 @@ typedef export BOOLEAN Platform_LittleEndian; -export int32 Platform_MainStackFrame, Platform_HaltCode; +export uintptr Platform_MainStackFrame; +export int32 Platform_HaltCode; export int16 Platform_PID; export CHAR Platform_CWD[256]; export int16 Platform_ArgCount; -export int32 Platform_ArgVector; +export uintptr Platform_ArgVector; static Platform_HaltProcedure Platform_HaltHandler; static int32 Platform_TimeStart; export int16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd; @@ -62,8 +63,8 @@ export void Platform_Init (int16 argc, int32 argvadr); export void Platform_MTimeAsClock (Platform_FileIdentity i, int32 *t, int32 *d); export int16 Platform_New (CHAR *n, LONGINT n__len, int32 *h); export BOOLEAN Platform_NoSuchDirectory (int16 e); -export int32 Platform_OSAllocate (int32 size); -export void Platform_OSFree (int32 address); +export uintptr Platform_OSAllocate (uintptr size); +export void Platform_OSFree (uintptr address); export int16 Platform_OldRO (CHAR *n, LONGINT n__len, int32 *h); export int16 Platform_OldRW (CHAR *n, LONGINT n__len, int32 *h); export int16 Platform_Read (int32 h, int32 p, int32 l, int32 *n); @@ -118,14 +119,14 @@ export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT #define Platform_EXDEV() EXDEV extern void Heap_InitHeap(); #define Platform_HeapInitHeap() Heap_InitHeap() -#define Platform_allocate(size) (LONGINT)(SYSTEM_ADRINT)((void*)malloc((size_t)size)) +#define Platform_allocate(size) (uintptr)((void*)malloc((size_t)size)) #define Platform_chdir(n, n__len) chdir((char*)n) #define Platform_closefile(fd) close(fd) #define Platform_err() errno #define Platform_errc(c) write(1, &c, 1) #define Platform_errstring(s, s__len) write(1, s, s__len-1) #define Platform_exit(code) exit(code) -#define Platform_free(address) free((void*)(SYSTEM_ADRINT)address) +#define Platform_free(address) free((void*)address) #define Platform_fstat(fd) fstat(fd, &s) #define Platform_fsync(fd) fsync(fd) #define Platform_ftruncate(fd, l) ftruncate(fd, l) @@ -212,14 +213,14 @@ BOOLEAN Platform_ConnectionFailed (int16 e) return _o_result; } -int32 Platform_OSAllocate (int32 size) +uintptr Platform_OSAllocate (uintptr size) { - int32 _o_result; + uintptr _o_result; _o_result = Platform_allocate(size); return _o_result; } -void Platform_OSFree (int32 address) +void Platform_OSFree (uintptr address) { Platform_free(address); } @@ -262,7 +263,7 @@ void Platform_GetArg (int16 n, CHAR *val, LONGINT val__len) { Platform_ArgVec av = NIL; if (n < Platform_ArgCount) { - av = (Platform_ArgVec)(SYSTEM_ADRINT)Platform_ArgVector; + av = __VAL(Platform_ArgVec, Platform_ArgVector); __COPY(*(*av)[__X(n, 1024)], val, val__len); } } diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index 129004fd..a4c001f3 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h @@ -18,11 +18,12 @@ typedef import BOOLEAN Platform_LittleEndian; -import int32 Platform_MainStackFrame, Platform_HaltCode; +import uintptr Platform_MainStackFrame; +import int32 Platform_HaltCode; import int16 Platform_PID; import CHAR Platform_CWD[256]; import int16 Platform_ArgCount; -import int32 Platform_ArgVector; +import uintptr Platform_ArgVector; import int16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd; import CHAR Platform_nl[3]; @@ -51,8 +52,8 @@ import void Platform_Init (int16 argc, int32 argvadr); import void Platform_MTimeAsClock (Platform_FileIdentity i, int32 *t, int32 *d); import int16 Platform_New (CHAR *n, LONGINT n__len, int32 *h); import BOOLEAN Platform_NoSuchDirectory (int16 e); -import int32 Platform_OSAllocate (int32 size); -import void Platform_OSFree (int32 address); +import uintptr Platform_OSAllocate (uintptr size); +import void Platform_OSFree (uintptr address); import int16 Platform_OldRO (CHAR *n, LONGINT n__len, int32 *h); import int16 Platform_OldRW (CHAR *n, LONGINT n__len, int32 *h); import int16 Platform_Read (int32 h, int32 p, int32 l, int32 *n); diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 4b500170..4e271371 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index a1191c0b..b1e62271 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 9bc6b756..16681ab8 100644 --- a/bootstrap/unix-44/SYSTEM.c +++ b/bootstrap/unix-44/SYSTEM.c @@ -18,8 +18,11 @@ #include -LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);} -LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);} +// 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);} @@ -35,7 +38,7 @@ void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)()) { while (n > 0) { - P((LONGINT)(SYSTEM_ADRINT)(*((void**)(adr)))); + P((uintptr)(*((void**)(adr)))); adr = ((void**)adr) + 1; n--; } @@ -48,20 +51,20 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) while (n > 0) { t = typ; off = *t; - while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;} + while (off >= 0) {P(*(uintptr*)((char*)adr+off)); t++; off = *t;} adr = ((char*)adr) + size; n--; } } -LONGINT SYSTEM_DIV(uLONGINT x, uLONGINT y) -{ if ((LONGINT) x >= 0) return (x / y); +LONGINT SYSTEM_DIV(uint64 x, uint64 y) +{ if ((int64) x >= 0) return (x / y); else return -((y - 1 - x) / y); } -LONGINT SYSTEM_MOD(uLONGINT x, uLONGINT y) -{ uLONGINT m; - if ((LONGINT) x >= 0) return (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; } @@ -106,7 +109,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, else if (typ == (LONGINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[-1]; + p = (LONGINT*)(uintptr)x[-1]; p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */ while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;} @@ -119,7 +122,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */ nptr = nofelems * nofptrs; /* total number of pointers */ x = Heap_NEWBLK(size + nptr * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[- 1]; + p = (LONGINT*)(uintptr)x[- 1]; p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nptr - 1; n = 0; off = dataoff; while (n < nofelems) {i = 0; @@ -155,7 +158,7 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler // (Ignore other signals) } - void SystemSetHandler(int s, SYSTEM_ADRINT h) { + void SystemSetHandler(int s, uintptr h) { if (s >= 2 && s <= 4) { int needtosetsystemhandler = handler[s-2] == 0; handler[s-2] = (SystemSignalHandler)h; @@ -194,12 +197,12 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler } } - void SystemSetInterruptHandler(SYSTEM_ADRINT h) { + void SystemSetInterruptHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemInterruptHandler = (SystemSignalHandler)h; } - void SystemSetQuitHandler(SYSTEM_ADRINT h) { + void SystemSetQuitHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemQuitHandler = (SystemSignalHandler)h; } diff --git a/bootstrap/unix-44/SYSTEM.h b/bootstrap/unix-44/SYSTEM.h index 2cab2429..c83f69f1 100644 --- a/bootstrap/unix-44/SYSTEM.h +++ b/bootstrap/unix-44/SYSTEM.h @@ -1,6 +1,27 @@ #ifndef SYSTEM__h #define SYSTEM__h +// Declare memcpy in a way compatible with C compilers intrinsic +// built in implementations. + +#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) + #if defined(_WIN64) + typedef unsigned long long size_t; + #else + typedef unsigned long size_t; + #endif +#else + typedef unsigned int size_t; +#endif + +#define _SIZE_T_DECLARED // For FreeBSD +#define _SIZE_T_DEFINED_ // For OpenBSD + +void *memcpy(void *dest, const void *source, size_t size); + + +// Declare fixed size versions of basic intger types + #if defined(_WIN64) typedef long long int64; typedef unsigned long long uint64; @@ -18,20 +39,7 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) - #if defined(_WIN64) - typedef unsigned long long size_t; - #else - typedef unsigned long size_t; - #endif -#else - typedef unsigned int size_t; -#endif - -#define _SIZE_T_DECLARED // For FreeBSD -#define _SIZE_T_DEFINED_ // For OpenBSD - -void *memcpy(void *dest, const void *source, size_t size); +#define uintptr size_t // The compiler uses 'import' and 'export' which translate to 'extern' and @@ -46,7 +54,7 @@ void *memcpy(void *dest, const void *source, size_t size); #define NIL ((void*)0) #define __MAXEXT 16 -#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type +#define POINTER__typ ((uintptr*)(1)) // not NIL and not a valid type // Oberon types @@ -60,7 +68,7 @@ typedef float REAL; typedef double LONGREAL; typedef void* SYSTEM_PTR; -typedef size_t SYSTEM_ADRINT; +typedef uintptr SYSTEM_ADRINT; // For 32 bit builds, the size of LONGINT depends on a make option: @@ -68,18 +76,19 @@ typedef size_t SYSTEM_ADRINT; #if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64) typedef int32 INTEGER; typedef int64 LONGINT; - typedef uint64 uLONGINT; + typedef uint64 SET; + typedef uint64 uSET; #else typedef int16 INTEGER; typedef int32 LONGINT; - typedef uint32 uLONGINT; + typedef uint32 SET; + typedef uint32 uSET; #endif -// Unsigned variants are for use by shift and rotate macros. -typedef uLONGINT SET; -typedef uLONGINT uSET; +// Temporary defs while bootstrapping +#define uLONGINT uint64 @@ -90,32 +99,32 @@ typedef uLONGINT uSET; // OS Memory allocation interfaces are in PlatformXXX.Mod -extern LONGINT Platform_OSAllocate (LONGINT size); -extern void Platform_OSFree (LONGINT addr); +extern uintptr Platform_OSAllocate (uintptr size); +extern void Platform_OSFree (uintptr addr); // Run time system routines in SYSTEM.c -extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub); -extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub); +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 (uLONGINT x, uLONGINT y); -extern LONGINT SYSTEM_MOD (uLONGINT x, uLONGINT y); +extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); +extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); // Signal handling in SYSTEM.c #ifndef _WIN32 - extern void SystemSetHandler(int s, SYSTEM_ADRINT h); + extern void SystemSetHandler(int s, uintptr h); #else - extern void SystemSetInterruptHandler(SYSTEM_ADRINT h); - extern void SystemSetQuitHandler (SYSTEM_ADRINT h); + extern void SystemSetInterruptHandler(uintptr h); + extern void SystemSetQuitHandler (uintptr h); #endif @@ -138,11 +147,18 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \ while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;} -#define __DUP(x, l, t) x=(void*)memcpy((void*)(SYSTEM_ADRINT)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) +#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) #define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t)) -#define __DEL(x) Platform_OSFree((LONGINT)(SYSTEM_ADRINT)x) +#define __DEL(x) Platform_OSFree((LONGINT)(uintptr)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 */ @@ -150,24 +166,24 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(SYSTEM_ADRINT)(a) -#define __PUT(a, x, t) *(t*)(SYSTEM_ADRINT)(a)=x +#define __GET(a, x, t) x= *(t*)(uintptr)(a) +#define __PUT(a, x, t) *(t*)(uintptr)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) #define __LSHR(x, n, t) ((t)((u##t)(x)>>(n))) #define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) -#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) - #define __ROTL(x, n, t) ((t)((u##t)(x)<<(n)|(u##t)(x)>>(8*sizeof(t)-(n)))) #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 __BIT(x, n) (*(uLONGINT*)(x)>>(n)&1) -#define __MOVE(s, d, n) memcpy((char*)(SYSTEM_ADRINT)(d),(char*)(SYSTEM_ADRINT)(s),n) +#define __ASHL(x, n) ((LONGINT)(x)<<(n)) +#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) #define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) + +#define __BIT(x, n) (*(uint64*)(x)>>(n)&1) +#define __MOVE(s, d, n) memcpy((char*)(uintptr)(d),(char*)(uintptr)(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)) @@ -191,10 +207,6 @@ static int __str_cmp(CHAR *x, CHAR *y){ // Runtime checks -#define __X(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub)) -#define __R(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub)) #define __RETCHK __retchk: __HALT(-3); return 0; #define __CASECHK __HALT(-4) #define __WITHCHK __HALT(-7) @@ -227,7 +239,7 @@ extern void Heap_INCREF(); extern void Platform_Init(INTEGER argc, LONGINT argv); extern void Heap_FINALL(); -#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(SYSTEM_ADRINT)&argv); +#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr)&argv); #define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum) #define __FINI Heap_FINALL(); return 0 @@ -248,7 +260,7 @@ extern SYSTEM_PTR Heap_NEWREC (LONGINT tag); extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len)) -#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(SYSTEM_ADRINT)t##__typ) +#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr)t##__typ) #define __NEWARR SYSTEM_NEWARR @@ -279,20 +291,20 @@ extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __INITYP(t, t0, level) \ t##__typ = (LONGINT*)&t##__desc.blksz; \ memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \ - t##__desc.basep[level] = (LONGINT)(SYSTEM_ADRINT)t##__typ; \ - t##__desc.module = (LONGINT)(SYSTEM_ADRINT)m; \ + t##__desc.basep[level] = (LONGINT)(uintptr)t##__typ; \ + t##__desc.module = (LONGINT)(uintptr)m; \ if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \ t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \ - Heap_REGTYP(m, (LONGINT)(SYSTEM_ADRINT)&t##__desc.next); \ + Heap_REGTYP(m, (LONGINT)(uintptr)&t##__desc.next); \ SYSTEM_INHERIT(t##__typ, t0##__typ) -#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(SYSTEM_ADRINT)typ##__typ) -#define __TYPEOF(p) ((LONGINT*)(SYSTEM_ADRINT)(*(((LONGINT*)(p))-1))) +#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr)typ##__typ) +#define __TYPEOF(p) ((LONGINT*)(uintptr)(*(((LONGINT*)(p))-1))) #define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level) // Oberon-2 type bound procedures support -#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(SYSTEM_ADRINT)proc -#define __SEND(typ, num, funtyp, parlist) ((funtyp)((SYSTEM_ADRINT)*(typ-(__TPROC0OFF+num))))parlist +#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr)proc +#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr)*(typ-(__TPROC0OFF+num))))parlist diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 6463db16..439a49e9 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 07051628..681fcf1c 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a736989a..4692859f 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Files.h" #include "Modules.h" diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index bba6eb24..e78a2d49 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c8f81032..9224220a 100644 --- a/bootstrap/unix-44/Vishap.c +++ b/bootstrap/unix-44/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkamSf */ #include "SYSTEM.h" #include "Configuration.h" #include "Heap.h" @@ -81,7 +81,7 @@ static void Vishap_PropagateElementaryTypeSizes (void) OPT_realtyp->size = OPM_RealSize; OPT_inttyp->size = OPM_IntSize; OPT_linttyp->size = OPM_LIntSize; - OPT_ainttyp->size = OPM_PointerSize; + OPT_pinttyp->size = OPM_PointerSize; OPT_lrltyp->size = OPM_LRealSize; OPT_sinttyp->size = OPM_SIntSize; OPT_booltyp->size = OPM_BoolSize; diff --git a/bootstrap/unix-44/errors.c b/bootstrap/unix-44/errors.c index 3f916fe9..6e4f20e5 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef diff --git a/bootstrap/unix-44/errors.h b/bootstrap/unix-44/errors.h index 2afac320..f06c706d 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 b894b3f9..00be6a22 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index ca635519..9d9202c0 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 46a1e460..8ca75a42 100644 --- a/bootstrap/unix-44/vt100.c +++ b/bootstrap/unix-44/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Console.h" #include "Strings.h" diff --git a/bootstrap/unix-44/vt100.h b/bootstrap/unix-44/vt100.h index ad1ac948..901eed38 100644 --- a/bootstrap/unix-44/vt100.h +++ b/bootstrap/unix-44/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 fb7df026..194e9da8 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" @@ -13,6 +13,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/01] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/02] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index 61b33bc5..fbca10e0 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8c9c6910..baf934fc 100644 --- a/bootstrap/unix-48/Console.c +++ b/bootstrap/unix-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Platform.h" diff --git a/bootstrap/unix-48/Console.h b/bootstrap/unix-48/Console.h index 16287a76..3823dacc 100644 --- a/bootstrap/unix-48/Console.h +++ b/bootstrap/unix-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 3c6594af..c971536e 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index d84672d4..f5c55397 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a252264a..2315b64e 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tskSfF */ #include "SYSTEM.h" struct Heap__1 { @@ -100,7 +100,7 @@ export void Heap_Unlock (void); extern void *Heap__init(); extern LONGINT Platform_MainStackFrame; -extern LONGINT Platform_OSAllocate(LONGINT size); +extern uintptr Platform_OSAllocate(uintptr size); #define Heap_FetchAddress(pointer) (LONGINT)(SYSTEM_ADRINT)(*((void**)((SYSTEM_ADRINT)pointer))) #define Heap_HeapModuleInit() Heap__init() #define Heap_OSAllocate(size) Platform_OSAllocate(size) diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index a89f18fc..83733c20 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] 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 7969f68f..e7006b76 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Console.h" #include "Heap.h" diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 8b271308..632138b5 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 bc74dd1d..fa8f98fe 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index a4ccc86e..8b2baa5f 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 08469d42..93d60530 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "OPM.h" @@ -200,8 +200,12 @@ void OPC_Ident (OPT_Object obj) } } } else if ((mode == 5 && obj->typ->form == 4)) { - OPM_WriteString((CHAR*)"int", 4); - OPM_WriteInt(__ASHL(obj->typ->size, 3)); + if (obj->typ == OPT_pinttyp || obj->typ == OPT_ainttyp) { + OPM_WriteString((CHAR*)"uintptr", 8); + } else { + OPM_WriteString((CHAR*)"int", 4); + OPM_WriteInt(__ASHL(obj->typ->size, 3)); + } } else { if (mode != 5 || obj->linkadr != 2) { if (mode == 13) { @@ -215,7 +219,7 @@ void OPC_Ident (OPT_Object obj) OPM_WriteStringVar((void*)OPM_modName, 32); } OPM_Write('_'); - } else if ((obj == OPT_sysptrtyp->strobj || obj == OPT_ainttyp->strobj) || obj == OPT_bytetyp->strobj) { + } else if (obj == OPT_sysptrtyp->strobj || obj == OPT_bytetyp->strobj) { OPM_WriteString((CHAR*)"SYSTEM_", 8); } OPM_WriteStringVar((void*)obj->name, 256); @@ -2080,6 +2084,7 @@ static void OPC_InitKeywords (void) Enter__49((CHAR*)"struct", 7); Enter__49((CHAR*)"switch", 7); Enter__49((CHAR*)"typedef", 8); + Enter__49((CHAR*)"uintptr", 8); Enter__49((CHAR*)"uint16", 7); Enter__49((CHAR*)"uint32", 7); Enter__49((CHAR*)"uint64", 7); diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 05c34fcc..78a60ed9 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8bf863b3..19ad29af 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index 36eb4165..44fe5275 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a366ef24..b0cd8613 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPB.h" #include "OPM.h" diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index 8bed9493..423013a4 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 2b29372f..36b37592 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index e40119f7..dec9c209 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 7fbad791..16dfc5b1 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" @@ -83,7 +83,7 @@ typedef export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; -export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export int8 OPT_nofGmod; export OPT_Object OPT_GlbMod[64]; export OPS_Name OPT_SelfName; @@ -1767,6 +1767,7 @@ static void EnumPtrs(void (*P)(void*)) P(OPT_sinttyp); P(OPT_inttyp); P(OPT_linttyp); + P(OPT_pinttyp); P(OPT_ainttyp); P(OPT_int8typ); P(OPT_int16typ); @@ -1849,6 +1850,7 @@ export void *OPT__init(void) OPT_InitStruct(&OPT_niltyp, 9); OPT_EnterTyp((CHAR*)"BYTE", 1, OPM_ByteSize, &OPT_bytetyp); OPT_EnterTyp((CHAR*)"PTR", 11, OPM_PointerSize, &OPT_sysptrtyp); + OPT_EnterTyp((CHAR*)"UINTPTR", 4, OPM_PointerSize, &OPT_pinttyp); OPT_EnterTyp((CHAR*)"ADRINT", 4, OPM_PointerSize, &OPT_ainttyp); OPT_EnterTyp((CHAR*)"INT8", 4, 1, &OPT_int8typ); OPT_EnterTyp((CHAR*)"INT16", 4, 2, &OPT_int16typ); diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index 480267cc..c290d3de 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h @@ -67,7 +67,7 @@ typedef import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; -import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import int8 OPT_nofGmod; import OPT_Object OPT_GlbMod[64]; import OPS_Name OPT_SelfName; diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 5ef539df..aeef6224 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPC.h" #include "OPM.h" @@ -285,6 +285,7 @@ void OPV_AdrAndSize (OPT_Object topScope) OPT_realtyp->strobj->linkadr = 2; OPT_inttyp->strobj->linkadr = 2; OPT_linttyp->strobj->linkadr = 2; + OPT_pinttyp->strobj->linkadr = 2; OPT_ainttyp->strobj->linkadr = 2; OPT_int8typ->strobj->linkadr = 2; OPT_int16typ->strobj->linkadr = 2; diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index 06bc39f1..8fd772f8 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c247eb06..f8dc8de8 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef @@ -26,11 +26,12 @@ typedef export BOOLEAN Platform_LittleEndian; -export int32 Platform_MainStackFrame, Platform_HaltCode; +export uintptr Platform_MainStackFrame; +export int32 Platform_HaltCode; export int16 Platform_PID; export CHAR Platform_CWD[256]; export int16 Platform_ArgCount; -export int32 Platform_ArgVector; +export uintptr Platform_ArgVector; static Platform_HaltProcedure Platform_HaltHandler; static int32 Platform_TimeStart; export int16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd; @@ -62,8 +63,8 @@ export void Platform_Init (int16 argc, int32 argvadr); export void Platform_MTimeAsClock (Platform_FileIdentity i, int32 *t, int32 *d); export int16 Platform_New (CHAR *n, LONGINT n__len, int32 *h); export BOOLEAN Platform_NoSuchDirectory (int16 e); -export int32 Platform_OSAllocate (int32 size); -export void Platform_OSFree (int32 address); +export uintptr Platform_OSAllocate (uintptr size); +export void Platform_OSFree (uintptr address); export int16 Platform_OldRO (CHAR *n, LONGINT n__len, int32 *h); export int16 Platform_OldRW (CHAR *n, LONGINT n__len, int32 *h); export int16 Platform_Read (int32 h, int32 p, int32 l, int32 *n); @@ -118,14 +119,14 @@ export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT #define Platform_EXDEV() EXDEV extern void Heap_InitHeap(); #define Platform_HeapInitHeap() Heap_InitHeap() -#define Platform_allocate(size) (LONGINT)(SYSTEM_ADRINT)((void*)malloc((size_t)size)) +#define Platform_allocate(size) (uintptr)((void*)malloc((size_t)size)) #define Platform_chdir(n, n__len) chdir((char*)n) #define Platform_closefile(fd) close(fd) #define Platform_err() errno #define Platform_errc(c) write(1, &c, 1) #define Platform_errstring(s, s__len) write(1, s, s__len-1) #define Platform_exit(code) exit(code) -#define Platform_free(address) free((void*)(SYSTEM_ADRINT)address) +#define Platform_free(address) free((void*)address) #define Platform_fstat(fd) fstat(fd, &s) #define Platform_fsync(fd) fsync(fd) #define Platform_ftruncate(fd, l) ftruncate(fd, l) @@ -212,14 +213,14 @@ BOOLEAN Platform_ConnectionFailed (int16 e) return _o_result; } -int32 Platform_OSAllocate (int32 size) +uintptr Platform_OSAllocate (uintptr size) { - int32 _o_result; + uintptr _o_result; _o_result = Platform_allocate(size); return _o_result; } -void Platform_OSFree (int32 address) +void Platform_OSFree (uintptr address) { Platform_free(address); } @@ -262,7 +263,7 @@ void Platform_GetArg (int16 n, CHAR *val, LONGINT val__len) { Platform_ArgVec av = NIL; if (n < Platform_ArgCount) { - av = (Platform_ArgVec)(SYSTEM_ADRINT)Platform_ArgVector; + av = __VAL(Platform_ArgVec, Platform_ArgVector); __COPY(*(*av)[__X(n, 1024)], val, val__len); } } diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index 129004fd..a4c001f3 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h @@ -18,11 +18,12 @@ typedef import BOOLEAN Platform_LittleEndian; -import int32 Platform_MainStackFrame, Platform_HaltCode; +import uintptr Platform_MainStackFrame; +import int32 Platform_HaltCode; import int16 Platform_PID; import CHAR Platform_CWD[256]; import int16 Platform_ArgCount; -import int32 Platform_ArgVector; +import uintptr Platform_ArgVector; import int16 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd; import CHAR Platform_nl[3]; @@ -51,8 +52,8 @@ import void Platform_Init (int16 argc, int32 argvadr); import void Platform_MTimeAsClock (Platform_FileIdentity i, int32 *t, int32 *d); import int16 Platform_New (CHAR *n, LONGINT n__len, int32 *h); import BOOLEAN Platform_NoSuchDirectory (int16 e); -import int32 Platform_OSAllocate (int32 size); -import void Platform_OSFree (int32 address); +import uintptr Platform_OSAllocate (uintptr size); +import void Platform_OSFree (uintptr address); import int16 Platform_OldRO (CHAR *n, LONGINT n__len, int32 *h); import int16 Platform_OldRW (CHAR *n, LONGINT n__len, int32 *h); import int16 Platform_Read (int32 h, int32 p, int32 l, int32 *n); diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 4b500170..4e271371 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index a1191c0b..b1e62271 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 9bc6b756..16681ab8 100644 --- a/bootstrap/unix-48/SYSTEM.c +++ b/bootstrap/unix-48/SYSTEM.c @@ -18,8 +18,11 @@ #include -LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);} -LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);} +// 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);} @@ -35,7 +38,7 @@ void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)()) { while (n > 0) { - P((LONGINT)(SYSTEM_ADRINT)(*((void**)(adr)))); + P((uintptr)(*((void**)(adr)))); adr = ((void**)adr) + 1; n--; } @@ -48,20 +51,20 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) while (n > 0) { t = typ; off = *t; - while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;} + while (off >= 0) {P(*(uintptr*)((char*)adr+off)); t++; off = *t;} adr = ((char*)adr) + size; n--; } } -LONGINT SYSTEM_DIV(uLONGINT x, uLONGINT y) -{ if ((LONGINT) x >= 0) return (x / y); +LONGINT SYSTEM_DIV(uint64 x, uint64 y) +{ if ((int64) x >= 0) return (x / y); else return -((y - 1 - x) / y); } -LONGINT SYSTEM_MOD(uLONGINT x, uLONGINT y) -{ uLONGINT m; - if ((LONGINT) x >= 0) return (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; } @@ -106,7 +109,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, else if (typ == (LONGINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[-1]; + p = (LONGINT*)(uintptr)x[-1]; p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */ while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;} @@ -119,7 +122,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */ nptr = nofelems * nofptrs; /* total number of pointers */ x = Heap_NEWBLK(size + nptr * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[- 1]; + p = (LONGINT*)(uintptr)x[- 1]; p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nptr - 1; n = 0; off = dataoff; while (n < nofelems) {i = 0; @@ -155,7 +158,7 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler // (Ignore other signals) } - void SystemSetHandler(int s, SYSTEM_ADRINT h) { + void SystemSetHandler(int s, uintptr h) { if (s >= 2 && s <= 4) { int needtosetsystemhandler = handler[s-2] == 0; handler[s-2] = (SystemSignalHandler)h; @@ -194,12 +197,12 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler } } - void SystemSetInterruptHandler(SYSTEM_ADRINT h) { + void SystemSetInterruptHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemInterruptHandler = (SystemSignalHandler)h; } - void SystemSetQuitHandler(SYSTEM_ADRINT h) { + void SystemSetQuitHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemQuitHandler = (SystemSignalHandler)h; } diff --git a/bootstrap/unix-48/SYSTEM.h b/bootstrap/unix-48/SYSTEM.h index 2cab2429..c83f69f1 100644 --- a/bootstrap/unix-48/SYSTEM.h +++ b/bootstrap/unix-48/SYSTEM.h @@ -1,6 +1,27 @@ #ifndef SYSTEM__h #define SYSTEM__h +// Declare memcpy in a way compatible with C compilers intrinsic +// built in implementations. + +#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) + #if defined(_WIN64) + typedef unsigned long long size_t; + #else + typedef unsigned long size_t; + #endif +#else + typedef unsigned int size_t; +#endif + +#define _SIZE_T_DECLARED // For FreeBSD +#define _SIZE_T_DEFINED_ // For OpenBSD + +void *memcpy(void *dest, const void *source, size_t size); + + +// Declare fixed size versions of basic intger types + #if defined(_WIN64) typedef long long int64; typedef unsigned long long uint64; @@ -18,20 +39,7 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) - #if defined(_WIN64) - typedef unsigned long long size_t; - #else - typedef unsigned long size_t; - #endif -#else - typedef unsigned int size_t; -#endif - -#define _SIZE_T_DECLARED // For FreeBSD -#define _SIZE_T_DEFINED_ // For OpenBSD - -void *memcpy(void *dest, const void *source, size_t size); +#define uintptr size_t // The compiler uses 'import' and 'export' which translate to 'extern' and @@ -46,7 +54,7 @@ void *memcpy(void *dest, const void *source, size_t size); #define NIL ((void*)0) #define __MAXEXT 16 -#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type +#define POINTER__typ ((uintptr*)(1)) // not NIL and not a valid type // Oberon types @@ -60,7 +68,7 @@ typedef float REAL; typedef double LONGREAL; typedef void* SYSTEM_PTR; -typedef size_t SYSTEM_ADRINT; +typedef uintptr SYSTEM_ADRINT; // For 32 bit builds, the size of LONGINT depends on a make option: @@ -68,18 +76,19 @@ typedef size_t SYSTEM_ADRINT; #if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64) typedef int32 INTEGER; typedef int64 LONGINT; - typedef uint64 uLONGINT; + typedef uint64 SET; + typedef uint64 uSET; #else typedef int16 INTEGER; typedef int32 LONGINT; - typedef uint32 uLONGINT; + typedef uint32 SET; + typedef uint32 uSET; #endif -// Unsigned variants are for use by shift and rotate macros. -typedef uLONGINT SET; -typedef uLONGINT uSET; +// Temporary defs while bootstrapping +#define uLONGINT uint64 @@ -90,32 +99,32 @@ typedef uLONGINT uSET; // OS Memory allocation interfaces are in PlatformXXX.Mod -extern LONGINT Platform_OSAllocate (LONGINT size); -extern void Platform_OSFree (LONGINT addr); +extern uintptr Platform_OSAllocate (uintptr size); +extern void Platform_OSFree (uintptr addr); // Run time system routines in SYSTEM.c -extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub); -extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub); +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 (uLONGINT x, uLONGINT y); -extern LONGINT SYSTEM_MOD (uLONGINT x, uLONGINT y); +extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); +extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); // Signal handling in SYSTEM.c #ifndef _WIN32 - extern void SystemSetHandler(int s, SYSTEM_ADRINT h); + extern void SystemSetHandler(int s, uintptr h); #else - extern void SystemSetInterruptHandler(SYSTEM_ADRINT h); - extern void SystemSetQuitHandler (SYSTEM_ADRINT h); + extern void SystemSetInterruptHandler(uintptr h); + extern void SystemSetQuitHandler (uintptr h); #endif @@ -138,11 +147,18 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \ while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;} -#define __DUP(x, l, t) x=(void*)memcpy((void*)(SYSTEM_ADRINT)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) +#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) #define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t)) -#define __DEL(x) Platform_OSFree((LONGINT)(SYSTEM_ADRINT)x) +#define __DEL(x) Platform_OSFree((LONGINT)(uintptr)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 */ @@ -150,24 +166,24 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(SYSTEM_ADRINT)(a) -#define __PUT(a, x, t) *(t*)(SYSTEM_ADRINT)(a)=x +#define __GET(a, x, t) x= *(t*)(uintptr)(a) +#define __PUT(a, x, t) *(t*)(uintptr)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) #define __LSHR(x, n, t) ((t)((u##t)(x)>>(n))) #define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) -#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) - #define __ROTL(x, n, t) ((t)((u##t)(x)<<(n)|(u##t)(x)>>(8*sizeof(t)-(n)))) #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 __BIT(x, n) (*(uLONGINT*)(x)>>(n)&1) -#define __MOVE(s, d, n) memcpy((char*)(SYSTEM_ADRINT)(d),(char*)(SYSTEM_ADRINT)(s),n) +#define __ASHL(x, n) ((LONGINT)(x)<<(n)) +#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) #define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) + +#define __BIT(x, n) (*(uint64*)(x)>>(n)&1) +#define __MOVE(s, d, n) memcpy((char*)(uintptr)(d),(char*)(uintptr)(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)) @@ -191,10 +207,6 @@ static int __str_cmp(CHAR *x, CHAR *y){ // Runtime checks -#define __X(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub)) -#define __R(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub)) #define __RETCHK __retchk: __HALT(-3); return 0; #define __CASECHK __HALT(-4) #define __WITHCHK __HALT(-7) @@ -227,7 +239,7 @@ extern void Heap_INCREF(); extern void Platform_Init(INTEGER argc, LONGINT argv); extern void Heap_FINALL(); -#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(SYSTEM_ADRINT)&argv); +#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr)&argv); #define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum) #define __FINI Heap_FINALL(); return 0 @@ -248,7 +260,7 @@ extern SYSTEM_PTR Heap_NEWREC (LONGINT tag); extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len)) -#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(SYSTEM_ADRINT)t##__typ) +#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr)t##__typ) #define __NEWARR SYSTEM_NEWARR @@ -279,20 +291,20 @@ extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __INITYP(t, t0, level) \ t##__typ = (LONGINT*)&t##__desc.blksz; \ memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \ - t##__desc.basep[level] = (LONGINT)(SYSTEM_ADRINT)t##__typ; \ - t##__desc.module = (LONGINT)(SYSTEM_ADRINT)m; \ + t##__desc.basep[level] = (LONGINT)(uintptr)t##__typ; \ + t##__desc.module = (LONGINT)(uintptr)m; \ if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \ t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \ - Heap_REGTYP(m, (LONGINT)(SYSTEM_ADRINT)&t##__desc.next); \ + Heap_REGTYP(m, (LONGINT)(uintptr)&t##__desc.next); \ SYSTEM_INHERIT(t##__typ, t0##__typ) -#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(SYSTEM_ADRINT)typ##__typ) -#define __TYPEOF(p) ((LONGINT*)(SYSTEM_ADRINT)(*(((LONGINT*)(p))-1))) +#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr)typ##__typ) +#define __TYPEOF(p) ((LONGINT*)(uintptr)(*(((LONGINT*)(p))-1))) #define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level) // Oberon-2 type bound procedures support -#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(SYSTEM_ADRINT)proc -#define __SEND(typ, num, funtyp, parlist) ((funtyp)((SYSTEM_ADRINT)*(typ-(__TPROC0OFF+num))))parlist +#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr)proc +#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr)*(typ-(__TPROC0OFF+num))))parlist diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 6463db16..439a49e9 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 07051628..681fcf1c 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8dea0639..e3516799 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Files.h" #include "Modules.h" diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index d946691c..b8f301f7 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c8f81032..9224220a 100644 --- a/bootstrap/unix-48/Vishap.c +++ b/bootstrap/unix-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkamSf */ #include "SYSTEM.h" #include "Configuration.h" #include "Heap.h" @@ -81,7 +81,7 @@ static void Vishap_PropagateElementaryTypeSizes (void) OPT_realtyp->size = OPM_RealSize; OPT_inttyp->size = OPM_IntSize; OPT_linttyp->size = OPM_LIntSize; - OPT_ainttyp->size = OPM_PointerSize; + OPT_pinttyp->size = OPM_PointerSize; OPT_lrltyp->size = OPM_LRealSize; OPT_sinttyp->size = OPM_SIntSize; OPT_booltyp->size = OPM_BoolSize; diff --git a/bootstrap/unix-48/errors.c b/bootstrap/unix-48/errors.c index 3f916fe9..6e4f20e5 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef diff --git a/bootstrap/unix-48/errors.h b/bootstrap/unix-48/errors.h index 2afac320..f06c706d 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 b894b3f9..00be6a22 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index ca635519..9d9202c0 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 46a1e460..8ca75a42 100644 --- a/bootstrap/unix-48/vt100.c +++ b/bootstrap/unix-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Console.h" #include "Strings.h" diff --git a/bootstrap/unix-48/vt100.h b/bootstrap/unix-48/vt100.h index ad1ac948..901eed38 100644 --- a/bootstrap/unix-48/vt100.h +++ b/bootstrap/unix-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 f4abd052..ea06c48a 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" @@ -14,6 +14,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/01] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/02] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index c756e930..1e741041 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 b4cd60d3..32b4d836 100644 --- a/bootstrap/unix-88/Console.c +++ b/bootstrap/unix-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Platform.h" diff --git a/bootstrap/unix-88/Console.h b/bootstrap/unix-88/Console.h index 987b5478..432a6e71 100644 --- a/bootstrap/unix-88/Console.h +++ b/bootstrap/unix-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 9ce98932..55714eaa 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index dee1234e..4dcd76c5 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 e96f7807..ba7f69f4 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tskSfF */ #define LARGE #include "SYSTEM.h" @@ -101,7 +101,7 @@ export void Heap_Unlock (void); extern void *Heap__init(); extern LONGINT Platform_MainStackFrame; -extern LONGINT Platform_OSAllocate(LONGINT size); +extern uintptr Platform_OSAllocate(uintptr size); #define Heap_FetchAddress(pointer) (LONGINT)(SYSTEM_ADRINT)(*((void**)((SYSTEM_ADRINT)pointer))) #define Heap_HeapModuleInit() Heap__init() #define Heap_OSAllocate(size) Platform_OSAllocate(size) diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index 40c921e4..e07b0d1e 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] 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 5f85fd33..3cc9156d 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Console.h" diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index d61c2889..f1bcc92f 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 36f97a5d..ad99f16a 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index 61a0edcd..82eb03c4 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8310f854..f67c2556 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" @@ -201,8 +201,12 @@ void OPC_Ident (OPT_Object obj) } } } else if ((mode == 5 && obj->typ->form == 4)) { - OPM_WriteString((CHAR*)"int", 4); - OPM_WriteInt(__ASHL(obj->typ->size, 3)); + if (obj->typ == OPT_pinttyp || obj->typ == OPT_ainttyp) { + OPM_WriteString((CHAR*)"uintptr", 8); + } else { + OPM_WriteString((CHAR*)"int", 4); + OPM_WriteInt(__ASHL(obj->typ->size, 3)); + } } else { if (mode != 5 || obj->linkadr != 2) { if (mode == 13) { @@ -216,7 +220,7 @@ void OPC_Ident (OPT_Object obj) OPM_WriteStringVar((void*)OPM_modName, 32); } OPM_Write('_'); - } else if ((obj == OPT_sysptrtyp->strobj || obj == OPT_ainttyp->strobj) || obj == OPT_bytetyp->strobj) { + } else if (obj == OPT_sysptrtyp->strobj || obj == OPT_bytetyp->strobj) { OPM_WriteString((CHAR*)"SYSTEM_", 8); } OPM_WriteStringVar((void*)obj->name, 256); @@ -2081,6 +2085,7 @@ static void OPC_InitKeywords (void) Enter__49((CHAR*)"struct", 7); Enter__49((CHAR*)"switch", 7); Enter__49((CHAR*)"typedef", 8); + Enter__49((CHAR*)"uintptr", 8); Enter__49((CHAR*)"uint16", 7); Enter__49((CHAR*)"uint32", 7); Enter__49((CHAR*)"uint64", 7); diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index 3c5dedf4..42f6f30d 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 d4b582de..fb89bcd6 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index ccce7304..72257311 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 78136a18..e270236a 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPB.h" diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index 863db6d6..9897c9c2 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 efd39a62..d07d06ca 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index c497e5c6..2aee5b21 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 287c2ba6..6fd27531 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" @@ -84,7 +84,7 @@ typedef export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; -export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export int8 OPT_nofGmod; export OPT_Object OPT_GlbMod[64]; export OPS_Name OPT_SelfName; @@ -1768,6 +1768,7 @@ static void EnumPtrs(void (*P)(void*)) P(OPT_sinttyp); P(OPT_inttyp); P(OPT_linttyp); + P(OPT_pinttyp); P(OPT_ainttyp); P(OPT_int8typ); P(OPT_int16typ); @@ -1850,6 +1851,7 @@ export void *OPT__init(void) OPT_InitStruct(&OPT_niltyp, 9); OPT_EnterTyp((CHAR*)"BYTE", 1, OPM_ByteSize, &OPT_bytetyp); OPT_EnterTyp((CHAR*)"PTR", 11, OPM_PointerSize, &OPT_sysptrtyp); + OPT_EnterTyp((CHAR*)"UINTPTR", 4, OPM_PointerSize, &OPT_pinttyp); OPT_EnterTyp((CHAR*)"ADRINT", 4, OPM_PointerSize, &OPT_ainttyp); OPT_EnterTyp((CHAR*)"INT8", 4, 1, &OPT_int8typ); OPT_EnterTyp((CHAR*)"INT16", 4, 2, &OPT_int16typ); diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index 808e8043..349849e8 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h @@ -68,7 +68,7 @@ typedef import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; -import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import int8 OPT_nofGmod; import OPT_Object OPT_GlbMod[64]; import OPS_Name OPT_SelfName; diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 5b1ffe19..d3aa0a87 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPC.h" @@ -286,6 +286,7 @@ void OPV_AdrAndSize (OPT_Object topScope) OPT_realtyp->strobj->linkadr = 2; OPT_inttyp->strobj->linkadr = 2; OPT_linttyp->strobj->linkadr = 2; + OPT_pinttyp->strobj->linkadr = 2; OPT_ainttyp->strobj->linkadr = 2; OPT_int8typ->strobj->linkadr = 2; OPT_int16typ->strobj->linkadr = 2; diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index 914ff060..09b50b36 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 fd00502a..2a6381d8 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" @@ -27,11 +27,12 @@ typedef export BOOLEAN Platform_LittleEndian; -export int64 Platform_MainStackFrame, Platform_HaltCode; +export uintptr Platform_MainStackFrame; +export int64 Platform_HaltCode; export int32 Platform_PID; export CHAR Platform_CWD[256]; export int32 Platform_ArgCount; -export int64 Platform_ArgVector; +export uintptr Platform_ArgVector; static Platform_HaltProcedure Platform_HaltHandler; static int64 Platform_TimeStart; export int32 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd; @@ -63,8 +64,8 @@ export void Platform_Init (int32 argc, int64 argvadr); export void Platform_MTimeAsClock (Platform_FileIdentity i, int64 *t, int64 *d); export int32 Platform_New (CHAR *n, LONGINT n__len, int64 *h); export BOOLEAN Platform_NoSuchDirectory (int32 e); -export int64 Platform_OSAllocate (int64 size); -export void Platform_OSFree (int64 address); +export uintptr Platform_OSAllocate (uintptr size); +export void Platform_OSFree (uintptr address); export int32 Platform_OldRO (CHAR *n, LONGINT n__len, int64 *h); export int32 Platform_OldRW (CHAR *n, LONGINT n__len, int64 *h); export int32 Platform_Read (int64 h, int64 p, int64 l, int64 *n); @@ -119,14 +120,14 @@ export BOOLEAN Platform_getEnv (CHAR *var, LONGINT var__len, CHAR *val, LONGINT #define Platform_EXDEV() EXDEV extern void Heap_InitHeap(); #define Platform_HeapInitHeap() Heap_InitHeap() -#define Platform_allocate(size) (LONGINT)(SYSTEM_ADRINT)((void*)malloc((size_t)size)) +#define Platform_allocate(size) (uintptr)((void*)malloc((size_t)size)) #define Platform_chdir(n, n__len) chdir((char*)n) #define Platform_closefile(fd) close(fd) #define Platform_err() errno #define Platform_errc(c) write(1, &c, 1) #define Platform_errstring(s, s__len) write(1, s, s__len-1) #define Platform_exit(code) exit(code) -#define Platform_free(address) free((void*)(SYSTEM_ADRINT)address) +#define Platform_free(address) free((void*)address) #define Platform_fstat(fd) fstat(fd, &s) #define Platform_fsync(fd) fsync(fd) #define Platform_ftruncate(fd, l) ftruncate(fd, l) @@ -213,14 +214,14 @@ BOOLEAN Platform_ConnectionFailed (int32 e) return _o_result; } -int64 Platform_OSAllocate (int64 size) +uintptr Platform_OSAllocate (uintptr size) { - int64 _o_result; + uintptr _o_result; _o_result = Platform_allocate(size); return _o_result; } -void Platform_OSFree (int64 address) +void Platform_OSFree (uintptr address) { Platform_free(address); } diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index caba8898..63531c58 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h @@ -19,11 +19,12 @@ typedef import BOOLEAN Platform_LittleEndian; -import int64 Platform_MainStackFrame, Platform_HaltCode; +import uintptr Platform_MainStackFrame; +import int64 Platform_HaltCode; import int32 Platform_PID; import CHAR Platform_CWD[256]; import int32 Platform_ArgCount; -import int64 Platform_ArgVector; +import uintptr Platform_ArgVector; import int32 Platform_SeekSet, Platform_SeekCur, Platform_SeekEnd; import CHAR Platform_nl[3]; @@ -52,8 +53,8 @@ import void Platform_Init (int32 argc, int64 argvadr); import void Platform_MTimeAsClock (Platform_FileIdentity i, int64 *t, int64 *d); import int32 Platform_New (CHAR *n, LONGINT n__len, int64 *h); import BOOLEAN Platform_NoSuchDirectory (int32 e); -import int64 Platform_OSAllocate (int64 size); -import void Platform_OSFree (int64 address); +import uintptr Platform_OSAllocate (uintptr size); +import void Platform_OSFree (uintptr address); import int32 Platform_OldRO (CHAR *n, LONGINT n__len, int64 *h); import int32 Platform_OldRW (CHAR *n, LONGINT n__len, int64 *h); import int32 Platform_Read (int64 h, int64 p, int64 l, int64 *n); diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index 5877bedc..d6e77abf 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index cf944612..2c04bec3 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 9bc6b756..16681ab8 100644 --- a/bootstrap/unix-88/SYSTEM.c +++ b/bootstrap/unix-88/SYSTEM.c @@ -18,8 +18,11 @@ #include -LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);} -LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);} +// 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);} @@ -35,7 +38,7 @@ void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)()) { while (n > 0) { - P((LONGINT)(SYSTEM_ADRINT)(*((void**)(adr)))); + P((uintptr)(*((void**)(adr)))); adr = ((void**)adr) + 1; n--; } @@ -48,20 +51,20 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) while (n > 0) { t = typ; off = *t; - while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;} + while (off >= 0) {P(*(uintptr*)((char*)adr+off)); t++; off = *t;} adr = ((char*)adr) + size; n--; } } -LONGINT SYSTEM_DIV(uLONGINT x, uLONGINT y) -{ if ((LONGINT) x >= 0) return (x / y); +LONGINT SYSTEM_DIV(uint64 x, uint64 y) +{ if ((int64) x >= 0) return (x / y); else return -((y - 1 - x) / y); } -LONGINT SYSTEM_MOD(uLONGINT x, uLONGINT y) -{ uLONGINT m; - if ((LONGINT) x >= 0) return (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; } @@ -106,7 +109,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, else if (typ == (LONGINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[-1]; + p = (LONGINT*)(uintptr)x[-1]; p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */ while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;} @@ -119,7 +122,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */ nptr = nofelems * nofptrs; /* total number of pointers */ x = Heap_NEWBLK(size + nptr * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[- 1]; + p = (LONGINT*)(uintptr)x[- 1]; p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nptr - 1; n = 0; off = dataoff; while (n < nofelems) {i = 0; @@ -155,7 +158,7 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler // (Ignore other signals) } - void SystemSetHandler(int s, SYSTEM_ADRINT h) { + void SystemSetHandler(int s, uintptr h) { if (s >= 2 && s <= 4) { int needtosetsystemhandler = handler[s-2] == 0; handler[s-2] = (SystemSignalHandler)h; @@ -194,12 +197,12 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler } } - void SystemSetInterruptHandler(SYSTEM_ADRINT h) { + void SystemSetInterruptHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemInterruptHandler = (SystemSignalHandler)h; } - void SystemSetQuitHandler(SYSTEM_ADRINT h) { + void SystemSetQuitHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemQuitHandler = (SystemSignalHandler)h; } diff --git a/bootstrap/unix-88/SYSTEM.h b/bootstrap/unix-88/SYSTEM.h index 2cab2429..c83f69f1 100644 --- a/bootstrap/unix-88/SYSTEM.h +++ b/bootstrap/unix-88/SYSTEM.h @@ -1,6 +1,27 @@ #ifndef SYSTEM__h #define SYSTEM__h +// Declare memcpy in a way compatible with C compilers intrinsic +// built in implementations. + +#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) + #if defined(_WIN64) + typedef unsigned long long size_t; + #else + typedef unsigned long size_t; + #endif +#else + typedef unsigned int size_t; +#endif + +#define _SIZE_T_DECLARED // For FreeBSD +#define _SIZE_T_DEFINED_ // For OpenBSD + +void *memcpy(void *dest, const void *source, size_t size); + + +// Declare fixed size versions of basic intger types + #if defined(_WIN64) typedef long long int64; typedef unsigned long long uint64; @@ -18,20 +39,7 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) - #if defined(_WIN64) - typedef unsigned long long size_t; - #else - typedef unsigned long size_t; - #endif -#else - typedef unsigned int size_t; -#endif - -#define _SIZE_T_DECLARED // For FreeBSD -#define _SIZE_T_DEFINED_ // For OpenBSD - -void *memcpy(void *dest, const void *source, size_t size); +#define uintptr size_t // The compiler uses 'import' and 'export' which translate to 'extern' and @@ -46,7 +54,7 @@ void *memcpy(void *dest, const void *source, size_t size); #define NIL ((void*)0) #define __MAXEXT 16 -#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type +#define POINTER__typ ((uintptr*)(1)) // not NIL and not a valid type // Oberon types @@ -60,7 +68,7 @@ typedef float REAL; typedef double LONGREAL; typedef void* SYSTEM_PTR; -typedef size_t SYSTEM_ADRINT; +typedef uintptr SYSTEM_ADRINT; // For 32 bit builds, the size of LONGINT depends on a make option: @@ -68,18 +76,19 @@ typedef size_t SYSTEM_ADRINT; #if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64) typedef int32 INTEGER; typedef int64 LONGINT; - typedef uint64 uLONGINT; + typedef uint64 SET; + typedef uint64 uSET; #else typedef int16 INTEGER; typedef int32 LONGINT; - typedef uint32 uLONGINT; + typedef uint32 SET; + typedef uint32 uSET; #endif -// Unsigned variants are for use by shift and rotate macros. -typedef uLONGINT SET; -typedef uLONGINT uSET; +// Temporary defs while bootstrapping +#define uLONGINT uint64 @@ -90,32 +99,32 @@ typedef uLONGINT uSET; // OS Memory allocation interfaces are in PlatformXXX.Mod -extern LONGINT Platform_OSAllocate (LONGINT size); -extern void Platform_OSFree (LONGINT addr); +extern uintptr Platform_OSAllocate (uintptr size); +extern void Platform_OSFree (uintptr addr); // Run time system routines in SYSTEM.c -extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub); -extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub); +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 (uLONGINT x, uLONGINT y); -extern LONGINT SYSTEM_MOD (uLONGINT x, uLONGINT y); +extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); +extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); // Signal handling in SYSTEM.c #ifndef _WIN32 - extern void SystemSetHandler(int s, SYSTEM_ADRINT h); + extern void SystemSetHandler(int s, uintptr h); #else - extern void SystemSetInterruptHandler(SYSTEM_ADRINT h); - extern void SystemSetQuitHandler (SYSTEM_ADRINT h); + extern void SystemSetInterruptHandler(uintptr h); + extern void SystemSetQuitHandler (uintptr h); #endif @@ -138,11 +147,18 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \ while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;} -#define __DUP(x, l, t) x=(void*)memcpy((void*)(SYSTEM_ADRINT)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) +#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) #define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t)) -#define __DEL(x) Platform_OSFree((LONGINT)(SYSTEM_ADRINT)x) +#define __DEL(x) Platform_OSFree((LONGINT)(uintptr)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 */ @@ -150,24 +166,24 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(SYSTEM_ADRINT)(a) -#define __PUT(a, x, t) *(t*)(SYSTEM_ADRINT)(a)=x +#define __GET(a, x, t) x= *(t*)(uintptr)(a) +#define __PUT(a, x, t) *(t*)(uintptr)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) #define __LSHR(x, n, t) ((t)((u##t)(x)>>(n))) #define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) -#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) - #define __ROTL(x, n, t) ((t)((u##t)(x)<<(n)|(u##t)(x)>>(8*sizeof(t)-(n)))) #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 __BIT(x, n) (*(uLONGINT*)(x)>>(n)&1) -#define __MOVE(s, d, n) memcpy((char*)(SYSTEM_ADRINT)(d),(char*)(SYSTEM_ADRINT)(s),n) +#define __ASHL(x, n) ((LONGINT)(x)<<(n)) +#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) #define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) + +#define __BIT(x, n) (*(uint64*)(x)>>(n)&1) +#define __MOVE(s, d, n) memcpy((char*)(uintptr)(d),(char*)(uintptr)(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)) @@ -191,10 +207,6 @@ static int __str_cmp(CHAR *x, CHAR *y){ // Runtime checks -#define __X(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub)) -#define __R(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub)) #define __RETCHK __retchk: __HALT(-3); return 0; #define __CASECHK __HALT(-4) #define __WITHCHK __HALT(-7) @@ -227,7 +239,7 @@ extern void Heap_INCREF(); extern void Platform_Init(INTEGER argc, LONGINT argv); extern void Heap_FINALL(); -#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(SYSTEM_ADRINT)&argv); +#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr)&argv); #define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum) #define __FINI Heap_FINALL(); return 0 @@ -248,7 +260,7 @@ extern SYSTEM_PTR Heap_NEWREC (LONGINT tag); extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len)) -#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(SYSTEM_ADRINT)t##__typ) +#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr)t##__typ) #define __NEWARR SYSTEM_NEWARR @@ -279,20 +291,20 @@ extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __INITYP(t, t0, level) \ t##__typ = (LONGINT*)&t##__desc.blksz; \ memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \ - t##__desc.basep[level] = (LONGINT)(SYSTEM_ADRINT)t##__typ; \ - t##__desc.module = (LONGINT)(SYSTEM_ADRINT)m; \ + t##__desc.basep[level] = (LONGINT)(uintptr)t##__typ; \ + t##__desc.module = (LONGINT)(uintptr)m; \ if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \ t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \ - Heap_REGTYP(m, (LONGINT)(SYSTEM_ADRINT)&t##__desc.next); \ + Heap_REGTYP(m, (LONGINT)(uintptr)&t##__desc.next); \ SYSTEM_INHERIT(t##__typ, t0##__typ) -#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(SYSTEM_ADRINT)typ##__typ) -#define __TYPEOF(p) ((LONGINT*)(SYSTEM_ADRINT)(*(((LONGINT*)(p))-1))) +#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr)typ##__typ) +#define __TYPEOF(p) ((LONGINT*)(uintptr)(*(((LONGINT*)(p))-1))) #define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level) // Oberon-2 type bound procedures support -#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(SYSTEM_ADRINT)proc -#define __SEND(typ, num, funtyp, parlist) ((funtyp)((SYSTEM_ADRINT)*(typ-(__TPROC0OFF+num))))parlist +#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr)proc +#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr)*(typ-(__TPROC0OFF+num))))parlist diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 85e9fca9..769cecb7 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index d703f8c0..012e77f9 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 0c5cb89c..934bc227 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Files.h" diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index 2e48fe94..fbd8a7a4 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c313eb20..f781d7ee 100644 --- a/bootstrap/unix-88/Vishap.c +++ b/bootstrap/unix-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkamSf */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" @@ -82,7 +82,7 @@ static void Vishap_PropagateElementaryTypeSizes (void) OPT_realtyp->size = OPM_RealSize; OPT_inttyp->size = OPM_IntSize; OPT_linttyp->size = OPM_LIntSize; - OPT_ainttyp->size = OPM_PointerSize; + OPT_pinttyp->size = OPM_PointerSize; OPT_lrltyp->size = OPM_LRealSize; OPT_sinttyp->size = OPM_SIntSize; OPT_booltyp->size = OPM_BoolSize; diff --git a/bootstrap/unix-88/errors.c b/bootstrap/unix-88/errors.c index dc5320bb..b1aa1639 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/unix-88/errors.h b/bootstrap/unix-88/errors.h index d15a472c..049c862a 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 bc32dc20..51975db4 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index 161e273a..3cba883d 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a757d25d..dfa8df9c 100644 --- a/bootstrap/unix-88/vt100.c +++ b/bootstrap/unix-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Console.h" diff --git a/bootstrap/unix-88/vt100.h b/bootstrap/unix-88/vt100.h index fb8a12d0..139b592e 100644 --- a/bootstrap/unix-88/vt100.h +++ b/bootstrap/unix-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 fb7df026..194e9da8 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" @@ -13,6 +13,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/01] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/02] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index 61b33bc5..fbca10e0 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 72c0b6bf..5b63f566 100644 --- a/bootstrap/windows-48/Console.c +++ b/bootstrap/windows-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Platform.h" diff --git a/bootstrap/windows-48/Console.h b/bootstrap/windows-48/Console.h index 16287a76..3823dacc 100644 --- a/bootstrap/windows-48/Console.h +++ b/bootstrap/windows-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 4aecc2ee..b53ae4ca 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index e85d1cfd..c216c6c6 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a252264a..2315b64e 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tskSfF */ #include "SYSTEM.h" struct Heap__1 { @@ -100,7 +100,7 @@ export void Heap_Unlock (void); extern void *Heap__init(); extern LONGINT Platform_MainStackFrame; -extern LONGINT Platform_OSAllocate(LONGINT size); +extern uintptr Platform_OSAllocate(uintptr size); #define Heap_FetchAddress(pointer) (LONGINT)(SYSTEM_ADRINT)(*((void**)((SYSTEM_ADRINT)pointer))) #define Heap_HeapModuleInit() Heap__init() #define Heap_OSAllocate(size) Platform_OSAllocate(size) diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index a89f18fc..83733c20 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] 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 7969f68f..e7006b76 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Console.h" #include "Heap.h" diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 8b271308..632138b5 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 bc74dd1d..fa8f98fe 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index a4ccc86e..8b2baa5f 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 08469d42..93d60530 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "OPM.h" @@ -200,8 +200,12 @@ void OPC_Ident (OPT_Object obj) } } } else if ((mode == 5 && obj->typ->form == 4)) { - OPM_WriteString((CHAR*)"int", 4); - OPM_WriteInt(__ASHL(obj->typ->size, 3)); + if (obj->typ == OPT_pinttyp || obj->typ == OPT_ainttyp) { + OPM_WriteString((CHAR*)"uintptr", 8); + } else { + OPM_WriteString((CHAR*)"int", 4); + OPM_WriteInt(__ASHL(obj->typ->size, 3)); + } } else { if (mode != 5 || obj->linkadr != 2) { if (mode == 13) { @@ -215,7 +219,7 @@ void OPC_Ident (OPT_Object obj) OPM_WriteStringVar((void*)OPM_modName, 32); } OPM_Write('_'); - } else if ((obj == OPT_sysptrtyp->strobj || obj == OPT_ainttyp->strobj) || obj == OPT_bytetyp->strobj) { + } else if (obj == OPT_sysptrtyp->strobj || obj == OPT_bytetyp->strobj) { OPM_WriteString((CHAR*)"SYSTEM_", 8); } OPM_WriteStringVar((void*)obj->name, 256); @@ -2080,6 +2084,7 @@ static void OPC_InitKeywords (void) Enter__49((CHAR*)"struct", 7); Enter__49((CHAR*)"switch", 7); Enter__49((CHAR*)"typedef", 8); + Enter__49((CHAR*)"uintptr", 8); Enter__49((CHAR*)"uint16", 7); Enter__49((CHAR*)"uint32", 7); Enter__49((CHAR*)"uint64", 7); diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 05c34fcc..78a60ed9 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8bf863b3..19ad29af 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index 36eb4165..44fe5275 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a366ef24..b0cd8613 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPB.h" #include "OPM.h" diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index 8bed9493..423013a4 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 2b29372f..36b37592 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index e40119f7..dec9c209 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 7fbad791..16dfc5b1 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" @@ -83,7 +83,7 @@ typedef export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; -export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export int8 OPT_nofGmod; export OPT_Object OPT_GlbMod[64]; export OPS_Name OPT_SelfName; @@ -1767,6 +1767,7 @@ static void EnumPtrs(void (*P)(void*)) P(OPT_sinttyp); P(OPT_inttyp); P(OPT_linttyp); + P(OPT_pinttyp); P(OPT_ainttyp); P(OPT_int8typ); P(OPT_int16typ); @@ -1849,6 +1850,7 @@ export void *OPT__init(void) OPT_InitStruct(&OPT_niltyp, 9); OPT_EnterTyp((CHAR*)"BYTE", 1, OPM_ByteSize, &OPT_bytetyp); OPT_EnterTyp((CHAR*)"PTR", 11, OPM_PointerSize, &OPT_sysptrtyp); + OPT_EnterTyp((CHAR*)"UINTPTR", 4, OPM_PointerSize, &OPT_pinttyp); OPT_EnterTyp((CHAR*)"ADRINT", 4, OPM_PointerSize, &OPT_ainttyp); OPT_EnterTyp((CHAR*)"INT8", 4, 1, &OPT_int8typ); OPT_EnterTyp((CHAR*)"INT16", 4, 2, &OPT_int16typ); diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index 480267cc..c290d3de 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h @@ -67,7 +67,7 @@ typedef import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; -import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import int8 OPT_nofGmod; import OPT_Object OPT_GlbMod[64]; import OPS_Name OPT_SelfName; diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 5ef539df..aeef6224 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPC.h" #include "OPM.h" @@ -285,6 +285,7 @@ void OPV_AdrAndSize (OPT_Object topScope) OPT_realtyp->strobj->linkadr = 2; OPT_inttyp->strobj->linkadr = 2; OPT_linttyp->strobj->linkadr = 2; + OPT_pinttyp->strobj->linkadr = 2; OPT_ainttyp->strobj->linkadr = 2; OPT_int8typ->strobj->linkadr = 2; OPT_int16typ->strobj->linkadr = 2; diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index 06bc39f1..8fd772f8 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 76fb4a1d..67dc8e39 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index 23922225..39074f3e 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 4b500170..4e271371 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index a1191c0b..b1e62271 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 9bc6b756..16681ab8 100644 --- a/bootstrap/windows-48/SYSTEM.c +++ b/bootstrap/windows-48/SYSTEM.c @@ -18,8 +18,11 @@ #include -LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);} -LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);} +// 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);} @@ -35,7 +38,7 @@ void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)()) { while (n > 0) { - P((LONGINT)(SYSTEM_ADRINT)(*((void**)(adr)))); + P((uintptr)(*((void**)(adr)))); adr = ((void**)adr) + 1; n--; } @@ -48,20 +51,20 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) while (n > 0) { t = typ; off = *t; - while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;} + while (off >= 0) {P(*(uintptr*)((char*)adr+off)); t++; off = *t;} adr = ((char*)adr) + size; n--; } } -LONGINT SYSTEM_DIV(uLONGINT x, uLONGINT y) -{ if ((LONGINT) x >= 0) return (x / y); +LONGINT SYSTEM_DIV(uint64 x, uint64 y) +{ if ((int64) x >= 0) return (x / y); else return -((y - 1 - x) / y); } -LONGINT SYSTEM_MOD(uLONGINT x, uLONGINT y) -{ uLONGINT m; - if ((LONGINT) x >= 0) return (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; } @@ -106,7 +109,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, else if (typ == (LONGINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[-1]; + p = (LONGINT*)(uintptr)x[-1]; p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */ while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;} @@ -119,7 +122,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */ nptr = nofelems * nofptrs; /* total number of pointers */ x = Heap_NEWBLK(size + nptr * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[- 1]; + p = (LONGINT*)(uintptr)x[- 1]; p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nptr - 1; n = 0; off = dataoff; while (n < nofelems) {i = 0; @@ -155,7 +158,7 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler // (Ignore other signals) } - void SystemSetHandler(int s, SYSTEM_ADRINT h) { + void SystemSetHandler(int s, uintptr h) { if (s >= 2 && s <= 4) { int needtosetsystemhandler = handler[s-2] == 0; handler[s-2] = (SystemSignalHandler)h; @@ -194,12 +197,12 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler } } - void SystemSetInterruptHandler(SYSTEM_ADRINT h) { + void SystemSetInterruptHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemInterruptHandler = (SystemSignalHandler)h; } - void SystemSetQuitHandler(SYSTEM_ADRINT h) { + void SystemSetQuitHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemQuitHandler = (SystemSignalHandler)h; } diff --git a/bootstrap/windows-48/SYSTEM.h b/bootstrap/windows-48/SYSTEM.h index 2cab2429..c83f69f1 100644 --- a/bootstrap/windows-48/SYSTEM.h +++ b/bootstrap/windows-48/SYSTEM.h @@ -1,6 +1,27 @@ #ifndef SYSTEM__h #define SYSTEM__h +// Declare memcpy in a way compatible with C compilers intrinsic +// built in implementations. + +#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) + #if defined(_WIN64) + typedef unsigned long long size_t; + #else + typedef unsigned long size_t; + #endif +#else + typedef unsigned int size_t; +#endif + +#define _SIZE_T_DECLARED // For FreeBSD +#define _SIZE_T_DEFINED_ // For OpenBSD + +void *memcpy(void *dest, const void *source, size_t size); + + +// Declare fixed size versions of basic intger types + #if defined(_WIN64) typedef long long int64; typedef unsigned long long uint64; @@ -18,20 +39,7 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) - #if defined(_WIN64) - typedef unsigned long long size_t; - #else - typedef unsigned long size_t; - #endif -#else - typedef unsigned int size_t; -#endif - -#define _SIZE_T_DECLARED // For FreeBSD -#define _SIZE_T_DEFINED_ // For OpenBSD - -void *memcpy(void *dest, const void *source, size_t size); +#define uintptr size_t // The compiler uses 'import' and 'export' which translate to 'extern' and @@ -46,7 +54,7 @@ void *memcpy(void *dest, const void *source, size_t size); #define NIL ((void*)0) #define __MAXEXT 16 -#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type +#define POINTER__typ ((uintptr*)(1)) // not NIL and not a valid type // Oberon types @@ -60,7 +68,7 @@ typedef float REAL; typedef double LONGREAL; typedef void* SYSTEM_PTR; -typedef size_t SYSTEM_ADRINT; +typedef uintptr SYSTEM_ADRINT; // For 32 bit builds, the size of LONGINT depends on a make option: @@ -68,18 +76,19 @@ typedef size_t SYSTEM_ADRINT; #if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64) typedef int32 INTEGER; typedef int64 LONGINT; - typedef uint64 uLONGINT; + typedef uint64 SET; + typedef uint64 uSET; #else typedef int16 INTEGER; typedef int32 LONGINT; - typedef uint32 uLONGINT; + typedef uint32 SET; + typedef uint32 uSET; #endif -// Unsigned variants are for use by shift and rotate macros. -typedef uLONGINT SET; -typedef uLONGINT uSET; +// Temporary defs while bootstrapping +#define uLONGINT uint64 @@ -90,32 +99,32 @@ typedef uLONGINT uSET; // OS Memory allocation interfaces are in PlatformXXX.Mod -extern LONGINT Platform_OSAllocate (LONGINT size); -extern void Platform_OSFree (LONGINT addr); +extern uintptr Platform_OSAllocate (uintptr size); +extern void Platform_OSFree (uintptr addr); // Run time system routines in SYSTEM.c -extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub); -extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub); +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 (uLONGINT x, uLONGINT y); -extern LONGINT SYSTEM_MOD (uLONGINT x, uLONGINT y); +extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); +extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); // Signal handling in SYSTEM.c #ifndef _WIN32 - extern void SystemSetHandler(int s, SYSTEM_ADRINT h); + extern void SystemSetHandler(int s, uintptr h); #else - extern void SystemSetInterruptHandler(SYSTEM_ADRINT h); - extern void SystemSetQuitHandler (SYSTEM_ADRINT h); + extern void SystemSetInterruptHandler(uintptr h); + extern void SystemSetQuitHandler (uintptr h); #endif @@ -138,11 +147,18 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \ while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;} -#define __DUP(x, l, t) x=(void*)memcpy((void*)(SYSTEM_ADRINT)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) +#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) #define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t)) -#define __DEL(x) Platform_OSFree((LONGINT)(SYSTEM_ADRINT)x) +#define __DEL(x) Platform_OSFree((LONGINT)(uintptr)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 */ @@ -150,24 +166,24 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(SYSTEM_ADRINT)(a) -#define __PUT(a, x, t) *(t*)(SYSTEM_ADRINT)(a)=x +#define __GET(a, x, t) x= *(t*)(uintptr)(a) +#define __PUT(a, x, t) *(t*)(uintptr)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) #define __LSHR(x, n, t) ((t)((u##t)(x)>>(n))) #define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) -#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) - #define __ROTL(x, n, t) ((t)((u##t)(x)<<(n)|(u##t)(x)>>(8*sizeof(t)-(n)))) #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 __BIT(x, n) (*(uLONGINT*)(x)>>(n)&1) -#define __MOVE(s, d, n) memcpy((char*)(SYSTEM_ADRINT)(d),(char*)(SYSTEM_ADRINT)(s),n) +#define __ASHL(x, n) ((LONGINT)(x)<<(n)) +#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) #define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) + +#define __BIT(x, n) (*(uint64*)(x)>>(n)&1) +#define __MOVE(s, d, n) memcpy((char*)(uintptr)(d),(char*)(uintptr)(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)) @@ -191,10 +207,6 @@ static int __str_cmp(CHAR *x, CHAR *y){ // Runtime checks -#define __X(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub)) -#define __R(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub)) #define __RETCHK __retchk: __HALT(-3); return 0; #define __CASECHK __HALT(-4) #define __WITHCHK __HALT(-7) @@ -227,7 +239,7 @@ extern void Heap_INCREF(); extern void Platform_Init(INTEGER argc, LONGINT argv); extern void Heap_FINALL(); -#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(SYSTEM_ADRINT)&argv); +#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr)&argv); #define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum) #define __FINI Heap_FINALL(); return 0 @@ -248,7 +260,7 @@ extern SYSTEM_PTR Heap_NEWREC (LONGINT tag); extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len)) -#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(SYSTEM_ADRINT)t##__typ) +#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr)t##__typ) #define __NEWARR SYSTEM_NEWARR @@ -279,20 +291,20 @@ extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __INITYP(t, t0, level) \ t##__typ = (LONGINT*)&t##__desc.blksz; \ memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \ - t##__desc.basep[level] = (LONGINT)(SYSTEM_ADRINT)t##__typ; \ - t##__desc.module = (LONGINT)(SYSTEM_ADRINT)m; \ + t##__desc.basep[level] = (LONGINT)(uintptr)t##__typ; \ + t##__desc.module = (LONGINT)(uintptr)m; \ if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \ t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \ - Heap_REGTYP(m, (LONGINT)(SYSTEM_ADRINT)&t##__desc.next); \ + Heap_REGTYP(m, (LONGINT)(uintptr)&t##__desc.next); \ SYSTEM_INHERIT(t##__typ, t0##__typ) -#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(SYSTEM_ADRINT)typ##__typ) -#define __TYPEOF(p) ((LONGINT*)(SYSTEM_ADRINT)(*(((LONGINT*)(p))-1))) +#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr)typ##__typ) +#define __TYPEOF(p) ((LONGINT*)(uintptr)(*(((LONGINT*)(p))-1))) #define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level) // Oberon-2 type bound procedures support -#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(SYSTEM_ADRINT)proc -#define __SEND(typ, num, funtyp, parlist) ((funtyp)((SYSTEM_ADRINT)*(typ-(__TPROC0OFF+num))))parlist +#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr)proc +#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr)*(typ-(__TPROC0OFF+num))))parlist diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 6463db16..439a49e9 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 07051628..681fcf1c 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8dea0639..e3516799 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Files.h" #include "Modules.h" diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index d946691c..b8f301f7 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c8f81032..9224220a 100644 --- a/bootstrap/windows-48/Vishap.c +++ b/bootstrap/windows-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkamSf */ #include "SYSTEM.h" #include "Configuration.h" #include "Heap.h" @@ -81,7 +81,7 @@ static void Vishap_PropagateElementaryTypeSizes (void) OPT_realtyp->size = OPM_RealSize; OPT_inttyp->size = OPM_IntSize; OPT_linttyp->size = OPM_LIntSize; - OPT_ainttyp->size = OPM_PointerSize; + OPT_pinttyp->size = OPM_PointerSize; OPT_lrltyp->size = OPM_LRealSize; OPT_sinttyp->size = OPM_SIntSize; OPT_booltyp->size = OPM_BoolSize; diff --git a/bootstrap/windows-48/errors.c b/bootstrap/windows-48/errors.c index 3f916fe9..6e4f20e5 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef diff --git a/bootstrap/windows-48/errors.h b/bootstrap/windows-48/errors.h index 2afac320..f06c706d 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 b894b3f9..00be6a22 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index ca635519..9d9202c0 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 46a1e460..8ca75a42 100644 --- a/bootstrap/windows-48/vt100.c +++ b/bootstrap/windows-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Console.h" #include "Strings.h" diff --git a/bootstrap/windows-48/vt100.h b/bootstrap/windows-48/vt100.h index ad1ac948..901eed38 100644 --- a/bootstrap/windows-48/vt100.h +++ b/bootstrap/windows-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 f4abd052..ea06c48a 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" @@ -14,6 +14,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/09/01] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/09/02] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index c756e930..1e741041 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 4331a772..7133027a 100644 --- a/bootstrap/windows-88/Console.c +++ b/bootstrap/windows-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Platform.h" diff --git a/bootstrap/windows-88/Console.h b/bootstrap/windows-88/Console.h index 987b5478..432a6e71 100644 --- a/bootstrap/windows-88/Console.h +++ b/bootstrap/windows-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 0c20d87b..7eae4cc4 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 918f272c..9a9b3b58 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 e96f7807..ba7f69f4 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tskSfF */ #define LARGE #include "SYSTEM.h" @@ -101,7 +101,7 @@ export void Heap_Unlock (void); extern void *Heap__init(); extern LONGINT Platform_MainStackFrame; -extern LONGINT Platform_OSAllocate(LONGINT size); +extern uintptr Platform_OSAllocate(uintptr size); #define Heap_FetchAddress(pointer) (LONGINT)(SYSTEM_ADRINT)(*((void**)((SYSTEM_ADRINT)pointer))) #define Heap_HeapModuleInit() Heap__init() #define Heap_OSAllocate(size) Platform_OSAllocate(size) diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index 40c921e4..e07b0d1e 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/09/02] 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 5f85fd33..3cc9156d 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Console.h" diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index d61c2889..f1bcc92f 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 36f97a5d..ad99f16a 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index 61a0edcd..82eb03c4 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 8310f854..f67c2556 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" @@ -201,8 +201,12 @@ void OPC_Ident (OPT_Object obj) } } } else if ((mode == 5 && obj->typ->form == 4)) { - OPM_WriteString((CHAR*)"int", 4); - OPM_WriteInt(__ASHL(obj->typ->size, 3)); + if (obj->typ == OPT_pinttyp || obj->typ == OPT_ainttyp) { + OPM_WriteString((CHAR*)"uintptr", 8); + } else { + OPM_WriteString((CHAR*)"int", 4); + OPM_WriteInt(__ASHL(obj->typ->size, 3)); + } } else { if (mode != 5 || obj->linkadr != 2) { if (mode == 13) { @@ -216,7 +220,7 @@ void OPC_Ident (OPT_Object obj) OPM_WriteStringVar((void*)OPM_modName, 32); } OPM_Write('_'); - } else if ((obj == OPT_sysptrtyp->strobj || obj == OPT_ainttyp->strobj) || obj == OPT_bytetyp->strobj) { + } else if (obj == OPT_sysptrtyp->strobj || obj == OPT_bytetyp->strobj) { OPM_WriteString((CHAR*)"SYSTEM_", 8); } OPM_WriteStringVar((void*)obj->name, 256); @@ -2081,6 +2085,7 @@ static void OPC_InitKeywords (void) Enter__49((CHAR*)"struct", 7); Enter__49((CHAR*)"switch", 7); Enter__49((CHAR*)"typedef", 8); + Enter__49((CHAR*)"uintptr", 8); Enter__49((CHAR*)"uint16", 7); Enter__49((CHAR*)"uint32", 7); Enter__49((CHAR*)"uint64", 7); diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index 3c5dedf4..42f6f30d 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 d4b582de..fb89bcd6 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index ccce7304..72257311 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 78136a18..e270236a 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPB.h" diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index 863db6d6..9897c9c2 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 efd39a62..d07d06ca 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin tspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index c497e5c6..2aee5b21 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/09/02] 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 287c2ba6..6fd27531 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" @@ -84,7 +84,7 @@ typedef export void (*OPT_typSize)(OPT_Struct); export OPT_Object OPT_topScope; -export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +export OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; export int8 OPT_nofGmod; export OPT_Object OPT_GlbMod[64]; export OPS_Name OPT_SelfName; @@ -1768,6 +1768,7 @@ static void EnumPtrs(void (*P)(void*)) P(OPT_sinttyp); P(OPT_inttyp); P(OPT_linttyp); + P(OPT_pinttyp); P(OPT_ainttyp); P(OPT_int8typ); P(OPT_int16typ); @@ -1850,6 +1851,7 @@ export void *OPT__init(void) OPT_InitStruct(&OPT_niltyp, 9); OPT_EnterTyp((CHAR*)"BYTE", 1, OPM_ByteSize, &OPT_bytetyp); OPT_EnterTyp((CHAR*)"PTR", 11, OPM_PointerSize, &OPT_sysptrtyp); + OPT_EnterTyp((CHAR*)"UINTPTR", 4, OPM_PointerSize, &OPT_pinttyp); OPT_EnterTyp((CHAR*)"ADRINT", 4, OPM_PointerSize, &OPT_ainttyp); OPT_EnterTyp((CHAR*)"INT8", 4, 1, &OPT_int8typ); OPT_EnterTyp((CHAR*)"INT16", 4, 2, &OPT_int16typ); diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index 808e8043..349849e8 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h @@ -68,7 +68,7 @@ typedef import void (*OPT_typSize)(OPT_Struct); import OPT_Object OPT_topScope; -import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; +import OPT_Struct OPT_undftyp, OPT_bytetyp, OPT_booltyp, OPT_chartyp, OPT_sinttyp, OPT_inttyp, OPT_linttyp, OPT_pinttyp, OPT_ainttyp, OPT_int8typ, OPT_int16typ, OPT_int32typ, OPT_int64typ, OPT_realtyp, OPT_lrltyp, OPT_settyp, OPT_stringtyp, OPT_niltyp, OPT_notyp, OPT_sysptrtyp; import int8 OPT_nofGmod; import OPT_Object OPT_GlbMod[64]; import OPS_Name OPT_SelfName; diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 5b1ffe19..d3aa0a87 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPC.h" @@ -286,6 +286,7 @@ void OPV_AdrAndSize (OPT_Object topScope) OPT_realtyp->strobj->linkadr = 2; OPT_inttyp->strobj->linkadr = 2; OPT_linttyp->strobj->linkadr = 2; + OPT_pinttyp->strobj->linkadr = 2; OPT_ainttyp->strobj->linkadr = 2; OPT_int8typ->strobj->linkadr = 2; OPT_int16typ->strobj->linkadr = 2; diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index 914ff060..09b50b36 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 2e9530e6..456a43cf 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index 13f60995..3691e5fb 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 5877bedc..d6e77abf 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index cf944612..2c04bec3 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 9bc6b756..16681ab8 100644 --- a/bootstrap/windows-88/SYSTEM.c +++ b/bootstrap/windows-88/SYSTEM.c @@ -18,8 +18,11 @@ #include -LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);} -LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);} +// 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);} @@ -35,7 +38,7 @@ void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)()) { while (n > 0) { - P((LONGINT)(SYSTEM_ADRINT)(*((void**)(adr)))); + P((uintptr)(*((void**)(adr)))); adr = ((void**)adr) + 1; n--; } @@ -48,20 +51,20 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) while (n > 0) { t = typ; off = *t; - while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;} + while (off >= 0) {P(*(uintptr*)((char*)adr+off)); t++; off = *t;} adr = ((char*)adr) + size; n--; } } -LONGINT SYSTEM_DIV(uLONGINT x, uLONGINT y) -{ if ((LONGINT) x >= 0) return (x / y); +LONGINT SYSTEM_DIV(uint64 x, uint64 y) +{ if ((int64) x >= 0) return (x / y); else return -((y - 1 - x) / y); } -LONGINT SYSTEM_MOD(uLONGINT x, uLONGINT y) -{ uLONGINT m; - if ((LONGINT) x >= 0) return (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; } @@ -106,7 +109,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, else if (typ == (LONGINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[-1]; + p = (LONGINT*)(uintptr)x[-1]; p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */ while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;} @@ -119,7 +122,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */ nptr = nofelems * nofptrs; /* total number of pointers */ x = Heap_NEWBLK(size + nptr * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[- 1]; + p = (LONGINT*)(uintptr)x[- 1]; p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nptr - 1; n = 0; off = dataoff; while (n < nofelems) {i = 0; @@ -155,7 +158,7 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler // (Ignore other signals) } - void SystemSetHandler(int s, SYSTEM_ADRINT h) { + void SystemSetHandler(int s, uintptr h) { if (s >= 2 && s <= 4) { int needtosetsystemhandler = handler[s-2] == 0; handler[s-2] = (SystemSignalHandler)h; @@ -194,12 +197,12 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler } } - void SystemSetInterruptHandler(SYSTEM_ADRINT h) { + void SystemSetInterruptHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemInterruptHandler = (SystemSignalHandler)h; } - void SystemSetQuitHandler(SYSTEM_ADRINT h) { + void SystemSetQuitHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemQuitHandler = (SystemSignalHandler)h; } diff --git a/bootstrap/windows-88/SYSTEM.h b/bootstrap/windows-88/SYSTEM.h index 2cab2429..c83f69f1 100644 --- a/bootstrap/windows-88/SYSTEM.h +++ b/bootstrap/windows-88/SYSTEM.h @@ -1,6 +1,27 @@ #ifndef SYSTEM__h #define SYSTEM__h +// Declare memcpy in a way compatible with C compilers intrinsic +// built in implementations. + +#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) + #if defined(_WIN64) + typedef unsigned long long size_t; + #else + typedef unsigned long size_t; + #endif +#else + typedef unsigned int size_t; +#endif + +#define _SIZE_T_DECLARED // For FreeBSD +#define _SIZE_T_DEFINED_ // For OpenBSD + +void *memcpy(void *dest, const void *source, size_t size); + + +// Declare fixed size versions of basic intger types + #if defined(_WIN64) typedef long long int64; typedef unsigned long long uint64; @@ -18,20 +39,7 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) - #if defined(_WIN64) - typedef unsigned long long size_t; - #else - typedef unsigned long size_t; - #endif -#else - typedef unsigned int size_t; -#endif - -#define _SIZE_T_DECLARED // For FreeBSD -#define _SIZE_T_DEFINED_ // For OpenBSD - -void *memcpy(void *dest, const void *source, size_t size); +#define uintptr size_t // The compiler uses 'import' and 'export' which translate to 'extern' and @@ -46,7 +54,7 @@ void *memcpy(void *dest, const void *source, size_t size); #define NIL ((void*)0) #define __MAXEXT 16 -#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type +#define POINTER__typ ((uintptr*)(1)) // not NIL and not a valid type // Oberon types @@ -60,7 +68,7 @@ typedef float REAL; typedef double LONGREAL; typedef void* SYSTEM_PTR; -typedef size_t SYSTEM_ADRINT; +typedef uintptr SYSTEM_ADRINT; // For 32 bit builds, the size of LONGINT depends on a make option: @@ -68,18 +76,19 @@ typedef size_t SYSTEM_ADRINT; #if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64) typedef int32 INTEGER; typedef int64 LONGINT; - typedef uint64 uLONGINT; + typedef uint64 SET; + typedef uint64 uSET; #else typedef int16 INTEGER; typedef int32 LONGINT; - typedef uint32 uLONGINT; + typedef uint32 SET; + typedef uint32 uSET; #endif -// Unsigned variants are for use by shift and rotate macros. -typedef uLONGINT SET; -typedef uLONGINT uSET; +// Temporary defs while bootstrapping +#define uLONGINT uint64 @@ -90,32 +99,32 @@ typedef uLONGINT uSET; // OS Memory allocation interfaces are in PlatformXXX.Mod -extern LONGINT Platform_OSAllocate (LONGINT size); -extern void Platform_OSFree (LONGINT addr); +extern uintptr Platform_OSAllocate (uintptr size); +extern void Platform_OSFree (uintptr addr); // Run time system routines in SYSTEM.c -extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub); -extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub); +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 (uLONGINT x, uLONGINT y); -extern LONGINT SYSTEM_MOD (uLONGINT x, uLONGINT y); +extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); +extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); // Signal handling in SYSTEM.c #ifndef _WIN32 - extern void SystemSetHandler(int s, SYSTEM_ADRINT h); + extern void SystemSetHandler(int s, uintptr h); #else - extern void SystemSetInterruptHandler(SYSTEM_ADRINT h); - extern void SystemSetQuitHandler (SYSTEM_ADRINT h); + extern void SystemSetInterruptHandler(uintptr h); + extern void SystemSetQuitHandler (uintptr h); #endif @@ -138,11 +147,18 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \ while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;} -#define __DUP(x, l, t) x=(void*)memcpy((void*)(SYSTEM_ADRINT)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) +#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) #define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t)) -#define __DEL(x) Platform_OSFree((LONGINT)(SYSTEM_ADRINT)x) +#define __DEL(x) Platform_OSFree((LONGINT)(uintptr)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 */ @@ -150,24 +166,24 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(SYSTEM_ADRINT)(a) -#define __PUT(a, x, t) *(t*)(SYSTEM_ADRINT)(a)=x +#define __GET(a, x, t) x= *(t*)(uintptr)(a) +#define __PUT(a, x, t) *(t*)(uintptr)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) #define __LSHR(x, n, t) ((t)((u##t)(x)>>(n))) #define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) -#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) - #define __ROTL(x, n, t) ((t)((u##t)(x)<<(n)|(u##t)(x)>>(8*sizeof(t)-(n)))) #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 __BIT(x, n) (*(uLONGINT*)(x)>>(n)&1) -#define __MOVE(s, d, n) memcpy((char*)(SYSTEM_ADRINT)(d),(char*)(SYSTEM_ADRINT)(s),n) +#define __ASHL(x, n) ((LONGINT)(x)<<(n)) +#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) #define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) + +#define __BIT(x, n) (*(uint64*)(x)>>(n)&1) +#define __MOVE(s, d, n) memcpy((char*)(uintptr)(d),(char*)(uintptr)(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)) @@ -191,10 +207,6 @@ static int __str_cmp(CHAR *x, CHAR *y){ // Runtime checks -#define __X(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub)) -#define __R(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub)) #define __RETCHK __retchk: __HALT(-3); return 0; #define __CASECHK __HALT(-4) #define __WITHCHK __HALT(-7) @@ -227,7 +239,7 @@ extern void Heap_INCREF(); extern void Platform_Init(INTEGER argc, LONGINT argv); extern void Heap_FINALL(); -#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(SYSTEM_ADRINT)&argv); +#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr)&argv); #define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum) #define __FINI Heap_FINALL(); return 0 @@ -248,7 +260,7 @@ extern SYSTEM_PTR Heap_NEWREC (LONGINT tag); extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len)) -#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(SYSTEM_ADRINT)t##__typ) +#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr)t##__typ) #define __NEWARR SYSTEM_NEWARR @@ -279,20 +291,20 @@ extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __INITYP(t, t0, level) \ t##__typ = (LONGINT*)&t##__desc.blksz; \ memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \ - t##__desc.basep[level] = (LONGINT)(SYSTEM_ADRINT)t##__typ; \ - t##__desc.module = (LONGINT)(SYSTEM_ADRINT)m; \ + t##__desc.basep[level] = (LONGINT)(uintptr)t##__typ; \ + t##__desc.module = (LONGINT)(uintptr)m; \ if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \ t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \ - Heap_REGTYP(m, (LONGINT)(SYSTEM_ADRINT)&t##__desc.next); \ + Heap_REGTYP(m, (LONGINT)(uintptr)&t##__desc.next); \ SYSTEM_INHERIT(t##__typ, t0##__typ) -#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(SYSTEM_ADRINT)typ##__typ) -#define __TYPEOF(p) ((LONGINT*)(SYSTEM_ADRINT)(*(((LONGINT*)(p))-1))) +#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr)typ##__typ) +#define __TYPEOF(p) ((LONGINT*)(uintptr)(*(((LONGINT*)(p))-1))) #define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level) // Oberon-2 type bound procedures support -#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(SYSTEM_ADRINT)proc -#define __SEND(typ, num, funtyp, parlist) ((funtyp)((SYSTEM_ADRINT)*(typ-(__TPROC0OFF+num))))parlist +#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr)proc +#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr)*(typ-(__TPROC0OFF+num))))parlist diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 85e9fca9..769cecb7 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index d703f8c0..012e77f9 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 0c5cb89c..934bc227 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Files.h" diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index 2e48fe94..fbd8a7a4 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 c313eb20..f781d7ee 100644 --- a/bootstrap/windows-88/Vishap.c +++ b/bootstrap/windows-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkamSf */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" @@ -82,7 +82,7 @@ static void Vishap_PropagateElementaryTypeSizes (void) OPT_realtyp->size = OPM_RealSize; OPT_inttyp->size = OPM_IntSize; OPT_linttyp->size = OPM_LIntSize; - OPT_ainttyp->size = OPM_PointerSize; + OPT_pinttyp->size = OPM_PointerSize; OPT_lrltyp->size = OPM_LRealSize; OPT_sinttyp->size = OPM_SIntSize; OPT_booltyp->size = OPM_BoolSize; diff --git a/bootstrap/windows-88/errors.c b/bootstrap/windows-88/errors.c index dc5320bb..b1aa1639 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/windows-88/errors.h b/bootstrap/windows-88/errors.h index d15a472c..049c862a 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 bc32dc20..51975db4 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index 161e273a..3cba883d 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] 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 a757d25d..dfa8df9c 100644 --- a/bootstrap/windows-88/vt100.c +++ b/bootstrap/windows-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Console.h" diff --git a/bootstrap/windows-88/vt100.h b/bootstrap/windows-88/vt100.h index fb8a12d0..139b592e 100644 --- a/bootstrap/windows-88/vt100.h +++ b/bootstrap/windows-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/09/01] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/09/02] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h diff --git a/makefile b/makefile index eee8238a..3840589a 100644 --- a/makefile +++ b/makefile @@ -158,6 +158,9 @@ full: configuration +assemble: + @make -f src/tools/make/vishap.make -s assemble + # compile: compiler only, without cleaning compiler: configuration @@ -244,6 +247,14 @@ bootstrap: configuration make -f src/tools/make/vishap.make -s translate INTSIZE=4 ADRSIZE=8 ALIGNMENT=8 PLATFORM=windows BUILDDIR=bootstrap/windows-88 && rm bootstrap/windows-88/*.sym +bootstrapunclean: + rm -rf bootstrap/* + make -f src/tools/make/vishap.make -s translate INTSIZE=2 ADRSIZE=4 ALIGNMENT=4 PLATFORM=unix BUILDDIR=bootstrap/unix-44 && rm bootstrap/unix-44/*.sym + make -f src/tools/make/vishap.make -s translate INTSIZE=2 ADRSIZE=4 ALIGNMENT=8 PLATFORM=unix BUILDDIR=bootstrap/unix-48 && rm bootstrap/unix-48/*.sym + make -f src/tools/make/vishap.make -s translate INTSIZE=4 ADRSIZE=8 ALIGNMENT=8 PLATFORM=unix BUILDDIR=bootstrap/unix-88 && rm bootstrap/unix-88/*.sym + make -f src/tools/make/vishap.make -s translate INTSIZE=2 ADRSIZE=4 ALIGNMENT=8 PLATFORM=windows BUILDDIR=bootstrap/windows-48 && rm bootstrap/windows-48/*.sym + make -f src/tools/make/vishap.make -s translate INTSIZE=4 ADRSIZE=8 ALIGNMENT=8 PLATFORM=windows BUILDDIR=bootstrap/windows-88 && rm bootstrap/windows-88/*.sym + revertbootstrap: diff --git a/src/compiler/OPC.Mod b/src/compiler/OPC.Mod index e51f9704..5b4f9195 100644 --- a/src/compiler/OPC.Mod +++ b/src/compiler/OPC.Mod @@ -7,7 +7,6 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) IMPORT OPT, OPM, Configuration, SYSTEM; - CONST demoVersion = FALSE; @@ -118,7 +117,11 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) IF keytab[hashtab[h]] = obj^.name THEN OPM.Write('_') END END ELSIF (mode = OPT.Typ) & (obj.typ.form = OPT.Int) THEN - OPM.WriteString("int"); OPM.WriteInt(obj.typ.size*8) + IF (obj.typ = OPT.pinttyp) OR (obj.typ = OPT.ainttyp) THEN + OPM.WriteString("uintptr") + ELSE + OPM.WriteString("int"); OPM.WriteInt(obj.typ.size*8) + END ELSE IF (mode # OPT.Typ) OR (obj^.linkadr # PredefinedType) THEN IF mode = OPT.TProc THEN Ident(obj^.link^.typ^.strobj) @@ -129,7 +132,6 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) END ; OPM.Write('_') ELSIF (obj = OPT.sysptrtyp^.strobj) - OR (obj = OPT.ainttyp^.strobj) OR (obj = OPT.bytetyp^.strobj) THEN OPM.WriteString("SYSTEM_") END; @@ -1357,6 +1359,7 @@ MODULE OPC; (* copyright (c) J. Templ 12.7.95 / 3.7.96 *) Enter("struct"); Enter("switch"); Enter("typedef"); + Enter("uintptr"); (* pseudo keyword used by voc *) Enter("uint16"); (* pseudo keyword used by voc *) Enter("uint32"); (* pseudo keyword used by voc *) Enter("uint64"); (* pseudo keyword used by voc *) diff --git a/src/compiler/OPT.Mod b/src/compiler/OPT.Mod index a60f30f8..135d1016 100644 --- a/src/compiler/OPT.Mod +++ b/src/compiler/OPT.Mod @@ -155,7 +155,7 @@ VAR undftyp*, bytetyp*, booltyp*, chartyp*, sinttyp*, inttyp*, linttyp*, - ainttyp*, + pinttyp*, ainttyp*, int8typ*, int16typ*, int32typ*, int64typ*, realtyp*, lrltyp*, settyp*, stringtyp*, niltyp*, notyp*, sysptrtyp*: Struct; @@ -1186,13 +1186,14 @@ BEGIN topScope := NIL; OpenScope(0, NIL); OPM.errpos := 0; InitStruct(niltyp, NilTyp); (*initialization of module SYSTEM*) - EnterTyp("BYTE", Byte, OPM.ByteSize, bytetyp); - EnterTyp("PTR", Pointer, OPM.PointerSize, sysptrtyp); - EnterTyp("ADRINT", Int, OPM.PointerSize, ainttyp); - EnterTyp("INT8", Int, 1, int8typ); - EnterTyp("INT16", Int, 2, int16typ); - EnterTyp("INT32", Int, 4, int32typ); - EnterTyp("INT64", Int, 8, int64typ); + EnterTyp("BYTE", Byte, OPM.ByteSize, bytetyp); + EnterTyp("PTR", Pointer, OPM.PointerSize, sysptrtyp); + EnterTyp("UINTPTR", Int, OPM.PointerSize, pinttyp); + EnterTyp("ADRINT", Int, OPM.PointerSize, ainttyp); (* Temporary for bootstrapping *) + EnterTyp("INT8", Int, 1, int8typ); + EnterTyp("INT16", Int, 2, int16typ); + EnterTyp("INT32", Int, 4, int32typ); + EnterTyp("INT64", Int, 8, int64typ); EnterProc("ADR", adrfn); EnterProc("CC", ccfn); EnterProc("LSH", lshfn); diff --git a/src/compiler/OPV.Mod b/src/compiler/OPV.Mod index 089cd5e1..e23a89ad 100644 --- a/src/compiler/OPV.Mod +++ b/src/compiler/OPV.Mod @@ -205,6 +205,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 OPT.realtyp^.strobj^.linkadr := PredefinedType; OPT.inttyp^.strobj^.linkadr := PredefinedType; OPT.linttyp^.strobj^.linkadr := PredefinedType; + OPT.pinttyp^.strobj^.linkadr := PredefinedType; OPT.ainttyp^.strobj^.linkadr := PredefinedType; OPT.int8typ^.strobj^.linkadr := PredefinedType; OPT.int16typ^.strobj^.linkadr := PredefinedType; diff --git a/src/compiler/Vishap.Mod b/src/compiler/Vishap.Mod index 6d306e5e..615a032c 100644 --- a/src/compiler/Vishap.Mod +++ b/src/compiler/Vishap.Mod @@ -58,7 +58,7 @@ MODULE Vishap; (* J. Templ 3.2.95 *) OPT.realtyp.size := OPM.RealSize; OPT.inttyp.size := OPM.IntSize; OPT.linttyp.size := OPM.LIntSize; - OPT.ainttyp.size := OPM.PointerSize; + OPT.pinttyp.size := OPM.PointerSize; OPT.lrltyp.size := OPM.LRealSize; OPT.sinttyp.size := OPM.SIntSize; OPT.booltyp.size := OPM.BoolSize diff --git a/src/system/Heap.Mod b/src/system/Heap.Mod index 5acbb04e..619daf53 100644 --- a/src/system/Heap.Mod +++ b/src/system/Heap.Mod @@ -162,8 +162,8 @@ MODULE Heap; END INCREF; - PROCEDURE -ExternPlatformOSAllocate "extern LONGINT Platform_OSAllocate(LONGINT size);"; - PROCEDURE -OSAllocate(size: LONGINT): LONGINT "Platform_OSAllocate(size)"; + PROCEDURE -ExternPlatformOSAllocate "extern uintptr Platform_OSAllocate(uintptr size);"; + PROCEDURE -OSAllocate(size: SYSTEM.UINTPTR): SYSTEM.UINTPTR "Platform_OSAllocate(size)"; PROCEDURE NewChunk(blksz: LONGINT): LONGINT; VAR chnk: LONGINT; diff --git a/src/system/Platformunix.Mod b/src/system/Platformunix.Mod index a55e1130..34ee60b6 100644 --- a/src/system/Platformunix.Mod +++ b/src/system/Platformunix.Mod @@ -27,13 +27,13 @@ TYPE VAR LittleEndian-: BOOLEAN; - MainStackFrame-: LONGINT; + MainStackFrame-: SYSTEM.ADRINT; HaltCode-: LONGINT; PID-: INTEGER; (* Note: Must be updated by Fork implementation *) CWD-: ARRAY 256 OF CHAR; ArgCount-: INTEGER; - ArgVector-: LONGINT; + ArgVector-: SYSTEM.ADRINT; HaltHandler: HaltProcedure; TimeStart: LONGINT; @@ -106,11 +106,11 @@ BEGIN RETURN (e = ECONNREFUSED()) OR (e = ECONNABORTED()) (* OS memory allocaton *) -PROCEDURE -allocate(size: LONGINT): LONGINT "(LONGINT)(SYSTEM_ADRINT)((void*)malloc((size_t)size))"; -PROCEDURE OSAllocate*(size: LONGINT): LONGINT; BEGIN RETURN allocate(size) END OSAllocate; +PROCEDURE -allocate (size: SYSTEM.UINTPTR): SYSTEM.UINTPTR "(uintptr)((void*)malloc((size_t)size))"; +PROCEDURE OSAllocate*(size: SYSTEM.UINTPTR): SYSTEM.UINTPTR; BEGIN RETURN allocate(size) END OSAllocate; -PROCEDURE -free(address: LONGINT) "free((void*)(SYSTEM_ADRINT)address)"; -PROCEDURE OSFree*(address: LONGINT); BEGIN free(address) END OSFree; +PROCEDURE -free(address: SYSTEM.UINTPTR) "free((void*)address)"; +PROCEDURE OSFree*(address: SYSTEM.UINTPTR); BEGIN free(address) END OSFree; diff --git a/src/system/SYSTEM.c b/src/system/SYSTEM.c index 9bc6b756..16681ab8 100644 --- a/src/system/SYSTEM.c +++ b/src/system/SYSTEM.c @@ -18,8 +18,11 @@ #include -LONGINT SYSTEM_XCHK(LONGINT i, LONGINT ub) {return __X(i, ub);} -LONGINT SYSTEM_RCHK(LONGINT i, LONGINT ub) {return __R(i, ub);} +// 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);} @@ -35,7 +38,7 @@ void SYSTEM_INHERIT(LONGINT *t, LONGINT *t0) void SYSTEM_ENUMP(void *adr, LONGINT n, void (*P)()) { while (n > 0) { - P((LONGINT)(SYSTEM_ADRINT)(*((void**)(adr)))); + P((uintptr)(*((void**)(adr)))); adr = ((void**)adr) + 1; n--; } @@ -48,20 +51,20 @@ void SYSTEM_ENUMR(void *adr, LONGINT *typ, LONGINT size, LONGINT n, void (*P)()) while (n > 0) { t = typ; off = *t; - while (off >= 0) {P(*(LONGINT*)((char*)adr+off)); t++; off = *t;} + while (off >= 0) {P(*(uintptr*)((char*)adr+off)); t++; off = *t;} adr = ((char*)adr) + size; n--; } } -LONGINT SYSTEM_DIV(uLONGINT x, uLONGINT y) -{ if ((LONGINT) x >= 0) return (x / y); +LONGINT SYSTEM_DIV(uint64 x, uint64 y) +{ if ((int64) x >= 0) return (x / y); else return -((y - 1 - x) / y); } -LONGINT SYSTEM_MOD(uLONGINT x, uLONGINT y) -{ uLONGINT m; - if ((LONGINT) x >= 0) return (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; } @@ -106,7 +109,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, else if (typ == (LONGINT*)POINTER__typ) { /* element type is a pointer */ x = Heap_NEWBLK(size + nofelems * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[-1]; + p = (LONGINT*)(uintptr)x[-1]; p[-nofelems] = *p; /* build new type desc in situ: 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nofelems - 1; n = 1; /* n =1 for skipping the size field */ while (n <= nofelems) {*p = n*sizeof(LONGINT); p++; n++;} @@ -119,7 +122,7 @@ SYSTEM_PTR SYSTEM_NEWARR(LONGINT *typ, LONGINT elemsz, int elemalgn, int nofdim, while (ptab[nofptrs] >= 0) {nofptrs++;} /* number of pointers per element */ nptr = nofelems * nofptrs; /* total number of pointers */ x = Heap_NEWBLK(size + nptr * sizeof(LONGINT)); - p = (LONGINT*)(SYSTEM_ADRINT)x[- 1]; + p = (LONGINT*)(uintptr)x[- 1]; p[-nptr] = *p; /* build new type desc in situ; 1. copy block size; 2. setup ptr tab; 3. set sentinel; 4. patch tag */ p -= nptr - 1; n = 0; off = dataoff; while (n < nofelems) {i = 0; @@ -155,7 +158,7 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler // (Ignore other signals) } - void SystemSetHandler(int s, SYSTEM_ADRINT h) { + void SystemSetHandler(int s, uintptr h) { if (s >= 2 && s <= 4) { int needtosetsystemhandler = handler[s-2] == 0; handler[s-2] = (SystemSignalHandler)h; @@ -194,12 +197,12 @@ typedef void (*SystemSignalHandler)(INTEGER); // = Platform_SignalHandler } } - void SystemSetInterruptHandler(SYSTEM_ADRINT h) { + void SystemSetInterruptHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemInterruptHandler = (SystemSignalHandler)h; } - void SystemSetQuitHandler(SYSTEM_ADRINT h) { + void SystemSetQuitHandler(uintptr h) { EnsureConsoleCtrlHandler(); SystemQuitHandler = (SystemSignalHandler)h; } diff --git a/src/system/SYSTEM.h b/src/system/SYSTEM.h index 2cab2429..c83f69f1 100644 --- a/src/system/SYSTEM.h +++ b/src/system/SYSTEM.h @@ -1,6 +1,27 @@ #ifndef SYSTEM__h #define SYSTEM__h +// Declare memcpy in a way compatible with C compilers intrinsic +// built in implementations. + +#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) + #if defined(_WIN64) + typedef unsigned long long size_t; + #else + typedef unsigned long size_t; + #endif +#else + typedef unsigned int size_t; +#endif + +#define _SIZE_T_DECLARED // For FreeBSD +#define _SIZE_T_DEFINED_ // For OpenBSD + +void *memcpy(void *dest, const void *source, size_t size); + + +// Declare fixed size versions of basic intger types + #if defined(_WIN64) typedef long long int64; typedef unsigned long long uint64; @@ -18,20 +39,7 @@ typedef unsigned short int uint16; typedef signed char int8; typedef unsigned char uint8; -#if (__SIZEOF_POINTER__ == 8) || defined(_WIN64) || defined(__LP64__) - #if defined(_WIN64) - typedef unsigned long long size_t; - #else - typedef unsigned long size_t; - #endif -#else - typedef unsigned int size_t; -#endif - -#define _SIZE_T_DECLARED // For FreeBSD -#define _SIZE_T_DEFINED_ // For OpenBSD - -void *memcpy(void *dest, const void *source, size_t size); +#define uintptr size_t // The compiler uses 'import' and 'export' which translate to 'extern' and @@ -46,7 +54,7 @@ void *memcpy(void *dest, const void *source, size_t size); #define NIL ((void*)0) #define __MAXEXT 16 -#define POINTER__typ ((LONGINT*)(1)) // not NIL and not a valid type +#define POINTER__typ ((uintptr*)(1)) // not NIL and not a valid type // Oberon types @@ -60,7 +68,7 @@ typedef float REAL; typedef double LONGREAL; typedef void* SYSTEM_PTR; -typedef size_t SYSTEM_ADRINT; +typedef uintptr SYSTEM_ADRINT; // For 32 bit builds, the size of LONGINT depends on a make option: @@ -68,18 +76,19 @@ typedef size_t SYSTEM_ADRINT; #if (__SIZEOF_POINTER__ == 8) || defined(LARGE) || defined(_WIN64) typedef int32 INTEGER; typedef int64 LONGINT; - typedef uint64 uLONGINT; + typedef uint64 SET; + typedef uint64 uSET; #else typedef int16 INTEGER; typedef int32 LONGINT; - typedef uint32 uLONGINT; + typedef uint32 SET; + typedef uint32 uSET; #endif -// Unsigned variants are for use by shift and rotate macros. -typedef uLONGINT SET; -typedef uLONGINT uSET; +// Temporary defs while bootstrapping +#define uLONGINT uint64 @@ -90,32 +99,32 @@ typedef uLONGINT uSET; // OS Memory allocation interfaces are in PlatformXXX.Mod -extern LONGINT Platform_OSAllocate (LONGINT size); -extern void Platform_OSFree (LONGINT addr); +extern uintptr Platform_OSAllocate (uintptr size); +extern void Platform_OSFree (uintptr addr); // Run time system routines in SYSTEM.c -extern LONGINT SYSTEM_XCHK (LONGINT i, LONGINT ub); -extern LONGINT SYSTEM_RCHK (LONGINT i, LONGINT ub); +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 (uLONGINT x, uLONGINT y); -extern LONGINT SYSTEM_MOD (uLONGINT x, uLONGINT y); +extern LONGINT SYSTEM_DIV (uint64 x, uint64 y); +extern LONGINT SYSTEM_MOD (uint64 x, uint64 y); extern LONGINT SYSTEM_ENTIER (double x); // Signal handling in SYSTEM.c #ifndef _WIN32 - extern void SystemSetHandler(int s, SYSTEM_ADRINT h); + extern void SystemSetHandler(int s, uintptr h); #else - extern void SystemSetInterruptHandler(SYSTEM_ADRINT h); - extern void SystemSetQuitHandler (SYSTEM_ADRINT h); + extern void SystemSetInterruptHandler(uintptr h); + extern void SystemSetQuitHandler (uintptr h); #endif @@ -138,11 +147,18 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __COPY(s, d, n) {char*_a=(void*)s,*_b=(void*)d; LONGINT _i=0,_t=n-1; \ while(_i<_t&&((_b[_i]=_a[_i])!=0)){_i++;};_b[_i]=0;} -#define __DUP(x, l, t) x=(void*)memcpy((void*)(SYSTEM_ADRINT)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) +#define __DUP(x, l, t) x=(void*)memcpy((void*)(uintptr)Platform_OSAllocate(l*sizeof(t)),x,l*sizeof(t)) #define __DUPARR(v, t) v=(void*)memcpy(v##__copy,v,sizeof(t)) -#define __DEL(x) Platform_OSFree((LONGINT)(SYSTEM_ADRINT)x) +#define __DEL(x) Platform_OSFree((LONGINT)(uintptr)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 */ @@ -150,24 +166,24 @@ static int __str_cmp(CHAR *x, CHAR *y){ #define __VAL(t, x) (*(t*)&(x)) -#define __GET(a, x, t) x= *(t*)(SYSTEM_ADRINT)(a) -#define __PUT(a, x, t) *(t*)(SYSTEM_ADRINT)(a)=x +#define __GET(a, x, t) x= *(t*)(uintptr)(a) +#define __PUT(a, x, t) *(t*)(uintptr)(a)=x #define __LSHL(x, n, t) ((t)((u##t)(x)<<(n))) #define __LSHR(x, n, t) ((t)((u##t)(x)>>(n))) #define __LSH(x, n, t) ((n)>=0? __LSHL(x, n, t): __LSHR(x, -(n), t)) -#define __ASHL(x, n) ((LONGINT)(x)<<(n)) -#define __ASHR(x, n) ((LONGINT)(x)>>(n)) -#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) - #define __ROTL(x, n, t) ((t)((u##t)(x)<<(n)|(u##t)(x)>>(8*sizeof(t)-(n)))) #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 __BIT(x, n) (*(uLONGINT*)(x)>>(n)&1) -#define __MOVE(s, d, n) memcpy((char*)(SYSTEM_ADRINT)(d),(char*)(SYSTEM_ADRINT)(s),n) +#define __ASHL(x, n) ((LONGINT)(x)<<(n)) +#define __ASHR(x, n) ((LONGINT)(x)>>(n)) +#define __ASH(x, n) ((n)>=0?__ASHL(x,n):__ASHR(x,-(n))) #define __ASHF(x, n) SYSTEM_ASH((LONGINT)(x), (LONGINT)(n)) + +#define __BIT(x, n) (*(uint64*)(x)>>(n)&1) +#define __MOVE(s, d, n) memcpy((char*)(uintptr)(d),(char*)(uintptr)(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)) @@ -191,10 +207,6 @@ static int __str_cmp(CHAR *x, CHAR *y){ // Runtime checks -#define __X(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-2),0)) -#define __XF(i, ub) SYSTEM_XCHK((LONGINT)(i), (LONGINT)(ub)) -#define __R(i, ub) (((uLONGINT)(i)<(uLONGINT)(ub))?i:(__HALT(-8),0)) -#define __RF(i, ub) SYSTEM_RCHK((LONGINT)(i),(LONGINT)(ub)) #define __RETCHK __retchk: __HALT(-3); return 0; #define __CASECHK __HALT(-4) #define __WITHCHK __HALT(-7) @@ -227,7 +239,7 @@ extern void Heap_INCREF(); extern void Platform_Init(INTEGER argc, LONGINT argv); extern void Heap_FINALL(); -#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(SYSTEM_ADRINT)&argv); +#define __INIT(argc, argv) static void *m; Platform_Init((INTEGER)argc, (LONGINT)(uintptr)&argv); #define __REGMAIN(name, enum) m = Heap_REGMOD((CHAR*)name,enum) #define __FINI Heap_FINALL(); return 0 @@ -248,7 +260,7 @@ extern SYSTEM_PTR Heap_NEWREC (LONGINT tag); extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __SYSNEW(p, len) p = Heap_NEWBLK((LONGINT)(len)) -#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(SYSTEM_ADRINT)t##__typ) +#define __NEW(p, t) p = Heap_NEWREC((LONGINT)(uintptr)t##__typ) #define __NEWARR SYSTEM_NEWARR @@ -279,20 +291,20 @@ extern SYSTEM_PTR SYSTEM_NEWARR(LONGINT*, LONGINT, int, int, int, ...); #define __INITYP(t, t0, level) \ t##__typ = (LONGINT*)&t##__desc.blksz; \ memcpy(t##__desc.basep, t0##__typ - __BASEOFF, level*sizeof(LONGINT)); \ - t##__desc.basep[level] = (LONGINT)(SYSTEM_ADRINT)t##__typ; \ - t##__desc.module = (LONGINT)(SYSTEM_ADRINT)m; \ + t##__desc.basep[level] = (LONGINT)(uintptr)t##__typ; \ + t##__desc.module = (LONGINT)(uintptr)m; \ if(t##__desc.blksz!=sizeof(struct t)) __HALT(-15); \ t##__desc.blksz = (t##__desc.blksz+5*sizeof(LONGINT)-1)/(4*sizeof(LONGINT))*(4*sizeof(LONGINT)); \ - Heap_REGTYP(m, (LONGINT)(SYSTEM_ADRINT)&t##__desc.next); \ + Heap_REGTYP(m, (LONGINT)(uintptr)&t##__desc.next); \ SYSTEM_INHERIT(t##__typ, t0##__typ) -#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(SYSTEM_ADRINT)typ##__typ) -#define __TYPEOF(p) ((LONGINT*)(SYSTEM_ADRINT)(*(((LONGINT*)(p))-1))) +#define __IS(tag, typ, level) (*(tag-(__BASEOFF-level))==(LONGINT)(uintptr)typ##__typ) +#define __TYPEOF(p) ((LONGINT*)(uintptr)(*(((LONGINT*)(p))-1))) #define __ISP(p, typ, level) __IS(__TYPEOF(p),typ,level) // Oberon-2 type bound procedures support -#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(SYSTEM_ADRINT)proc -#define __SEND(typ, num, funtyp, parlist) ((funtyp)((SYSTEM_ADRINT)*(typ-(__TPROC0OFF+num))))parlist +#define __INITBP(t, proc, num) *(t##__typ-(__TPROC0OFF+num))=(LONGINT)(uintptr)proc +#define __SEND(typ, num, funtyp, parlist) ((funtyp)((uintptr)*(typ-(__TPROC0OFF+num))))parlist