sqAPIs for Win32 & Mac available

Andreas Raab raab at isgnw.cs.Uni-Magdeburg.DE
Sun Apr 26 12:01:25 UTC 1998


Ale,

> I've released the 1.0 version for sqAPIs [Squeak API calls].
> Currently under Win32 & Mac. (we are working to port to other OS).

A few notes: 
1) You should add some examples for VirtualMachineSourceBuilder (plus a
   note in the readme file saying that you've got to use the builder
   instead of Interpreter>>translate) - it took some time until I figured
   out what has to be done to translate a new VM. 
2) You should add a note that it's currently not possible to translate the
   sqAPI in an inlined interpreter - it took me quite some time figuring
   out why ExternalInterface>>thunkProcess:with: gets removed (which
   should also be tagged as #inline: false).
3) VirtualMachineSourceBuilder>>release should include
     self doAssertions: false
   since most people will want to have the release version fast ;-)
4) sqGetHInstance() should be renamed into something like
   sqGetProcessHandle() - this would make sense on Unix machines too.

Anyways, here is a sqAPIUnix.c file (I've tried it on Linux but I'm quite
sure that it works at least on SGI and Solaris also since I've copied
pieces of code from an interfacing DSO running on all of the above).

############################################################################
/* sqAPI on Unix machines: Must be linked with -ldl */
#include <stdio.h>
#include <dlfcn.h>
#include "sqAPI.h"

int sqLoadLibrary(char *pathString)
{ int handle;

  /* Use RTLD_NOW so dlopen will barf if something is amiss.
     Might be changed to RTLD_LAZY in the future. */
  handle = (int) dlopen(pathString, RTLD_NOW);
  if(!handle)
    fprintf(stderr,"Unable to open %s\n%s\n", pathString, dlerror());
  return handle;
}

int sqGetModuleHandle(char *pathString)
{
  /* From the man page of dlopen(): 
     If the same library is loaded twice with dlopen(), the same file han‚
     dle is returned.  The dl library maintains link counts for
     dynamic file handles, so a dynamic library is not deallo‚
     cated until dlclose has been called on it as many times as
     dlopen has succeeded on it. 
  */
  return sqLoadLibrary(pathString);
}
int sqFreeLibrary(int hLib)
{
  dlclose((void*)hLib);
  return 1;
}

int sqGetProcAddressname(int hModule, char *lpProcName)
{
  return (int) dlsym((void*)hModule, lpProcName);
}

int sqGetHInstance()
{
  return sqLoadLibrary(NULL);
}

###########################################################################

Bye,
  Andreas
-- 
Linear algebra is your friend - Trigonometry is your enemy.
+===== Andreas Raab ============= (raab at isg.cs.uni-magdeburg.de) =====+
I Department of Simulation and Graphics      Phone: +49 391 671 8065  I
I University of Magdeburg, Germany           Fax:   +49 391 671 1164  I
+=============< http://isgwww.cs.uni-magdeburg.de/~raab >=============+





More information about the Squeak-dev mailing list