diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index 40ee14ce..532bfc28 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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/07/19] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/07/21] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index bf6756e8..9c7095b9 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a17cab07..2119fef2 100644 --- a/bootstrap/unix-44/Console.c +++ b/bootstrap/unix-44/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a4799f33..8558cf0e 100644 --- a/bootstrap/unix-44/Console.h +++ b/bootstrap/unix-44/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 4ca7a5cf..4834d8bc 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" @@ -7,7 +7,7 @@ #include "Strings.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef struct Files_BufDesc { @@ -24,14 +24,15 @@ typedef CHAR Files_FileName[101]; typedef - struct Files_Handle { + struct Files_FileDesc { Files_FileName workName, registerName; BOOLEAN tempFile; Platform_FileIdentity identity; LONGINT fd, len, pos; Files_Buffer bufs[4]; INTEGER swapper, state; - } Files_Handle; + Files_File next; + } Files_FileDesc; typedef struct Files_Rider { @@ -42,7 +43,7 @@ typedef } Files_Rider; -static LONGINT Files_fileTab[256]; +static Files_File Files_files; static INTEGER Files_tempno; static CHAR Files_HOME[1024]; static struct { @@ -50,7 +51,7 @@ static struct { CHAR data[1]; } *Files_SearchPath; -export LONGINT *Files_Handle__typ; +export LONGINT *Files_FileDesc__typ; export LONGINT *Files_BufDesc__typ; export LONGINT *Files_Rider__typ; @@ -58,6 +59,7 @@ export Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); static Files_File Files_CacheEntry (Platform_FileIdentity identity); export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res); export void Files_Close (Files_File f); +static void Files_CloseOSFile (Files_File f); static void Files_Create (Files_File f); export void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res); static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode); @@ -68,7 +70,6 @@ export void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d); export void Files_GetName (Files_File f, CHAR *name, LONGINT name__len); static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len); static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len); -static void Files_Init (void); export LONGINT Files_Length (Files_File f); static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len); export Files_File Files_New (CHAR *name, LONGINT name__len); @@ -225,26 +226,14 @@ static void Files_Create (Files_File f) error = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && f->fd >= 256)) { - if ((done && f->fd >= 256)) { - error = Platform_Close(f->fd); - } - Heap_GC(1); - error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); - done = f->fd == 0; - } if (done) { - if (f->fd >= 256) { - error = Platform_Close(f->fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); - } else { - Files_fileTab[f->fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; - Heap_RegisterFinalizer((void*)f, Files_Finalize); - f->state = 0; - f->pos = 0; - error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); - } + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; + Heap_RegisterFinalizer((void*)f, Files_Finalize); + f->state = 0; + f->pos = 0; + error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); } else { if (Platform_NoSuchDirectory(error)) { __MOVE("no such directory", err, 18); @@ -281,6 +270,27 @@ static void Files_Flush (Files_Buffer buf) } } +static void Files_CloseOSFile (Files_File f) +{ + Files_File prev = NIL; + INTEGER error; + if (Files_files == f) { + Files_files = f->next; + } else { + prev = Files_files; + while ((prev != NIL && prev->next != f)) { + prev = prev->next; + } + if (prev->next != NIL) { + prev->next = f->next; + } + } + error = Platform_Close(f->fd); + f->fd = -1; + f->state = 1; + Heap_FileCount -= 1; +} + void Files_Close (Files_File f) { LONGINT i; @@ -296,11 +306,7 @@ void Files_Close (Files_File f) if (error != 0) { Files_Err((CHAR*)"error writing file", (LONGINT)19, f, error); } - Files_fileTab[f->fd] = 0; - error = Platform_Close(f->fd); - f->fd = -1; - f->state = 1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); } } @@ -316,7 +322,7 @@ Files_File Files_New (CHAR *name, LONGINT name__len) Files_File _o_result; Files_File f = NIL; __DUP(name, name__len, CHAR); - __NEW(f, Files_Handle); + __NEW(f, Files_FileDesc); f->workName[0] = 0x00; __COPY(name, f->registerName, ((LONGINT)(101))); f->fd = -1; @@ -392,10 +398,9 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) Files_File _o_result; Files_File f = NIL; INTEGER i, error; - i = 0; - while (i < 256) { - f = (Files_File)(uintptr_t)Files_fileTab[i]; - if ((f != NIL && Platform_SameFile(identity, f->identity))) { + f = Files_files; + while (f != NIL) { + if (Platform_SameFile(identity, f->identity)) { if (!Platform_SameFileTime(identity, f->identity)) { i = 0; while (i < 4) { @@ -412,7 +417,7 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) _o_result = f; return _o_result; } - i += 1; + f = f->next; } _o_result = NIL; return _o_result; @@ -442,16 +447,8 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) for (;;) { error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && fd >= 256)) { - if ((done && fd >= 256)) { - error = Platform_Close(fd); - } - Heap_GC(1); - error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); - done = error == 0; - if ((!done && Platform_TooManyFiles(error))) { - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); - } + if ((!done && Platform_TooManyFiles(error))) { + Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); } if ((!done && Platform_Inaccessible(error))) { error = Platform_OldRO((void*)path, ((LONGINT)(256)), &fd); @@ -468,17 +465,11 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) error = Platform_Identify(fd, &identity, Platform_FileIdentity__typ); f = Files_CacheEntry(identity); if (f != NIL) { - error = Platform_Close(fd); _o_result = f; __DEL(name); return _o_result; - } else if (fd >= 256) { - error = Platform_Close(fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); } else { - __NEW(f, Files_Handle); - Files_fileTab[fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; + __NEW(f, Files_FileDesc); Heap_RegisterFinalizer((void*)f, Files_Finalize); f->fd = fd; f->state = 0; @@ -489,6 +480,9 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) f->registerName[0] = 0x00; f->tempFile = 0; f->identity = identity; + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; _o_result = f; __DEL(name); return _o_result; @@ -1014,10 +1008,7 @@ static void Files_Finalize (SYSTEM_PTR o) LONGINT res; f = (Files_File)(uintptr_t)o; if (f->fd >= 0) { - Files_fileTab[f->fd] = 0; - res = Platform_Close(f->fd); - f->fd = -1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); if (f->tempFile) { res = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); } @@ -1036,27 +1027,13 @@ void Files_SetSearchPath (CHAR *path, LONGINT path__len) __DEL(path); } -static void Files_Init (void) -{ - LONGINT i; - i = 0; - while (i < 256) { - Files_fileTab[i] = 0; - i += 1; - } - Files_tempno = -1; - Heap_FileCount = 0; - Files_SearchPath = NIL; - Files_HOME[0] = 0x00; - Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); -} - static void EnumPtrs(void (*P)(void*)) { + P(Files_files); P(Files_SearchPath); } -__TDESC(Files_Handle, 1, 4) = {__TDFLDS("Handle", 248), {228, 232, 236, 240, -20}}; +__TDESC(Files_FileDesc, 1, 5) = {__TDFLDS("FileDesc", 252), {228, 232, 236, 240, 248, -24}}; __TDESC(Files_BufDesc, 1, 1) = {__TDFLDS("BufDesc", 4112), {0, -8}}; __TDESC(Files_Rider, 1, 1) = {__TDFLDS("Rider", 20), {8, -8}}; @@ -1069,10 +1046,13 @@ export void *Files__init(void) __MODULE_IMPORT(Platform); __MODULE_IMPORT(Strings); __REGMOD("Files", EnumPtrs); - __INITYP(Files_Handle, Files_Handle, 0); + __INITYP(Files_FileDesc, Files_FileDesc, 0); __INITYP(Files_BufDesc, Files_BufDesc, 0); __INITYP(Files_Rider, Files_Rider, 0); /* BEGIN */ - Files_Init(); + Files_tempno = -1; + Heap_FileCount = 0; + Files_HOME[0] = 0x00; + Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); __ENDMOD; } diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index 9e409adc..dbc01a40 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h @@ -6,14 +6,14 @@ #include "SYSTEM.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef - struct Files_Handle { + struct Files_FileDesc { char _prvt0[216]; LONGINT fd; - char _prvt1[28]; - } Files_Handle; + char _prvt1[32]; + } Files_FileDesc; typedef struct Files_Rider { @@ -24,7 +24,7 @@ typedef -import LONGINT *Files_Handle__typ; +import LONGINT *Files_FileDesc__typ; import LONGINT *Files_Rider__typ; import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index d6248ab0..6888d3b4 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tskSfF */ #include "SYSTEM.h" struct Heap__1 { diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index a7c115d1..4d58aaa0 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] 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 5e0ba69f..4051a16b 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 2387f45f..674b8179 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a69a396f..d5151e32 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 9391eccb..077cea05 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 81cadc05..358871cb 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "OPM.h" diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 27fe129c..8bf1d703 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 05ec3144..b3849a7b 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c5e413a3..58dd953e 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 877f2dc0..dddb24bb 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c7a155eb..51c1177d 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 e4fb2cf6..5d3430ff 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 73fb31d0..2c8af702 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 34c1acb6..8e4c0838 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index 998a6db8..0e0961c2 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index 1c086988..552dde2e 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPC.h" #include "OPM.h" diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index c9a566de..99e51118 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 2832d8d3..351690cc 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index f5315fd6..7f649145 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 146ece15..9174951e 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 79518e88..d68a783e 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 5ea5720d..0236f251 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 3a8ef7a3..db08524a 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 3bec2632..3303218b 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f8eeb41d..8818827b 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a5d922e9..8b14dc22 100644 --- a/bootstrap/unix-44/Vishap.c +++ b/bootstrap/unix-44/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkamSf */ #include "SYSTEM.h" #include "Configuration.h" #include "Heap.h" diff --git a/bootstrap/unix-44/errors.c b/bootstrap/unix-44/errors.c index e8272348..918c86fe 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 7a085f56..3762b03f 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 646b357b..fb1322bb 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 1c63c923..2530385b 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 67bed77e..0697fe1d 100644 --- a/bootstrap/unix-44/vt100.c +++ b/bootstrap/unix-44/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 83c4e777..bb6e8f9c 100644 --- a/bootstrap/unix-44/vt100.h +++ b/bootstrap/unix-44/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 40ee14ce..532bfc28 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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/07/19] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/07/21] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index bf6756e8..9c7095b9 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a17cab07..2119fef2 100644 --- a/bootstrap/unix-48/Console.c +++ b/bootstrap/unix-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a4799f33..8558cf0e 100644 --- a/bootstrap/unix-48/Console.h +++ b/bootstrap/unix-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 4ca7a5cf..4834d8bc 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" @@ -7,7 +7,7 @@ #include "Strings.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef struct Files_BufDesc { @@ -24,14 +24,15 @@ typedef CHAR Files_FileName[101]; typedef - struct Files_Handle { + struct Files_FileDesc { Files_FileName workName, registerName; BOOLEAN tempFile; Platform_FileIdentity identity; LONGINT fd, len, pos; Files_Buffer bufs[4]; INTEGER swapper, state; - } Files_Handle; + Files_File next; + } Files_FileDesc; typedef struct Files_Rider { @@ -42,7 +43,7 @@ typedef } Files_Rider; -static LONGINT Files_fileTab[256]; +static Files_File Files_files; static INTEGER Files_tempno; static CHAR Files_HOME[1024]; static struct { @@ -50,7 +51,7 @@ static struct { CHAR data[1]; } *Files_SearchPath; -export LONGINT *Files_Handle__typ; +export LONGINT *Files_FileDesc__typ; export LONGINT *Files_BufDesc__typ; export LONGINT *Files_Rider__typ; @@ -58,6 +59,7 @@ export Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); static Files_File Files_CacheEntry (Platform_FileIdentity identity); export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res); export void Files_Close (Files_File f); +static void Files_CloseOSFile (Files_File f); static void Files_Create (Files_File f); export void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res); static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode); @@ -68,7 +70,6 @@ export void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d); export void Files_GetName (Files_File f, CHAR *name, LONGINT name__len); static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len); static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len); -static void Files_Init (void); export LONGINT Files_Length (Files_File f); static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len); export Files_File Files_New (CHAR *name, LONGINT name__len); @@ -225,26 +226,14 @@ static void Files_Create (Files_File f) error = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && f->fd >= 256)) { - if ((done && f->fd >= 256)) { - error = Platform_Close(f->fd); - } - Heap_GC(1); - error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); - done = f->fd == 0; - } if (done) { - if (f->fd >= 256) { - error = Platform_Close(f->fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); - } else { - Files_fileTab[f->fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; - Heap_RegisterFinalizer((void*)f, Files_Finalize); - f->state = 0; - f->pos = 0; - error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); - } + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; + Heap_RegisterFinalizer((void*)f, Files_Finalize); + f->state = 0; + f->pos = 0; + error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); } else { if (Platform_NoSuchDirectory(error)) { __MOVE("no such directory", err, 18); @@ -281,6 +270,27 @@ static void Files_Flush (Files_Buffer buf) } } +static void Files_CloseOSFile (Files_File f) +{ + Files_File prev = NIL; + INTEGER error; + if (Files_files == f) { + Files_files = f->next; + } else { + prev = Files_files; + while ((prev != NIL && prev->next != f)) { + prev = prev->next; + } + if (prev->next != NIL) { + prev->next = f->next; + } + } + error = Platform_Close(f->fd); + f->fd = -1; + f->state = 1; + Heap_FileCount -= 1; +} + void Files_Close (Files_File f) { LONGINT i; @@ -296,11 +306,7 @@ void Files_Close (Files_File f) if (error != 0) { Files_Err((CHAR*)"error writing file", (LONGINT)19, f, error); } - Files_fileTab[f->fd] = 0; - error = Platform_Close(f->fd); - f->fd = -1; - f->state = 1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); } } @@ -316,7 +322,7 @@ Files_File Files_New (CHAR *name, LONGINT name__len) Files_File _o_result; Files_File f = NIL; __DUP(name, name__len, CHAR); - __NEW(f, Files_Handle); + __NEW(f, Files_FileDesc); f->workName[0] = 0x00; __COPY(name, f->registerName, ((LONGINT)(101))); f->fd = -1; @@ -392,10 +398,9 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) Files_File _o_result; Files_File f = NIL; INTEGER i, error; - i = 0; - while (i < 256) { - f = (Files_File)(uintptr_t)Files_fileTab[i]; - if ((f != NIL && Platform_SameFile(identity, f->identity))) { + f = Files_files; + while (f != NIL) { + if (Platform_SameFile(identity, f->identity)) { if (!Platform_SameFileTime(identity, f->identity)) { i = 0; while (i < 4) { @@ -412,7 +417,7 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) _o_result = f; return _o_result; } - i += 1; + f = f->next; } _o_result = NIL; return _o_result; @@ -442,16 +447,8 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) for (;;) { error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && fd >= 256)) { - if ((done && fd >= 256)) { - error = Platform_Close(fd); - } - Heap_GC(1); - error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); - done = error == 0; - if ((!done && Platform_TooManyFiles(error))) { - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); - } + if ((!done && Platform_TooManyFiles(error))) { + Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); } if ((!done && Platform_Inaccessible(error))) { error = Platform_OldRO((void*)path, ((LONGINT)(256)), &fd); @@ -468,17 +465,11 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) error = Platform_Identify(fd, &identity, Platform_FileIdentity__typ); f = Files_CacheEntry(identity); if (f != NIL) { - error = Platform_Close(fd); _o_result = f; __DEL(name); return _o_result; - } else if (fd >= 256) { - error = Platform_Close(fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); } else { - __NEW(f, Files_Handle); - Files_fileTab[fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; + __NEW(f, Files_FileDesc); Heap_RegisterFinalizer((void*)f, Files_Finalize); f->fd = fd; f->state = 0; @@ -489,6 +480,9 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) f->registerName[0] = 0x00; f->tempFile = 0; f->identity = identity; + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; _o_result = f; __DEL(name); return _o_result; @@ -1014,10 +1008,7 @@ static void Files_Finalize (SYSTEM_PTR o) LONGINT res; f = (Files_File)(uintptr_t)o; if (f->fd >= 0) { - Files_fileTab[f->fd] = 0; - res = Platform_Close(f->fd); - f->fd = -1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); if (f->tempFile) { res = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); } @@ -1036,27 +1027,13 @@ void Files_SetSearchPath (CHAR *path, LONGINT path__len) __DEL(path); } -static void Files_Init (void) -{ - LONGINT i; - i = 0; - while (i < 256) { - Files_fileTab[i] = 0; - i += 1; - } - Files_tempno = -1; - Heap_FileCount = 0; - Files_SearchPath = NIL; - Files_HOME[0] = 0x00; - Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); -} - static void EnumPtrs(void (*P)(void*)) { + P(Files_files); P(Files_SearchPath); } -__TDESC(Files_Handle, 1, 4) = {__TDFLDS("Handle", 248), {228, 232, 236, 240, -20}}; +__TDESC(Files_FileDesc, 1, 5) = {__TDFLDS("FileDesc", 252), {228, 232, 236, 240, 248, -24}}; __TDESC(Files_BufDesc, 1, 1) = {__TDFLDS("BufDesc", 4112), {0, -8}}; __TDESC(Files_Rider, 1, 1) = {__TDFLDS("Rider", 20), {8, -8}}; @@ -1069,10 +1046,13 @@ export void *Files__init(void) __MODULE_IMPORT(Platform); __MODULE_IMPORT(Strings); __REGMOD("Files", EnumPtrs); - __INITYP(Files_Handle, Files_Handle, 0); + __INITYP(Files_FileDesc, Files_FileDesc, 0); __INITYP(Files_BufDesc, Files_BufDesc, 0); __INITYP(Files_Rider, Files_Rider, 0); /* BEGIN */ - Files_Init(); + Files_tempno = -1; + Heap_FileCount = 0; + Files_HOME[0] = 0x00; + Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); __ENDMOD; } diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index 9e409adc..dbc01a40 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h @@ -6,14 +6,14 @@ #include "SYSTEM.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef - struct Files_Handle { + struct Files_FileDesc { char _prvt0[216]; LONGINT fd; - char _prvt1[28]; - } Files_Handle; + char _prvt1[32]; + } Files_FileDesc; typedef struct Files_Rider { @@ -24,7 +24,7 @@ typedef -import LONGINT *Files_Handle__typ; +import LONGINT *Files_FileDesc__typ; import LONGINT *Files_Rider__typ; import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index d6248ab0..6888d3b4 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tskSfF */ #include "SYSTEM.h" struct Heap__1 { diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index a7c115d1..4d58aaa0 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] 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 5e0ba69f..4051a16b 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 2387f45f..674b8179 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a69a396f..d5151e32 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 9391eccb..077cea05 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 81cadc05..358871cb 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "OPM.h" diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 27fe129c..8bf1d703 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 05ec3144..b3849a7b 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c5e413a3..58dd953e 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 877f2dc0..dddb24bb 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c7a155eb..51c1177d 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 e4fb2cf6..5d3430ff 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 73fb31d0..2c8af702 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 34c1acb6..8e4c0838 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index 998a6db8..0e0961c2 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index 1c086988..552dde2e 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPC.h" #include "OPM.h" diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index c9a566de..99e51118 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 2832d8d3..351690cc 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" typedef diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index f5315fd6..7f649145 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 146ece15..9174951e 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 79518e88..d68a783e 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 5ea5720d..0236f251 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 3a8ef7a3..db08524a 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 6e92e862..107d4836 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 169fe56b..612534d4 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a5d922e9..8b14dc22 100644 --- a/bootstrap/unix-48/Vishap.c +++ b/bootstrap/unix-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkamSf */ #include "SYSTEM.h" #include "Configuration.h" #include "Heap.h" diff --git a/bootstrap/unix-48/errors.c b/bootstrap/unix-48/errors.c index e8272348..918c86fe 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 7a085f56..3762b03f 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 646b357b..fb1322bb 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 1c63c923..2530385b 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 67bed77e..0697fe1d 100644 --- a/bootstrap/unix-48/vt100.c +++ b/bootstrap/unix-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 83c4e777..bb6e8f9c 100644 --- a/bootstrap/unix-48/vt100.h +++ b/bootstrap/unix-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 bdec7223..5ba6cdf8 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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/07/19] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/07/21] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index 00d35df8..4d9593cc 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 28a3d5cf..0e642fae 100644 --- a/bootstrap/unix-88/Console.c +++ b/bootstrap/unix-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 ae5997db..d1875d91 100644 --- a/bootstrap/unix-88/Console.h +++ b/bootstrap/unix-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f8e3a46a..e952925a 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" @@ -8,7 +8,7 @@ #include "Strings.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef struct Files_BufDesc { @@ -25,14 +25,15 @@ typedef CHAR Files_FileName[101]; typedef - struct Files_Handle { + struct Files_FileDesc { Files_FileName workName, registerName; BOOLEAN tempFile; Platform_FileIdentity identity; LONGINT fd, len, pos; Files_Buffer bufs[4]; INTEGER swapper, state; - } Files_Handle; + Files_File next; + } Files_FileDesc; typedef struct Files_Rider { @@ -43,7 +44,7 @@ typedef } Files_Rider; -static LONGINT Files_fileTab[256]; +static Files_File Files_files; static INTEGER Files_tempno; static CHAR Files_HOME[1024]; static struct { @@ -51,7 +52,7 @@ static struct { CHAR data[1]; } *Files_SearchPath; -export LONGINT *Files_Handle__typ; +export LONGINT *Files_FileDesc__typ; export LONGINT *Files_BufDesc__typ; export LONGINT *Files_Rider__typ; @@ -59,6 +60,7 @@ export Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); static Files_File Files_CacheEntry (Platform_FileIdentity identity); export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res); export void Files_Close (Files_File f); +static void Files_CloseOSFile (Files_File f); static void Files_Create (Files_File f); export void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res); static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode); @@ -69,7 +71,6 @@ export void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d); export void Files_GetName (Files_File f, CHAR *name, LONGINT name__len); static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len); static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len); -static void Files_Init (void); export LONGINT Files_Length (Files_File f); static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len); export Files_File Files_New (CHAR *name, LONGINT name__len); @@ -226,26 +227,14 @@ static void Files_Create (Files_File f) error = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && f->fd >= 256)) { - if ((done && f->fd >= 256)) { - error = Platform_Close(f->fd); - } - Heap_GC(1); - error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); - done = f->fd == 0; - } if (done) { - if (f->fd >= 256) { - error = Platform_Close(f->fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); - } else { - Files_fileTab[f->fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; - Heap_RegisterFinalizer((void*)f, Files_Finalize); - f->state = 0; - f->pos = 0; - error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); - } + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; + Heap_RegisterFinalizer((void*)f, Files_Finalize); + f->state = 0; + f->pos = 0; + error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); } else { if (Platform_NoSuchDirectory(error)) { __MOVE("no such directory", err, 18); @@ -282,6 +271,27 @@ static void Files_Flush (Files_Buffer buf) } } +static void Files_CloseOSFile (Files_File f) +{ + Files_File prev = NIL; + INTEGER error; + if (Files_files == f) { + Files_files = f->next; + } else { + prev = Files_files; + while ((prev != NIL && prev->next != f)) { + prev = prev->next; + } + if (prev->next != NIL) { + prev->next = f->next; + } + } + error = Platform_Close(f->fd); + f->fd = -1; + f->state = 1; + Heap_FileCount -= 1; +} + void Files_Close (Files_File f) { LONGINT i; @@ -297,11 +307,7 @@ void Files_Close (Files_File f) if (error != 0) { Files_Err((CHAR*)"error writing file", (LONGINT)19, f, error); } - Files_fileTab[f->fd] = 0; - error = Platform_Close(f->fd); - f->fd = -1; - f->state = 1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); } } @@ -317,7 +323,7 @@ Files_File Files_New (CHAR *name, LONGINT name__len) Files_File _o_result; Files_File f = NIL; __DUP(name, name__len, CHAR); - __NEW(f, Files_Handle); + __NEW(f, Files_FileDesc); f->workName[0] = 0x00; __COPY(name, f->registerName, ((LONGINT)(101))); f->fd = -1; @@ -393,10 +399,9 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) Files_File _o_result; Files_File f = NIL; INTEGER i, error; - i = 0; - while (i < 256) { - f = (Files_File)(uintptr_t)Files_fileTab[i]; - if ((f != NIL && Platform_SameFile(identity, f->identity))) { + f = Files_files; + while (f != NIL) { + if (Platform_SameFile(identity, f->identity)) { if (!Platform_SameFileTime(identity, f->identity)) { i = 0; while (i < 4) { @@ -413,7 +418,7 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) _o_result = f; return _o_result; } - i += 1; + f = f->next; } _o_result = NIL; return _o_result; @@ -443,16 +448,8 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) for (;;) { error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && fd >= 256)) { - if ((done && fd >= 256)) { - error = Platform_Close(fd); - } - Heap_GC(1); - error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); - done = error == 0; - if ((!done && Platform_TooManyFiles(error))) { - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); - } + if ((!done && Platform_TooManyFiles(error))) { + Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); } if ((!done && Platform_Inaccessible(error))) { error = Platform_OldRO((void*)path, ((LONGINT)(256)), &fd); @@ -469,17 +466,11 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) error = Platform_Identify(fd, &identity, Platform_FileIdentity__typ); f = Files_CacheEntry(identity); if (f != NIL) { - error = Platform_Close(fd); _o_result = f; __DEL(name); return _o_result; - } else if (fd >= 256) { - error = Platform_Close(fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); } else { - __NEW(f, Files_Handle); - Files_fileTab[fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; + __NEW(f, Files_FileDesc); Heap_RegisterFinalizer((void*)f, Files_Finalize); f->fd = fd; f->state = 0; @@ -490,6 +481,9 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) f->registerName[0] = 0x00; f->tempFile = 0; f->identity = identity; + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; _o_result = f; __DEL(name); return _o_result; @@ -1015,10 +1009,7 @@ static void Files_Finalize (SYSTEM_PTR o) LONGINT res; f = (Files_File)(uintptr_t)o; if (f->fd >= 0) { - Files_fileTab[f->fd] = 0; - res = Platform_Close(f->fd); - f->fd = -1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); if (f->tempFile) { res = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); } @@ -1037,27 +1028,13 @@ void Files_SetSearchPath (CHAR *path, LONGINT path__len) __DEL(path); } -static void Files_Init (void) -{ - LONGINT i; - i = 0; - while (i < 256) { - Files_fileTab[i] = 0; - i += 1; - } - Files_tempno = -1; - Heap_FileCount = 0; - Files_SearchPath = NIL; - Files_HOME[0] = 0x00; - Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); -} - static void EnumPtrs(void (*P)(void*)) { + P(Files_files); P(Files_SearchPath); } -__TDESC(Files_Handle, 1, 4) = {__TDFLDS("Handle", 296), {256, 264, 272, 280, -40}}; +__TDESC(Files_FileDesc, 1, 5) = {__TDFLDS("FileDesc", 304), {256, 264, 272, 280, 296, -48}}; __TDESC(Files_BufDesc, 1, 1) = {__TDFLDS("BufDesc", 4128), {0, -16}}; __TDESC(Files_Rider, 1, 1) = {__TDFLDS("Rider", 40), {16, -16}}; @@ -1070,10 +1047,13 @@ export void *Files__init(void) __MODULE_IMPORT(Platform); __MODULE_IMPORT(Strings); __REGMOD("Files", EnumPtrs); - __INITYP(Files_Handle, Files_Handle, 0); + __INITYP(Files_FileDesc, Files_FileDesc, 0); __INITYP(Files_BufDesc, Files_BufDesc, 0); __INITYP(Files_Rider, Files_Rider, 0); /* BEGIN */ - Files_Init(); + Files_tempno = -1; + Heap_FileCount = 0; + Files_HOME[0] = 0x00; + Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); __ENDMOD; } diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 7b4ace20..88756ec8 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h @@ -7,14 +7,14 @@ #include "SYSTEM.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef - struct Files_Handle { + struct Files_FileDesc { char _prvt0[232]; LONGINT fd; - char _prvt1[56]; - } Files_Handle; + char _prvt1[64]; + } Files_FileDesc; typedef struct Files_Rider { @@ -25,7 +25,7 @@ typedef -import LONGINT *Files_Handle__typ; +import LONGINT *Files_FileDesc__typ; import LONGINT *Files_Rider__typ; import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 9122c75d..ab8bd793 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tskSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index 070c972a..1a13a9af 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] 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 0aae7575..d5411050 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 39c8f674..e6254a2e 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 592ee7e0..2b3ff4f7 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 3e8819ed..8b8d0a4c 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 008bc7ca..ebcd0651 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index a80eedad..1562be22 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 b5198578..40658c18 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 56fcf196..7d4b03b1 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 3adde5cb..a01ab45f 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 71e6e1fb..3df6ebfe 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 8e85be6e..c89a1322 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 dfa2d800..1ce9683e 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 57333946..a1ef6cf9 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index 7f7aff33..6f5f182a 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 1091acf3..dbdc1868 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPC.h" diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index 0370a1d7..1963d30e 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 7f0a4d64..d418ba24 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index 9ee31f1b..4145a946 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index 911df230..b82cd526 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f166c1b9..61320bbb 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index e767e842..090e4a68 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 94a70d57..b09d7336 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f5efee7c..a489adbb 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 5d8e0c33..1aaf0c32 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 822287a3..37d64ec3 100644 --- a/bootstrap/unix-88/Vishap.c +++ b/bootstrap/unix-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkamSf */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/unix-88/errors.c b/bootstrap/unix-88/errors.c index a54d8e43..3e819c0b 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 205ba3a1..14e6456a 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 327aeac4..816ab551 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f19d95a4..d9e89e69 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 4b742768..8a30b13f 100644 --- a/bootstrap/unix-88/vt100.c +++ b/bootstrap/unix-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 dd08fa37..49a57eb4 100644 --- a/bootstrap/unix-88/vt100.h +++ b/bootstrap/unix-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 40ee14ce..532bfc28 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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/07/19] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/07/21] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index bf6756e8..9c7095b9 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 84f4ea3b..79526e86 100644 --- a/bootstrap/windows-48/Console.c +++ b/bootstrap/windows-48/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a4799f33..8558cf0e 100644 --- a/bootstrap/windows-48/Console.h +++ b/bootstrap/windows-48/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 0eb0643d..ff9e1dd6 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "Console.h" @@ -7,7 +7,7 @@ #include "Strings.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef struct Files_BufDesc { @@ -24,14 +24,15 @@ typedef CHAR Files_FileName[101]; typedef - struct Files_Handle { + struct Files_FileDesc { Files_FileName workName, registerName; BOOLEAN tempFile; Platform_FileIdentity identity; LONGINT fd, len, pos; Files_Buffer bufs[4]; INTEGER swapper, state; - } Files_Handle; + Files_File next; + } Files_FileDesc; typedef struct Files_Rider { @@ -42,7 +43,7 @@ typedef } Files_Rider; -static LONGINT Files_fileTab[256]; +static Files_File Files_files; static INTEGER Files_tempno; static CHAR Files_HOME[1024]; static struct { @@ -50,7 +51,7 @@ static struct { CHAR data[1]; } *Files_SearchPath; -export LONGINT *Files_Handle__typ; +export LONGINT *Files_FileDesc__typ; export LONGINT *Files_BufDesc__typ; export LONGINT *Files_Rider__typ; @@ -58,6 +59,7 @@ export Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); static Files_File Files_CacheEntry (Platform_FileIdentity identity); export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res); export void Files_Close (Files_File f); +static void Files_CloseOSFile (Files_File f); static void Files_Create (Files_File f); export void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res); static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode); @@ -68,7 +70,6 @@ export void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d); export void Files_GetName (Files_File f, CHAR *name, LONGINT name__len); static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len); static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len); -static void Files_Init (void); export LONGINT Files_Length (Files_File f); static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len); export Files_File Files_New (CHAR *name, LONGINT name__len); @@ -225,26 +226,14 @@ static void Files_Create (Files_File f) error = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && f->fd >= 256)) { - if ((done && f->fd >= 256)) { - error = Platform_Close(f->fd); - } - Heap_GC(1); - error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); - done = f->fd == 0; - } if (done) { - if (f->fd >= 256) { - error = Platform_Close(f->fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); - } else { - Files_fileTab[f->fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; - Heap_RegisterFinalizer((void*)f, Files_Finalize); - f->state = 0; - f->pos = 0; - error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); - } + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; + Heap_RegisterFinalizer((void*)f, Files_Finalize); + f->state = 0; + f->pos = 0; + error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); } else { if (Platform_NoSuchDirectory(error)) { __MOVE("no such directory", err, 18); @@ -281,6 +270,27 @@ static void Files_Flush (Files_Buffer buf) } } +static void Files_CloseOSFile (Files_File f) +{ + Files_File prev = NIL; + INTEGER error; + if (Files_files == f) { + Files_files = f->next; + } else { + prev = Files_files; + while ((prev != NIL && prev->next != f)) { + prev = prev->next; + } + if (prev->next != NIL) { + prev->next = f->next; + } + } + error = Platform_Close(f->fd); + f->fd = -1; + f->state = 1; + Heap_FileCount -= 1; +} + void Files_Close (Files_File f) { LONGINT i; @@ -296,11 +306,7 @@ void Files_Close (Files_File f) if (error != 0) { Files_Err((CHAR*)"error writing file", (LONGINT)19, f, error); } - Files_fileTab[f->fd] = 0; - error = Platform_Close(f->fd); - f->fd = -1; - f->state = 1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); } } @@ -316,7 +322,7 @@ Files_File Files_New (CHAR *name, LONGINT name__len) Files_File _o_result; Files_File f = NIL; __DUP(name, name__len, CHAR); - __NEW(f, Files_Handle); + __NEW(f, Files_FileDesc); f->workName[0] = 0x00; __COPY(name, f->registerName, ((LONGINT)(101))); f->fd = -1; @@ -392,10 +398,9 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) Files_File _o_result; Files_File f = NIL; INTEGER i, error; - i = 0; - while (i < 256) { - f = (Files_File)(uintptr_t)Files_fileTab[i]; - if ((f != NIL && Platform_SameFile(identity, f->identity))) { + f = Files_files; + while (f != NIL) { + if (Platform_SameFile(identity, f->identity)) { if (!Platform_SameFileTime(identity, f->identity)) { i = 0; while (i < 4) { @@ -412,7 +417,7 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) _o_result = f; return _o_result; } - i += 1; + f = f->next; } _o_result = NIL; return _o_result; @@ -442,16 +447,8 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) for (;;) { error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && fd >= 256)) { - if ((done && fd >= 256)) { - error = Platform_Close(fd); - } - Heap_GC(1); - error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); - done = error == 0; - if ((!done && Platform_TooManyFiles(error))) { - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); - } + if ((!done && Platform_TooManyFiles(error))) { + Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); } if ((!done && Platform_Inaccessible(error))) { error = Platform_OldRO((void*)path, ((LONGINT)(256)), &fd); @@ -468,17 +465,11 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) error = Platform_Identify(fd, &identity, Platform_FileIdentity__typ); f = Files_CacheEntry(identity); if (f != NIL) { - error = Platform_Close(fd); _o_result = f; __DEL(name); return _o_result; - } else if (fd >= 256) { - error = Platform_Close(fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); } else { - __NEW(f, Files_Handle); - Files_fileTab[fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; + __NEW(f, Files_FileDesc); Heap_RegisterFinalizer((void*)f, Files_Finalize); f->fd = fd; f->state = 0; @@ -489,6 +480,9 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) f->registerName[0] = 0x00; f->tempFile = 0; f->identity = identity; + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; _o_result = f; __DEL(name); return _o_result; @@ -1014,10 +1008,7 @@ static void Files_Finalize (SYSTEM_PTR o) LONGINT res; f = (Files_File)(uintptr_t)o; if (f->fd >= 0) { - Files_fileTab[f->fd] = 0; - res = Platform_Close(f->fd); - f->fd = -1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); if (f->tempFile) { res = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); } @@ -1036,27 +1027,13 @@ void Files_SetSearchPath (CHAR *path, LONGINT path__len) __DEL(path); } -static void Files_Init (void) -{ - LONGINT i; - i = 0; - while (i < 256) { - Files_fileTab[i] = 0; - i += 1; - } - Files_tempno = -1; - Heap_FileCount = 0; - Files_SearchPath = NIL; - Files_HOME[0] = 0x00; - Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); -} - static void EnumPtrs(void (*P)(void*)) { + P(Files_files); P(Files_SearchPath); } -__TDESC(Files_Handle, 1, 4) = {__TDFLDS("Handle", 256), {236, 240, 244, 248, -20}}; +__TDESC(Files_FileDesc, 1, 5) = {__TDFLDS("FileDesc", 260), {236, 240, 244, 248, 256, -24}}; __TDESC(Files_BufDesc, 1, 1) = {__TDFLDS("BufDesc", 4112), {0, -8}}; __TDESC(Files_Rider, 1, 1) = {__TDFLDS("Rider", 20), {8, -8}}; @@ -1069,10 +1046,13 @@ export void *Files__init(void) __MODULE_IMPORT(Platform); __MODULE_IMPORT(Strings); __REGMOD("Files", EnumPtrs); - __INITYP(Files_Handle, Files_Handle, 0); + __INITYP(Files_FileDesc, Files_FileDesc, 0); __INITYP(Files_BufDesc, Files_BufDesc, 0); __INITYP(Files_Rider, Files_Rider, 0); /* BEGIN */ - Files_Init(); + Files_tempno = -1; + Heap_FileCount = 0; + Files_HOME[0] = 0x00; + Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); __ENDMOD; } diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index cac52834..4a470229 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h @@ -6,14 +6,14 @@ #include "SYSTEM.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef - struct Files_Handle { + struct Files_FileDesc { char _prvt0[224]; LONGINT fd; - char _prvt1[28]; - } Files_Handle; + char _prvt1[32]; + } Files_FileDesc; typedef struct Files_Rider { @@ -24,7 +24,7 @@ typedef -import LONGINT *Files_Handle__typ; +import LONGINT *Files_FileDesc__typ; import LONGINT *Files_Rider__typ; import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index d6248ab0..6888d3b4 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tskSfF */ #include "SYSTEM.h" struct Heap__1 { diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index a7c115d1..4d58aaa0 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] 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 5e0ba69f..4051a16b 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 2387f45f..674b8179 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a69a396f..d5151e32 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 9391eccb..077cea05 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 81cadc05..358871cb 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "Configuration.h" #include "OPM.h" diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 27fe129c..8bf1d703 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 05ec3144..b3849a7b 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c5e413a3..58dd953e 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 877f2dc0..dddb24bb 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c7a155eb..51c1177d 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 e4fb2cf6..5d3430ff 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 73fb31d0..2c8af702 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 34c1acb6..8e4c0838 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPM.h" #include "OPS.h" diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index 998a6db8..0e0961c2 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index 1c086988..552dde2e 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" #include "OPC.h" #include "OPM.h" diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index c9a566de..99e51118 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 8de5b802..3ba426f1 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 c72e975f..a912723a 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 146ece15..9174951e 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 79518e88..d68a783e 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 5ea5720d..0236f251 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #include "SYSTEM.h" diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 3a8ef7a3..db08524a 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 6e92e862..107d4836 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 169fe56b..612534d4 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a5d922e9..8b14dc22 100644 --- a/bootstrap/windows-48/Vishap.c +++ b/bootstrap/windows-48/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkamSf */ #include "SYSTEM.h" #include "Configuration.h" #include "Heap.h" diff --git a/bootstrap/windows-48/errors.c b/bootstrap/windows-48/errors.c index e8272348..918c86fe 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 7a085f56..3762b03f 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 646b357b..fb1322bb 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 1c63c923..2530385b 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 67bed77e..0697fe1d 100644 --- a/bootstrap/windows-48/vt100.c +++ b/bootstrap/windows-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 83c4e777..bb6e8f9c 100644 --- a/bootstrap/windows-48/vt100.h +++ b/bootstrap/windows-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 bdec7223..5ba6cdf8 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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/07/19] for gcc LP64 on cygwin", Configuration_versionLong, 41); + __MOVE("1.95 [2016/07/21] for gcc LP64 on cygwin", Configuration_versionLong, 41); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index 00d35df8..4d9593cc 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 82ab9c30..2ad8373b 100644 --- a/bootstrap/windows-88/Console.c +++ b/bootstrap/windows-88/Console.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 ae5997db..d1875d91 100644 --- a/bootstrap/windows-88/Console.h +++ b/bootstrap/windows-88/Console.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 cdaf4440..752e5c07 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" @@ -8,7 +8,7 @@ #include "Strings.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef struct Files_BufDesc { @@ -25,14 +25,15 @@ typedef CHAR Files_FileName[101]; typedef - struct Files_Handle { + struct Files_FileDesc { Files_FileName workName, registerName; BOOLEAN tempFile; Platform_FileIdentity identity; LONGINT fd, len, pos; Files_Buffer bufs[4]; INTEGER swapper, state; - } Files_Handle; + Files_File next; + } Files_FileDesc; typedef struct Files_Rider { @@ -43,7 +44,7 @@ typedef } Files_Rider; -static LONGINT Files_fileTab[256]; +static Files_File Files_files; static INTEGER Files_tempno; static CHAR Files_HOME[1024]; static struct { @@ -51,7 +52,7 @@ static struct { CHAR data[1]; } *Files_SearchPath; -export LONGINT *Files_Handle__typ; +export LONGINT *Files_FileDesc__typ; export LONGINT *Files_BufDesc__typ; export LONGINT *Files_Rider__typ; @@ -59,6 +60,7 @@ export Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); static Files_File Files_CacheEntry (Platform_FileIdentity identity); export void Files_ChangeDirectory (CHAR *path, LONGINT path__len, INTEGER *res); export void Files_Close (Files_File f); +static void Files_CloseOSFile (Files_File f); static void Files_Create (Files_File f); export void Files_Delete (CHAR *name, LONGINT name__len, INTEGER *res); static void Files_Err (CHAR *s, LONGINT s__len, Files_File f, INTEGER errcode); @@ -69,7 +71,6 @@ export void Files_GetDate (Files_File f, LONGINT *t, LONGINT *d); export void Files_GetName (Files_File f, CHAR *name, LONGINT name__len); static void Files_GetTempName (CHAR *finalName, LONGINT finalName__len, CHAR *name, LONGINT name__len); static BOOLEAN Files_HasDir (CHAR *name, LONGINT name__len); -static void Files_Init (void); export LONGINT Files_Length (Files_File f); static void Files_MakeFileName (CHAR *dir, LONGINT dir__len, CHAR *name, LONGINT name__len, CHAR *dest, LONGINT dest__len); export Files_File Files_New (CHAR *name, LONGINT name__len); @@ -226,26 +227,14 @@ static void Files_Create (Files_File f) error = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && f->fd >= 256)) { - if ((done && f->fd >= 256)) { - error = Platform_Close(f->fd); - } - Heap_GC(1); - error = Platform_New((void*)f->workName, ((LONGINT)(101)), &f->fd); - done = f->fd == 0; - } if (done) { - if (f->fd >= 256) { - error = Platform_Close(f->fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); - } else { - Files_fileTab[f->fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; - Heap_RegisterFinalizer((void*)f, Files_Finalize); - f->state = 0; - f->pos = 0; - error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); - } + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; + Heap_RegisterFinalizer((void*)f, Files_Finalize); + f->state = 0; + f->pos = 0; + error = Platform_Identify(f->fd, &f->identity, Platform_FileIdentity__typ); } else { if (Platform_NoSuchDirectory(error)) { __MOVE("no such directory", err, 18); @@ -282,6 +271,27 @@ static void Files_Flush (Files_Buffer buf) } } +static void Files_CloseOSFile (Files_File f) +{ + Files_File prev = NIL; + INTEGER error; + if (Files_files == f) { + Files_files = f->next; + } else { + prev = Files_files; + while ((prev != NIL && prev->next != f)) { + prev = prev->next; + } + if (prev->next != NIL) { + prev->next = f->next; + } + } + error = Platform_Close(f->fd); + f->fd = -1; + f->state = 1; + Heap_FileCount -= 1; +} + void Files_Close (Files_File f) { LONGINT i; @@ -297,11 +307,7 @@ void Files_Close (Files_File f) if (error != 0) { Files_Err((CHAR*)"error writing file", (LONGINT)19, f, error); } - Files_fileTab[f->fd] = 0; - error = Platform_Close(f->fd); - f->fd = -1; - f->state = 1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); } } @@ -317,7 +323,7 @@ Files_File Files_New (CHAR *name, LONGINT name__len) Files_File _o_result; Files_File f = NIL; __DUP(name, name__len, CHAR); - __NEW(f, Files_Handle); + __NEW(f, Files_FileDesc); f->workName[0] = 0x00; __COPY(name, f->registerName, ((LONGINT)(101))); f->fd = -1; @@ -393,10 +399,9 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) Files_File _o_result; Files_File f = NIL; INTEGER i, error; - i = 0; - while (i < 256) { - f = (Files_File)(uintptr_t)Files_fileTab[i]; - if ((f != NIL && Platform_SameFile(identity, f->identity))) { + f = Files_files; + while (f != NIL) { + if (Platform_SameFile(identity, f->identity)) { if (!Platform_SameFileTime(identity, f->identity)) { i = 0; while (i < 4) { @@ -413,7 +418,7 @@ static Files_File Files_CacheEntry (Platform_FileIdentity identity) _o_result = f; return _o_result; } - i += 1; + f = f->next; } _o_result = NIL; return _o_result; @@ -443,16 +448,8 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) for (;;) { error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); done = error == 0; - if ((!done && Platform_TooManyFiles(error)) || (done && fd >= 256)) { - if ((done && fd >= 256)) { - error = Platform_Close(fd); - } - Heap_GC(1); - error = Platform_OldRW((void*)path, ((LONGINT)(256)), &fd); - done = error == 0; - if ((!done && Platform_TooManyFiles(error))) { - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); - } + if ((!done && Platform_TooManyFiles(error))) { + Files_Err((CHAR*)"too many files open", (LONGINT)20, f, error); } if ((!done && Platform_Inaccessible(error))) { error = Platform_OldRO((void*)path, ((LONGINT)(256)), &fd); @@ -469,17 +466,11 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) error = Platform_Identify(fd, &identity, Platform_FileIdentity__typ); f = Files_CacheEntry(identity); if (f != NIL) { - error = Platform_Close(fd); _o_result = f; __DEL(name); return _o_result; - } else if (fd >= 256) { - error = Platform_Close(fd); - Files_Err((CHAR*)"too many files open", (LONGINT)20, f, 0); } else { - __NEW(f, Files_Handle); - Files_fileTab[fd] = (LONGINT)(uintptr_t)f; - Heap_FileCount += 1; + __NEW(f, Files_FileDesc); Heap_RegisterFinalizer((void*)f, Files_Finalize); f->fd = fd; f->state = 0; @@ -490,6 +481,9 @@ Files_File Files_Old (CHAR *name, LONGINT name__len) f->registerName[0] = 0x00; f->tempFile = 0; f->identity = identity; + f->next = Files_files; + Files_files = f; + Heap_FileCount += 1; _o_result = f; __DEL(name); return _o_result; @@ -1015,10 +1009,7 @@ static void Files_Finalize (SYSTEM_PTR o) LONGINT res; f = (Files_File)(uintptr_t)o; if (f->fd >= 0) { - Files_fileTab[f->fd] = 0; - res = Platform_Close(f->fd); - f->fd = -1; - Heap_FileCount -= 1; + Files_CloseOSFile(f); if (f->tempFile) { res = Platform_Unlink((void*)f->workName, ((LONGINT)(101))); } @@ -1037,27 +1028,13 @@ void Files_SetSearchPath (CHAR *path, LONGINT path__len) __DEL(path); } -static void Files_Init (void) -{ - LONGINT i; - i = 0; - while (i < 256) { - Files_fileTab[i] = 0; - i += 1; - } - Files_tempno = -1; - Heap_FileCount = 0; - Files_SearchPath = NIL; - Files_HOME[0] = 0x00; - Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); -} - static void EnumPtrs(void (*P)(void*)) { + P(Files_files); P(Files_SearchPath); } -__TDESC(Files_Handle, 1, 4) = {__TDFLDS("Handle", 312), {272, 280, 288, 296, -40}}; +__TDESC(Files_FileDesc, 1, 5) = {__TDFLDS("FileDesc", 320), {272, 280, 288, 296, 312, -48}}; __TDESC(Files_BufDesc, 1, 1) = {__TDFLDS("BufDesc", 4128), {0, -16}}; __TDESC(Files_Rider, 1, 1) = {__TDFLDS("Rider", 40), {16, -16}}; @@ -1070,10 +1047,13 @@ export void *Files__init(void) __MODULE_IMPORT(Platform); __MODULE_IMPORT(Strings); __REGMOD("Files", EnumPtrs); - __INITYP(Files_Handle, Files_Handle, 0); + __INITYP(Files_FileDesc, Files_FileDesc, 0); __INITYP(Files_BufDesc, Files_BufDesc, 0); __INITYP(Files_Rider, Files_Rider, 0); /* BEGIN */ - Files_Init(); + Files_tempno = -1; + Heap_FileCount = 0; + Files_HOME[0] = 0x00; + Platform_GetEnv((CHAR*)"HOME", (LONGINT)5, (void*)Files_HOME, ((LONGINT)(1024))); __ENDMOD; } diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 03f88e71..5889b25b 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tspkaSfF */ #ifndef Files__h #define Files__h @@ -7,14 +7,14 @@ #include "SYSTEM.h" typedef - struct Files_Handle *Files_File; + struct Files_FileDesc *Files_File; typedef - struct Files_Handle { + struct Files_FileDesc { char _prvt0[248]; LONGINT fd; - char _prvt1[56]; - } Files_Handle; + char _prvt1[64]; + } Files_FileDesc; typedef struct Files_Rider { @@ -25,7 +25,7 @@ typedef -import LONGINT *Files_Handle__typ; +import LONGINT *Files_FileDesc__typ; import LONGINT *Files_Rider__typ; import Files_File Files_Base (Files_Rider *r, LONGINT *r__typ); diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 9122c75d..ab8bd793 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin tskSfF */ #define LARGE #include "SYSTEM.h" diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index 070c972a..1a13a9af 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tskSfF */ +/* voc 1.95 [2016/07/21] 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 0aae7575..d5411050 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 39c8f674..e6254a2e 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 592ee7e0..2b3ff4f7 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 3e8819ed..8b8d0a4c 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 008bc7ca..ebcd0651 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index a80eedad..1562be22 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 b5198578..40658c18 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 56fcf196..7d4b03b1 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 3adde5cb..a01ab45f 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 71e6e1fb..3df6ebfe 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 8e85be6e..c89a1322 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 dfa2d800..1ce9683e 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin tspkaSfF */ +/* voc 1.95 [2016/07/21] 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 57333946..a1ef6cf9 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPM.h" diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index 7f7aff33..6f5f182a 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 1091acf3..dbdc1868 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #define LARGE #include "SYSTEM.h" #include "OPC.h" diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index 0370a1d7..1963d30e 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 3d29e466..6c415d24 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 a15fd477..c6f87611 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 911df230..b82cd526 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f166c1b9..61320bbb 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index e767e842..090e4a68 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 94a70d57..b09d7336 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f5efee7c..a489adbb 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 5d8e0c33..1aaf0c32 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 822287a3..37d64ec3 100644 --- a/bootstrap/windows-88/Vishap.c +++ b/bootstrap/windows-88/Vishap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkamSf */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkamSf */ #define LARGE #include "SYSTEM.h" #include "Configuration.h" diff --git a/bootstrap/windows-88/errors.c b/bootstrap/windows-88/errors.c index a54d8e43..3e819c0b 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 205ba3a1..14e6456a 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 327aeac4..816ab551 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 f19d95a4..d9e89e69 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 4b742768..8a30b13f 100644 --- a/bootstrap/windows-88/vt100.c +++ b/bootstrap/windows-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] 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 dd08fa37..49a57eb4 100644 --- a/bootstrap/windows-88/vt100.h +++ b/bootstrap/windows-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/07/19] for gcc LP64 on cygwin xtspkaSfF */ +/* voc 1.95 [2016/07/21] for gcc LP64 on cygwin xtspkaSfF */ #ifndef vt100__h #define vt100__h diff --git a/src/system/Files.Mod b/src/system/Files.Mod index 73a78028..02bc69fc 100644 --- a/src/system/Files.Mod +++ b/src/system/Files.Mod @@ -16,7 +16,6 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files CONST nofbufs = 4; bufsize = 4096; - fileTabSize = 256; (* 256 needed for Windows *) noDesc = -1; notDone = -1; @@ -31,17 +30,18 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files TYPE FileName = ARRAY 101 OF CHAR; - File* = POINTER TO Handle; + File* = POINTER TO FileDesc; Buffer = POINTER TO BufDesc; - Handle = RECORD + FileDesc = RECORD workName, registerName: FileName; tempFile: BOOLEAN; identity: Platform.FileIdentity; fd-: Platform.FileHandle; len, pos: LONGINT; bufs: ARRAY nofbufs OF Buffer; - swapper, state: INTEGER + swapper, state: INTEGER; + next: File; END; BufDesc = RECORD @@ -61,7 +61,7 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files VAR - fileTab: ARRAY fileTabSize OF LONGINT (*=File*); + files: File; (* List of files that have an OS file handle/descriptor assigned *) tempno: INTEGER; HOME: ARRAY 1024 OF CHAR; SearchPath: POINTER TO ARRAY OF CHAR; @@ -137,30 +137,16 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files error := Platform.New(f.workName, f.fd); done := error = 0; - (* In case of too many files, try just once more. *) - IF (~done & Platform.TooManyFiles(error)) OR (done & (f.fd >= fileTabSize)) THEN - IF done & (f.fd >= fileTabSize) THEN error := Platform.Close(f.fd) END; - Heap.GC(TRUE); - error := Platform.New(f.workName, f.fd); - done := f.fd = 0 - END; IF done THEN - IF f.fd >= fileTabSize THEN - (* Console.String("f.fd = "); Console.Int(f.fd,1); Console.Ln; *) - error := Platform.Close(f.fd); Err("too many files open", f, 0) - ELSE - fileTab[f.fd] := SYSTEM.VAL(LONGINT, f); - INC(Heap.FileCount); - Heap.RegisterFinalizer(f, Finalize); - f.state := open; - f.pos := 0; - error := Platform.Identify(f.fd, f.identity); - END + f.next := files; files := f; + INC(Heap.FileCount); + Heap.RegisterFinalizer(f, Finalize); + f.state := open; + f.pos := 0; + error := Platform.Identify(f.fd, f.identity); ELSE IF Platform.NoSuchDirectory(error) THEN err := "no such directory" - ELSIF Platform.TooManyFiles(error) THEN - (* Console.String("f.fd = "); Console.Int(f.fd,1); Console.Ln; *) - err := "too many files open" + ELSIF Platform.TooManyFiles(error) THEN err := "too many files open" ELSE err := "file not created" END; Err(err, f, error) @@ -201,30 +187,33 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files END END Flush; + + PROCEDURE CloseOSFile(f: File); + (* Close the OS file handle and remove f from 'files' *) + VAR prev: File; error: Platform.ErrorCode; + BEGIN + IF files = f THEN files := f.next + ELSE + prev := files; + WHILE (prev # NIL) & (prev.next # f) DO prev := prev.next END; + IF prev.next # NIL THEN prev.next := f.next END + END; + error := Platform.Close(f.fd); + f.fd := noDesc; f.state := create; DEC(Heap.FileCount); + END CloseOSFile; + + PROCEDURE Close* (f: File); VAR i: LONGINT; error: Platform.ErrorCode; BEGIN - (* - Console.String("Files.Close f.fd = "); Console.Int(f.fd,1); - Console.String(" f.registername = "); Console.String(f.registerName); - Console.String(", f.workName = "); Console.String(f.workName); Console.Ln; - *) IF (f.state # create) OR (f.registerName # "") THEN Create(f); i := 0; WHILE (i < nofbufs) & (f.bufs[i] # NIL) DO Flush(f.bufs[i]); INC(i) END; error := Platform.Sync(f.fd); - (* - Console.String("Syncing closed file. fd = "); Console.Int(f.fd, 1); - Console.String(" error = "); Console.Int(error,1); Console.Ln; - *) IF error # 0 THEN Err("error writing file", f, error) END; - (* Windows needs us to actually cose the file so that subsequent rename - will not encounter a sharing error. *) - fileTab[f.fd] := 0; - error := Platform.Close(f.fd); - f.fd := noDesc; f.state := create; DEC(Heap.FileCount); + CloseOSFile(f); END END Close; @@ -275,10 +264,9 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files PROCEDURE CacheEntry(identity: Platform.FileIdentity): File; VAR f: File; i: INTEGER; error: Platform.ErrorCode; - BEGIN i := 0; - WHILE i < fileTabSize DO - f := SYSTEM.VAL(File, fileTab[i]); - IF (f # NIL) & Platform.SameFile(identity, f.identity) THEN + BEGIN f := files; + WHILE f # NIL DO + IF Platform.SameFile(identity, f.identity) THEN IF ~Platform.SameFileTime(identity, f.identity) THEN i := 0; WHILE i < nofbufs DO IF f.bufs[i] # NIL THEN f.bufs[i].org := -1; f.bufs[i] := NIL END; @@ -289,7 +277,7 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files END; RETURN f END; - INC(i) + f := f.next END; RETURN NIL END CacheEntry; @@ -311,19 +299,11 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files END; LOOP error := Platform.OldRW(path, fd); done := error = 0; - IF (~done & Platform.TooManyFiles(error)) OR (done & (fd >= fileTabSize)) THEN - IF done & (fd >= fileTabSize) THEN error := Platform.Close(fd) END; - Heap.GC(TRUE); - error := Platform.OldRW(path, fd); done := error = 0; - IF ~done & Platform.TooManyFiles(error) THEN - (* Console.String("fd = "); Console.Int(fd,1); Console.Ln; *) - Err("too many files open", f, error) - END - END; + IF ~done & Platform.TooManyFiles(error) THEN Err("too many files open", f, error) END; IF ~done & Platform.Inaccessible(error) THEN error := Platform.OldRO(path, fd); done := error = 0; END; - IF (~done) & (~Platform.Absent(error)) THEN + IF ~done & ~Platform.Absent(error) THEN Console.String("Warning: Files.Old "); Console.String(name); Console.String(" error = "); Console.Int(error, 0); Console.Ln; END; @@ -331,16 +311,15 @@ MODULE Files; (* J. Templ 1.12. 89/12.4.95 Oberon files mapped onto Unix files (* Console.String(" fd = "); Console.Int(fd,1); Console.Ln; *) error := Platform.Identify(fd, identity); f := CacheEntry(identity); - IF f # NIL THEN error := Platform.Close(fd); RETURN f - ELSIF fd >= fileTabSize THEN - (* Console.String("fd = "); Console.Int(fd,1); Console.Ln; *) - error := Platform.Close(fd); - Err("too many files open", f, 0) - ELSE NEW(f); fileTab[fd] := SYSTEM.VAL(LONGINT, f); INC(Heap.FileCount); Heap.RegisterFinalizer(f, Finalize); + IF f # NIL THEN + (* error := Platform.Close(fd); DCWB: Either this should be removed or should call CloseOSFile. *) + RETURN f + ELSE NEW(f); Heap.RegisterFinalizer(f, Finalize); f.fd := fd; f.state := open; f.pos := 0; f.swapper := -1; (*all f.buf[i] = NIL*) error := Platform.Size(fd, f.len); COPY(name, f.workName); f.registerName := ""; f.tempFile := FALSE; f.identity := identity; + f.next := files; files := f; INC(Heap.FileCount); RETURN f END ELSIF dir = "" THEN RETURN NIL @@ -743,7 +722,7 @@ Especially Length would become fairly complex. Console.String(", f.workName = "); Console.String(f.workName); Console.Ln; *) IF f.fd >= 0 THEN - fileTab[f.fd] := 0; res := Platform.Close(f.fd); f.fd := -1; DEC(Heap.FileCount); + CloseOSFile(f); IF f.tempFile THEN res := Platform.Unlink(f.workName) END END END Finalize; @@ -758,15 +737,9 @@ Especially Length would become fairly complex. END END SetSearchPath; - PROCEDURE Init; - VAR i: LONGINT; - BEGIN - i := 0; WHILE i < fileTabSize DO fileTab[i] := 0; INC(i) END; - tempno := -1; - Heap.FileCount := 0; - SearchPath := NIL; - HOME := ""; Platform.GetEnv("HOME", HOME); - END Init; -BEGIN Init +BEGIN + tempno := -1; + Heap.FileCount := 0; + HOME := ""; Platform.GetEnv("HOME", HOME); END Files. diff --git a/src/tools/make/buildall.pl b/src/tools/make/buildall.pl index 19d8fc80..3363bbc4 100755 --- a/src/tools/make/buildall.pl +++ b/src/tools/make/buildall.pl @@ -6,6 +6,8 @@ use Cwd; my $branch = "master"; +if (defined($ARGV[0]) && ($ARGV[0] ne "")) {$branch = $ARGV[0]} + my %machines = ( "pi" => ['pi@pie', "sudo", "projects/oberon/vishap/voc", "make full"], "darwin" => ['dave@dcb', "sudo", "projects/oberon/vishap/voc", "make full"], diff --git a/src/tools/make/postpush.pl b/src/tools/make/postpush.pl index 2b3a2ad6..a65fbb86 100755 --- a/src/tools/make/postpush.pl +++ b/src/tools/make/postpush.pl @@ -36,7 +36,6 @@ for my $file (@{$modified}) { if ($buildneeded) { writelog "Post push github web hook for repository $repo, branch $branch, name $name. Build required."; - my $child = fork; if (not defined $child) {die "Fork failed.";} if ($child) { @@ -44,8 +43,8 @@ if ($buildneeded) { } else { close(STDIN); close(STDOUT); close(STDERR); # child process system 'echo Syncing voc>postpush.log'; - system '(cd voc && git pull) >>postpush.log'; - exec 'perl voc/src/tools/make/buildall.pl >/tmp/buildall.log'; + system '(cd voc; git pull; git checkout ' . $branch . ') >>postpush.log'; + exec 'perl voc/src/tools/make/buildall.pl ' . $branch . ' >/tmp/buildall.log'; exit; } } else {