Initial commit, 3-52-19 alpha
[cls.git] / src / include / sysvr4-foreign.h
blobf40acc8cb44afe28f10fec5e44dbbdb3d55e91d5
1 #define SHLIB_DYNLOAD
3 #define INTERNAL_CNAME_PATTERN "%s"
4 #define INTERNAL_FNAME_PATTERN "%s_" /**** check this */
5 #define VERBDFLT TRUE
7 LOCAL VOID link_and_load _((char *fname, char *libs, int fort));
8 LOCAL char *get_caddress _((char *name));
10 #include <dlfcn.h>
12 /**** This code ought to cache the addresses found, but I won't bother
13 until I revise the way dynamic loading works */
15 LOCAL VOID link_and_load(fname, libs, fort)
16 char *fname, *libs;
17 int fort;
19 static initialized = FALSE;
20 void *handle;
22 if (! initialized) {
23 setvalue(s_cfun_table, NIL);
24 initialized = TRUE;
27 handle = dlopen(fname, RTLD_LAZY);
28 if (handle == NULL) {
29 sprintf(buf, "can't open %s", fname);
30 xlfail(buf);
32 setvalue(s_cfun_table,
33 cons(cvfixnum((FIXTYPE) handle), getvalue(s_cfun_table)));
36 LOCAL char *get_caddress(name)
37 char *name;
39 LVAL next;
40 void *handle;
41 char *f;
42 static int initialized = FALSE;
43 static void *prog_handle = NULL;
45 for (next = getvalue(s_cfun_table); consp(next); next = cdr(next)) {
46 handle = (void *) getfixnum(car(next));
47 f = dlsym(handle, name);
48 if (f != NULL) return(f);
50 if (! initialized) {
51 prog_handle = dlopen(NULL, RTLD_LAZY);
52 initialized = TRUE;
54 f = dlsym(prog_handle, name);
55 return(f);