Back to index

Defines | Typedefs | Functions
dynload.c File Reference
#include "dynload.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>

Go to the source code of this file.


#define MAXPATHLEN   1024
#define SUN_DL
#define PREFIX   "lib"
#define SUFFIX   ".so"


typedef void * HMODULE
typedef void(* FARPROC )()


static void make_filename (const char *name, char *filename)
static void make_init_fn (const char *name, char *init_fn)
static HMODULE dl_attach (const char *module)
static FARPROC dl_proc (HMODULE mo, const char *proc)
static void dl_detach (HMODULE mo)
pointer scm_load_ext (scheme *sc, pointer args)

Define Documentation


Definition at line 6 of file dynload.c.

#define MAXPATHLEN   1024

Definition at line 13 of file dynload.c.

#define PREFIX   "lib"

Definition at line 64 of file dynload.c.

#define SUFFIX   ".so"

Definition at line 65 of file dynload.c.

#define SUN_DL

Definition at line 24 of file dynload.c.

Typedef Documentation

typedef void(* FARPROC)()

Definition at line 23 of file dynload.c.

typedef void* HMODULE

Definition at line 22 of file dynload.c.

Function Documentation

static HMODULE dl_attach ( const char *  module) [static]

Definition at line 67 of file dynload.c.

  HMODULE so=dlopen(module,RTLD_LAZY);
  if(!so) {
    fprintf(stderr, "Error loading scheme extension \"%s\": %s\n", module, dlerror());
  return so;

Here is the caller graph for this function:

static void dl_detach ( HMODULE  mo) [static]

Definition at line 85 of file dynload.c.

static FARPROC dl_proc ( HMODULE  mo,
const char *  proc 
) [static]

Definition at line 75 of file dynload.c.

  const char *errmsg;
  FARPROC fp=(FARPROC)dlsym(mo,proc);
  if ((errmsg = dlerror()) == 0) {
    return fp;
  fprintf(stderr, "Error initializing scheme module \"%s\": %s\n", proc, errmsg);
 return 0;

Here is the caller graph for this function:

static void make_filename ( const char *  name,
char *  filename 
) [static]

Definition at line 125 of file dynload.c.


Here is the caller graph for this function:

static void make_init_fn ( const char *  name,
char *  init_fn 
) [static]

Definition at line 130 of file dynload.c.

 const char *p=strrchr(name,'/');
 if(p==0) {
 } else {

Here is the caller graph for this function:

pointer scm_load_ext ( scheme sc,
pointer  args 

Definition at line 90 of file dynload.c.

   pointer first_arg;
   pointer retval;
   char filename[MAXPATHLEN], init_fn[MAXPATHLEN+6];
   char *name;
   HMODULE dll_handle;
   void (*module_init)(scheme *sc);

   if ((args != sc->NIL) && is_string((first_arg = pair_car(args)))) {
      name = string_value(first_arg);
      dll_handle = dl_attach(filename);
      if (dll_handle == 0) {
         retval = sc -> F;
      else {
         module_init = (void(*)(scheme *))dl_proc(dll_handle, init_fn);
         if (module_init != 0) {
            retval = sc -> T;
         else {
            retval = sc->F;
   else {
      retval = sc -> F;


Here is the call graph for this function:

Here is the caller graph for this function: