--- a/ObjectFileLoader.st Thu Feb 13 15:46:48 2020 +0100
+++ b/ObjectFileLoader.st Thu Feb 13 18:00:27 2020 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
@@ -3061,26 +3063,26 @@
if (! __isArray(anInfoBuffer)
|| (__arraySize(anInfoBuffer) < 3)) {
- RETURN(nil);
+ RETURN(nil);
}
#ifdef GNU_DL
{
if (__isStringLike(pathName)) {
- if (dld_link(__stringVal(pathName))) {
- if (@global(Verbose) == true) {
- console_printf ("link file %s failed\n", __stringVal(pathName));
- }
- if (@global(ErrorPrinting) == true) {
- dld_perror("ObjectFileLoader - DLD error cant link");
- }
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING("DLD error");
- RETURN ( nil );
- }
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
- __STORE(anInfoBuffer, pathName);
- RETURN ( anInfoBuffer );
+ if (dld_link(__stringVal(pathName))) {
+ if (@global(Verbose) == true) {
+ console_printf ("link file %s failed\n", __stringVal(pathName));
+ }
+ if (@global(ErrorPrinting) == true) {
+ dld_perror("ObjectFileLoader - DLD error cant link");
+ }
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING("DLD error");
+ RETURN ( nil );
+ }
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
+ __STORE(anInfoBuffer, pathName);
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -3092,52 +3094,52 @@
int err;
if (__isStringLike(pathName)) {
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
- console_fflush(stderr);
- }
- //
- // LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also
- // in the directory of the loaded library, if an absolute path to
- // the library has been provided.
- // Note: this does not work for redirected library symbols, since they are
- // resolved ad symbol lookup time and not at library load time
- //
- handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: handle: %"_lx_"\n", (INT)handle);
- console_fflush(stderr);
- }
- if (handle == NULL) {
- char *msg;
-
- err = GetLastError();
- if ((@global(ErrorPrinting) == true)
- || (@global(Verbose) == true)) {
- console_fprintf (stderr,
- "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n",
- __stringVal(pathName), err);
- }
- @global(LastError) = @symbol(loadError);;
- @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
- switch (err) {
- case ERROR_BAD_FORMAT:
- msg = "LoadLibrary error - bad format";
- default:
- msg = "LoadLibrary error";
- break;
- }
- @global(LinkErrorMessage) = __MKSTRING(msg);
- RETURN ( nil );
- }
+ if (@global(Verbose) == true) {
+ console_fprintf(__win32_stderr(), "ObjectFileLoader [info]: loading dll: %s...\n", __stringVal(pathName));
+ console_fflush(__win32_stderr());
+ }
+ //
+ // LOAD_WITH_ALTERED_SEARCH_PATH causes follow-up dlls to be looked up also
+ // in the directory of the loaded library, if an absolute path to
+ // the library has been provided.
+ // Note: this does not work for redirected library symbols, since they are
+ // resolved ad symbol lookup time and not at library load time
+ //
+ handle = LoadLibraryEx(__stringVal(pathName), NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (@global(Verbose) == true) {
+ console_fprintf(__win32_stderr(), "ObjectFileLoader [info]: handle: %"_lx_"\n", (INT)handle);
+ console_fflush(__win32_stderr());
+ }
+ if (handle == NULL) {
+ char *msg;
+
+ err = GetLastError();
+ if ((@global(ErrorPrinting) == true)
+ || (@global(Verbose) == true)) {
+ console_fprintf (__win32_stderr(),
+ "ObjectFileLoader [warning]: LoadLibrary %s failed; error: %x\n",
+ __stringVal(pathName), err);
+ }
+ @global(LastError) = @symbol(loadError);;
+ @global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
+ switch (err) {
+ case ERROR_BAD_FORMAT:
+ msg = "LoadLibrary error - bad format";
+ default:
+ msg = "LoadLibrary error";
+ break;
+ }
+ @global(LinkErrorMessage) = __MKSTRING(msg);
+ RETURN ( nil );
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFFL );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFFL );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (UINT)handle & 0xFFFFFFFFL );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((UINT)handle >> 32) & 0xFFFFFFFFL );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (UINT)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((UINT)handle >> 16) & 0xFFFF );
# endif
- RETURN ( anInfoBuffer );
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -3150,21 +3152,21 @@
OBJ tmpName;
if (__isStringLike(pathName)) {
- if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
- if (@global(Verbose) == true) {
- console_printf ("link file %s failed\n", __stringVal(pathName));
- }
- @global(LinkErrorMessage) = __MKSTRING("dl_load error");
- RETURN ( nil );
- }
- /*
- * returns the name of the temporary ld-file
- * use that as handle ...
- */
- tmpName = __MKSTRING(ldname);
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
- __STORE(anInfoBuffer, tmpName);
- RETURN ( anInfoBuffer );
+ if ( dl_loadmod_only(__myName__, __stringVal(pathName), &ldname) == 0 ) {
+ if (@global(Verbose) == true) {
+ console_printf ("link file %s failed\n", __stringVal(pathName));
+ }
+ @global(LinkErrorMessage) = __MKSTRING("dl_load error");
+ RETURN ( nil );
+ }
+ /*
+ * returns the name of the temporary ld-file
+ * use that as handle ...
+ */
+ tmpName = __MKSTRING(ldname);
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = tmpName;
+ __STORE(anInfoBuffer, tmpName);
+ RETURN ( anInfoBuffer );
}
RETURN ( nil );
}
@@ -3177,53 +3179,53 @@
extern errno;
if (__isStringLike(pathName)) {
- objName = __stringVal(pathName);
-
- if (__isStringLike(@global(LibPath))) {
- libPath = __stringVal(@global(LibPath));
- } else {
- libPath = (char *)0;
- }
- if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
- if (@global(Verbose) == true) {
- char *messages[64];
- int i;
-
- console_fprintf (stderr,
- "ObjectFileLoader [info]: load file %s failed errno=%d\n",
- objName, errno);
-
- switch (errno) {
- case ENOEXEC:
- console_fprintf(stderr, " load messages:\n");
- loadquery(L_GETMESSAGES, messages, sizeof(messages));
- for (i=0; messages[i]; i++) {
- console_fprintf(stderr, " %s\n", messages[i]);
- }
- break;
- }
- } else {
- if (@global(ErrorPrinting) == true) {
- console_fprintf (stderr,
- "ObjectFileLoader [warning]: load file %s failed errno=%d\n",
- objName, errno);
- }
- }
- @global(LinkErrorMessage) = __MKSTRING("load error");
- RETURN ( nil );
- }
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle);
- }
+ objName = __stringVal(pathName);
+
+ if (__isStringLike(@global(LibPath))) {
+ libPath = __stringVal(@global(LibPath));
+ } else {
+ libPath = (char *)0;
+ }
+ if ( (handle = (int *) load(objName, 0, libPath)) == 0 ) {
+ if (@global(Verbose) == true) {
+ char *messages[64];
+ int i;
+
+ console_fprintf (stderr,
+ "ObjectFileLoader [info]: load file %s failed errno=%d\n",
+ objName, errno);
+
+ switch (errno) {
+ case ENOEXEC:
+ console_fprintf(stderr, " load messages:\n");
+ loadquery(L_GETMESSAGES, messages, sizeof(messages));
+ for (i=0; messages[i]; i++) {
+ console_fprintf(stderr, " %s\n", messages[i]);
+ }
+ break;
+ }
+ } else {
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf (stderr,
+ "ObjectFileLoader [warning]: load file %s failed errno=%d\n",
+ objName, errno);
+ }
+ }
+ @global(LinkErrorMessage) = __MKSTRING("load error");
+ RETURN ( nil );
+ }
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFIleLoader [info]: load %s handle = %x\n", objName, handle);
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
# endif
- RETURN (anInfoBuffer);
+ RETURN (anInfoBuffer);
}
RETURN ( nil );
}
@@ -3237,35 +3239,35 @@
char *errMsg;
if ((pathName == nil) || __isStringLike(pathName)) {
- INT lowHandle, hiHandle;
-
- handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW);
-
- if (! handle) {
- errMsg = (char *) dlerror();
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
- console_fprintf(stderr, " <%s>\n", errMsg);
- }
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING(errMsg);
- RETURN (nil);
- }
-
- if (@global(Verbose) == true) {
- console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
- }
+ INT lowHandle, hiHandle;
+
+ handle = (void *)dlopen(pathName == nil ? 0 : __stringVal(pathName), RTLD_NOW);
+
+ if (! handle) {
+ errMsg = (char *) dlerror();
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [warning]: dlopen %s error:\n", __stringVal(pathName));
+ console_fprintf(stderr, " <%s>\n", errMsg);
+ }
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING(errMsg);
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true) {
+ console_fprintf(stderr, "ObjectFileLoader [info]: open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
+ }
#if __POINTER_SIZE__ == 8
- lowHandle = (INT)handle & 0xFFFFFFFFL;
- hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
+ lowHandle = (INT)handle & 0xFFFFFFFFL;
+ hiHandle = ((INT)handle >> 32) & 0xFFFFFFFFL;
#else
- lowHandle = (INT)handle & 0xFFFF;
- hiHandle = ((INT)handle >> 16) & 0xFFFF;
+ lowHandle = (INT)handle & 0xFFFF;
+ hiHandle = ((INT)handle >> 16) & 0xFFFF;
#endif
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
- RETURN (anInfoBuffer);
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT(lowHandle);
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT(hiHandle);
+ RETURN (anInfoBuffer);
}
}
#endif
@@ -3278,49 +3280,49 @@
char *errMsg;
if (__isStringLike(pathName)) {
- handle = (void *)shl_load(__stringVal(pathName),
- BIND_IMMEDIATE, 0L /* address */);
-
- if (! handle) {
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName));
- }
- @global(LastError) = @symbol(linkError);
- switch (errno) {
- case ENOEXEC:
- errMsg = "not a shared library";
- break;
- case ENOSYM:
- errMsg = "undefined symbols";
- break;
- case ENOMEM:
- errMsg = "out of memory";
- break;
- case ENOENT:
- errMsg = "non existing library";
- break;
- case EACCES:
- errMsg = "permission denied";
- break;
- default:
- errMsg = "unspecified error";
- break;
- }
- @global(LinkErrorMessage) = __MKSTRING(errMsg);
- RETURN (nil);
- }
-
- if (@global(Verbose) == true) {
- console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
- }
+ handle = (void *)shl_load(__stringVal(pathName),
+ BIND_IMMEDIATE, 0L /* address */);
+
+ if (! handle) {
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "shl_load %s error:\n", __stringVal(pathName));
+ }
+ @global(LastError) = @symbol(linkError);
+ switch (errno) {
+ case ENOEXEC:
+ errMsg = "not a shared library";
+ break;
+ case ENOSYM:
+ errMsg = "undefined symbols";
+ break;
+ case ENOMEM:
+ errMsg = "out of memory";
+ break;
+ case ENOENT:
+ errMsg = "non existing library";
+ break;
+ case EACCES:
+ errMsg = "permission denied";
+ break;
+ default:
+ errMsg = "unspecified error";
+ break;
+ }
+ @global(LinkErrorMessage) = __MKSTRING(errMsg);
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true) {
+ console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
+ }
# if __POINTER_SIZE__ == 8
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFFFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 32) & 0xFFFFFFFF );
# else
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF);
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
- RETURN (anInfoBuffer);
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (INT)handle & 0xFFFF);
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((INT)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
# endif
}
}
@@ -3332,28 +3334,28 @@
void *handle;
if ((pathName == nil) || __isStringLike(pathName)) {
- if (pathName == nil)
- handle = dlopen((char *)0, 1);
- else
- handle = dlopen(__stringVal(pathName), 1);
-
- if (! handle) {
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "dlopen %s error: <%s>\n",
- __stringVal(pathName), dlerror());
- }
- @global(LastError) = @symbol(linkError);
- @global(LinkErrorMessage) = __MKSTRING("dlopen error");
- RETURN (nil);
- }
-
- if (@global(Verbose) == true) {
- console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
- }
-
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
- __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
- RETURN (anInfoBuffer);
+ if (pathName == nil)
+ handle = dlopen((char *)0, 1);
+ else
+ handle = dlopen(__stringVal(pathName), 1);
+
+ if (! handle) {
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "dlopen %s error: <%s>\n",
+ __stringVal(pathName), dlerror());
+ }
+ @global(LastError) = @symbol(linkError);
+ @global(LinkErrorMessage) = __MKSTRING("dlopen error");
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true) {
+ console_printf("open %s handle = %"_lx_"\n", __stringVal(pathName), (INT)handle);
+ }
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = __MKSMALLINT( (int)handle & 0xFFFF );
+ __ArrayInstPtr(anInfoBuffer)->a_element[1] = __MKSMALLINT( ((int)handle >> 16) & 0xFFFF );
+ RETURN (anInfoBuffer);
}
}
#endif
@@ -3365,29 +3367,29 @@
NXStream *errOut;
if (__isStringLike(pathName)) {
- files[0] = (char *) __stringVal(pathName);
- files[1] = (char *) 0;
- errOut = NXOpenFile(2, 2);
- result = rld_load(errOut,
- (struct mach_header **)0,
- files,
- (char *)0);
- NXClose(errOut);
- if (! result) {
- @global(LinkErrorMessage) = __MKSTRING("rld_load error");
- @global(LastError) = @symbol(linkError);
- if (@global(ErrorPrinting) == true) {
- console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
- }
- RETURN (nil);
- }
-
- if (@global(Verbose) == true)
- console_printf("rld_load %s ok\n", __stringVal(pathName));
-
- __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
- __STORE(anInfoBuffer, pathName);
- RETURN ( anInfoBuffer );
+ files[0] = (char *) __stringVal(pathName);
+ files[1] = (char *) 0;
+ errOut = NXOpenFile(2, 2);
+ result = rld_load(errOut,
+ (struct mach_header **)0,
+ files,
+ (char *)0);
+ NXClose(errOut);
+ if (! result) {
+ @global(LinkErrorMessage) = __MKSTRING("rld_load error");
+ @global(LastError) = @symbol(linkError);
+ if (@global(ErrorPrinting) == true) {
+ console_fprintf(stderr, "rld_load %s failed\n", __stringVal(pathName));
+ }
+ RETURN (nil);
+ }
+
+ if (@global(Verbose) == true)
+ console_printf("rld_load %s ok\n", __stringVal(pathName));
+
+ __ArrayInstPtr(anInfoBuffer)->a_element[0] = pathName;
+ __STORE(anInfoBuffer, pathName);
+ RETURN ( anInfoBuffer );
}
}
#endif
@@ -3424,33 +3426,42 @@
#endif
#ifdef WIN_DL
+# if defined(__BORLANDC__)
+ // FreeLibrary in Borland C calls exit, catches it with setjmp()
+ // but hangs after this.
+ if (@global(Verbose) == true) {
+ console_fprintf (__win32_stderr(),
+ "ObjectFileLoader [info]: FreeLibrary is not supported in Borland C\n");
+ }
+ RETURN (true);
+# else // ! __BORLAND_C__
if (__bothSmallInteger(sysHandle1, sysHandle2)) {
- INT val;
+ UINT val;
HINSTANCE handle;
int err;
jmp_buf exitJmpBuf;
# if __POINTER_SIZE__ == 8
- val = (_intVal(sysHandle2) << 32) + _intVal(sysHandle1);
+ val = ((UINT)_intVal(sysHandle2) << 32) + (UINT)_intVal(sysHandle1);
# else
- val = (_intVal(sysHandle2) << 16) + _intVal(sysHandle1);
+ val = ((UINT)_intVal(sysHandle2) << 16) + (UINT)_intVal(sysHandle1);
# endif
- handle = (HINSTANCE)(val);
-
- if (setjmp(exitJmpBuf)) {
+ handle = (HINSTANCE)val;
+
+ if (!setjmp(exitJmpBuf)) {
__setAtExitLongJmp(exitJmpBuf);
if (@global(Verbose) == true) {
- console_fprintf (stderr,
- "ObjectFileLoader [info]: FreeLibrary %s handle: %"_lx_"\n",
- __stringVal(sysHandle1), (INT)handle);
+ console_fprintf (__win32_stderr(),
+ "ObjectFileLoader [info]: FreeLibrary handle: %"_lx_"\n",
+ (INT)handle);
}
if (FreeLibrary(handle) != TRUE) {
__setAtExitLongJmp(0);
err = GetLastError();
if (@global(Verbose) == true) {
- console_fprintf (stderr,
- "ObjectFileLoader [warning]: FreeLibrary %s failed; error: %x\n",
- __stringVal(sysHandle1), err);
+ console_fprintf (__win32_stderr(),
+ "ObjectFileLoader [warning]: FreeLibrary failed; error: %x\n",
+ err);
}
@global(LastErrorNumber) = __MKINT(__WIN32_ERR(err));
RETURN (false);
@@ -3460,29 +3471,29 @@
} else {
// arrive here if FreeLibrary does exit
__setAtExitLongJmp(0);
- console_fprintf(stderr, "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
+ console_fprintf(__win32_stderr(), "ObjectFileLoader [warning]: FreeLibrary called exit() - ignored\n");
}
RETURN (true);
}
RETURN (false);
-#endif
+# endif // !defined(__BORLAND_C__)
+#endif // WIN_DL
#ifdef SYSV4_DL
{
- void *h;
- INT val;
- OBJ low = sysHandle1, hi = sysHandle2;
-
- if (__bothSmallInteger(low, hi)) {
+ if (__bothSmallInteger(sysHandle1, sysHandle2)) {
+ void *handle;
+ UINT val;
+
#if __POINTER_SIZE__ == 8
- val = (__intVal(hi) << 32) + __intVal(low);
+ val = ((UINT)__intVal(sysHandle2) << 32) + (UINT)__intVal(sysHandle1);
#else
- val = (_intVal(hi) << 16) + _intVal(low);
+ val = ((UINT)_intVal(sysHandle2) << 16) + (UINT)_intVal(sysHandle1);
#endif
- h = (void *)(val);
+ handle = (void *)(val);
if (@global(Verbose) == true)
- console_printf("close handle = %"_lx_"\n", (INT)h);
- if (dlclose(h) != 0) {
+ console_printf("close handle = %"_lx_"\n", (UINT)handle);
+ if (dlclose(handle) != 0) {
console_fprintf(stderr, "dlclose failed with:<%s>\n", dlerror());
RETURN (false);
}
@@ -3567,97 +3578,97 @@
module. Calling it for still living classes will definitely
lead to some fatal conditions to occur later."
- |key fileName functionName deInitAddr m|
+ |key fileName functionName deInitAddr method|
Verbose ifTrue:[
- 'unload module name=' errorPrint. handle pathName errorPrintCR.
+ 'unload module name=' errorPrint. handle pathName errorPrintCR.
].
handle isUnknownHandle ifTrue:[
- Verbose ifTrue:[
- 'module type is not known - assume uninitialized classLib' errorPrintCR.
- ].
- self unregisterModule:handle.
- handle makeClassLibHandle.
+ Verbose ifTrue:[
+ 'module type is not known - assume uninitialized classLib' errorPrintCR.
+ ].
+ self unregisterModule:handle.
+ handle makeClassLibHandle.
] ifFalse:[
- handle isClassLibHandle ifTrue:[
- Verbose ifTrue:[
- 'a classLib - deinit classes' errorPrintCR.
- ].
- self deinitializeClassesFromModule:handle.
- Verbose ifTrue:[
- 'unregister' errorPrintCR.
- ].
- self unregisterModule:handle.
- ] ifFalse:[
- handle isMethodHandle ifTrue:[
- Verbose ifTrue:[
- 'a methodHandle - unregister' errorPrintCR.
- ].
- self unregisterModule:handle.
- ] ifFalse:[
- handle isFunctionObjectHandle ifTrue:[
- Verbose ifTrue:[
- 'a functionObject - fixup functionRefs' errorPrintCR.
- ].
- handle functions do:[:f |
- f notNil ifTrue:[
- f invalidate
- ]
- ].
- ].
-
- "/
- "/ call its deInit function (if present)
- "/
- Verbose ifTrue:[
- 'search for deInit function...' errorPrintCR.
- ].
- fileName := handle pathName asFilename baseName.
- functionName := self initFunctionBasenameForFile:fileName.
-
- deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
- deInitAddr notNil ifTrue:[
- Verbose ifTrue:[
- 'invoke deInit function...' errorPrintCR.
- ].
- self
- saveCallInitFunctionAt:deInitAddr
- in:fileName
- specialInit:false
- forceOld:true
- interruptable:false
- argument:0
- identifyAs:handle
- returnsObject:false.
- ]
- ]
- ].
+ handle isClassLibHandle ifTrue:[
+ Verbose ifTrue:[
+ 'a classLib - deinit classes' errorPrintCR.
+ ].
+ self deinitializeClassesFromModule:handle.
+ Verbose ifTrue:[
+ 'unregister' errorPrintCR.
+ ].
+ self unregisterModule:handle.
+ ] ifFalse:[
+ handle isMethodHandle ifTrue:[
+ Verbose ifTrue:[
+ 'a methodHandle - unregister' errorPrintCR.
+ ].
+ self unregisterModule:handle.
+ ] ifFalse:[
+ handle isFunctionObjectHandle ifTrue:[
+ Verbose ifTrue:[
+ 'a functionObject - fixup functionRefs' errorPrintCR.
+ ].
+ handle functions do:[:f |
+ f notNil ifTrue:[
+ f invalidate
+ ]
+ ].
+ ].
+
+ "/
+ "/ call its deInit function (if present)
+ "/
+ Verbose ifTrue:[
+ 'search for deInit function...' errorPrintCR.
+ ].
+ fileName := handle pathName asFilename baseName.
+ functionName := self initFunctionBasenameForFile:fileName.
+
+ deInitAddr := self findFunction:functionName suffix:'__deInit' in:handle.
+ deInitAddr notNil ifTrue:[
+ Verbose ifTrue:[
+ 'invoke deInit function...' errorPrintCR.
+ ].
+ self
+ saveCallInitFunctionAt:deInitAddr
+ in:fileName
+ specialInit:false
+ forceOld:true
+ interruptable:false
+ argument:0
+ identifyAs:handle
+ returnsObject:false.
+ ]
+ ]
+ ].
].
Verbose ifTrue:[
- 'cleanup done - now unload...' errorPrintCR.
+ 'cleanup done - now unload...' errorPrintCR.
].
"/
"/ now, really unload
"/
(self primUnloadDynamicObject:handle) ifFalse:[
- ^ self error:'unloadDynamic failed' mayProceed:true
+ ^ self error:'unloadDynamic failed' mayProceed:true
].
Verbose ifTrue:[
- 'unload done ...' errorPrintCR.
+ 'unload done ...' errorPrintCR.
].
"/
"/ remove from loaded objects
"/
LoadedObjects notNil ifTrue:[
- key := LoadedObjects keyAtEqualValue:handle.
- key notNil ifTrue:[
- LoadedObjects removeKey:key
- ]
+ key := LoadedObjects keyAtEqualValue:handle.
+ key notNil ifTrue:[
+ LoadedObjects removeKey:key
+ ]
].
"
@@ -3665,18 +3676,16 @@
but make it unexecutable. Its still visible in the browser.
"
handle isMethodHandle ifTrue:[
- ((m := handle method) notNil
- and:[m ~~ 0]) ifTrue:[
- m makeUnloaded.
- ]
+ method := handle method.
+ (method notNil and:[method ~~ 0]) ifTrue:[
+ method makeUnloaded.
+ ].
+ ObjectMemory flushCaches.
].
handle isClassLibHandle ifTrue:[
- Smalltalk flushCachedClasses.
- Class flushSubclassInfo.
- ].
- handle isMethodHandle ifTrue:[
- ObjectMemory flushCaches.
+ Smalltalk flushCachedClasses.
+ Class flushSubclassInfo.
].
handle moduleID:nil.