Missing function definitions?

Bruce ONeel beoneel at mindspring.com
Tue Feb 22 11:24:23 UTC 2000


Hi,
  These are in sqMacExternalPrims.c when you generate the VM from
a 2.8a image.  When I generated it from a 2.7 image I also had the same
problem.   I think the change might have come through in
1799vmSupportCode-jm, but maybe not.

Anyway the whole file is attached below.  Thanks for doing this!
I'd love for MPW builds to work.

cheers

bruce

Jesse Welton <jwelton at pacific.mps.ohio-state.edu> wrote:
> I've made a great deal of progress in compiling Squeak under MPW, not
> the least of which was due to upgrading to the newest version.
> However, I'm still having a problem with some apparently missing
> function definitions:
> 
> # Error:  File "sqVirtualMachine.c.x"
> #         Reference to unresolved symbol "ioLoadModuleOfLength"
> # Error:  File "sqVirtualMachine.c.x"
> #         Reference to unresolved symbol "ioLoadSymbolOfLengthFromModule"
> 
> These functions are both declared in sqVirtualMachine.h, but are
> nowhere defined.  I generated all the sources from a clean 2.7 image,
> with all 2.7 updates applied.  A global search for "ioLoad" in all the
> files turns up no other instances of these symbols other than in these
> files, and there is no definition.  Could any VM builder tell me,
> where should I find these?
> 
> -Jesse

Date: Tue, 22 Feb 2000 11:20:03 +0100 (MET)
From: O'NEEL Bruce <bruce.oneel at obs.unige.ch>
To: Bruce O'Neel <beoneel at mac.com>


#include <CodeFragments.h>
#include <Strings.h>
#include "sq.h"

/*** Functions Exported to sqVirtualMachine.c ***/
int ioLoadModuleOfLength(int moduleNameIndex, int moduleNameLength);
int ioLoadSymbolOfLengthFromModule(int functionNameIndex, int functionNameLength, int moduleHandle);

/*** Variables ***/
CFragConnectionID squeakVMLib = nil;  /* connection to the VM itself as a shared library */

/*** Function Type Declaration ***/
typedef int (*RecordVMProxyProc)(struct VirtualMachine *interpreterProxy);

CFragConnectionID FindOrLoadLib(char *libName, int loadFlag);
CFragConnectionID FindOrLoadLib(char *libName, int loadFlag) {
	CFragLoadOptions action;
	CFragConnectionID libHandle;
	Ptr mainAddr;
	Str255 errorMsg;
	OSErr err;

	action = loadFlag ? kLoadCFrag : kFindCFrag;
	err = GetSharedLibrary(
		c2pstr(libName), kCurrentCFragArch, action, &libHandle, &mainAddr, errorMsg);
	p2cstr((unsigned char *) libName);  /* undo C to Pascal conversion */
	if (err) {
		return null;
	}
	return libHandle;
}

int ioLoadExternalFunctionOfLengthFromModuleOfLength(
  int functionNameIndex, int functionNameLength, int moduleNameIndex, int moduleNameLength) {
	Str255 functionName, moduleName;
	CFragConnectionID libHandle;
	CFragSymbolClass ignored;
	Ptr functionPtr;
	OSErr err;
	int i, ok;

	/* copy function and module names into C strings */
	for (i = 0; i < functionNameLength; i++) {
		functionName[i] = ((char *) functionNameIndex)[i];
	}
	functionName[functionNameLength] = 0;
	for (i = 0; i < moduleNameLength; i++) {
		moduleName[i] = ((char *) moduleNameIndex)[i];
	}
	moduleName[moduleNameLength] = 0;

	/* find the library */
	if (moduleNameLength > 0) {
		/* look for the primitive in named library */
		/* first try to find it */
		libHandle = FindOrLoadLib((char *) moduleName, false);
		if (!libHandle) {
			/* then try to load it */
			libHandle = FindOrLoadLib((char *) moduleName, true);
		}
	} else {
		/* look for the primitive in the Squeak VM itself */
		if (!squeakVMLib) {
			/* try to get a handle on the Squeak VM itself, viewed as a library */
			squeakVMLib = FindOrLoadLib("SqueakVMPrims", false);
		}
		libHandle = squeakVMLib;
	}

	if (!libHandle) return success(false);  /* could not open the library */

	/* if library is external, initialize its VMProxy pointer */
	if (libHandle != squeakVMLib) {
		/* get the setInterpreter() function */
		err = FindSymbol(libHandle, "\psetInterpreter", &functionPtr, &ignored);
		if (err) return success(false);

		/* call setInterpreter() */
		ok = ((RecordVMProxyProc) functionPtr)(sqGetInterpreterProxy());
		if(!ok) return success(false);
	}

	/* get the address of the desired primitive function */
	c2pstr((char *) functionName);
	err = FindSymbol(libHandle, functionName, &functionPtr, &ignored);
	if (err) return success(false);

	return (int) functionPtr;
}

int ioLoadModuleOfLength(int moduleNameIndex, int moduleNameLength) {
	Str255 moduleName;
	CFragConnectionID libHandle;
	int i;

	/* copy module name into C string */
	for (i = 0; i < moduleNameLength; i++) {
		moduleName[i] = ((char *) moduleNameIndex)[i];
	}
	moduleName[moduleNameLength] = 0;

	/* find the library */
	if (moduleNameLength > 0) {
		/* look for the named library */
		/* first try to find it */
		libHandle = FindOrLoadLib((char *) moduleName, false);
		if (!libHandle) {
			/* then try to load it */
			libHandle = FindOrLoadLib((char *) moduleName, true);
		}
	} else {
		/* look for the Squeak VM itself */
		if (!squeakVMLib) {
			/* try to get a handle on the Squeak VM itself, viewed as a library */
			squeakVMLib = FindOrLoadLib("SqueakVMPrims", false);
		}
		libHandle = squeakVMLib;
	}

	if (!libHandle) {  /* could not open the library */
		success(false);
		return nil;
	}
	return (int) libHandle;
}

int ioLoadSymbolOfLengthFromModule(int functionNameIndex, int functionNameLength, int moduleHandle) {
	Str255 functionName;
	CFragConnectionID libHandle;
	CFragSymbolClass ignored;
	Ptr functionPtr;
	OSErr err;
	int i;

	/* copy function and module names into C strings */
	for (i = 0; i < functionNameLength; i++) {
		functionName[i] = ((char *) functionNameIndex)[i];
	}
	functionName[functionNameLength] = 0;

	/* get the address of the desired primitive function */
	if (!moduleHandle) moduleHandle = ioLoadModuleOfLength(0, 0);
	libHandle = (CFragConnectionID) moduleHandle;
	if (libHandle == nil) {
		if (squeakVMLib != nil) {
			libHandle = squeakVMLib;
		} else {  /* no module handle */
			success(false);
			return nil;
		}
	}

	c2pstr((char *) functionName);
	err = FindSymbol(libHandle, functionName, &functionPtr, &ignored);
	
	if (err) {  /* could not find the given function */
		success(false);
		return nil;
	}
	return (int) functionPtr;
}





More information about the Squeak-dev mailing list