48 char* binary_name_so=
NULL;
53 if (proc_path !=
NULL)
58 int binary_name_so_length = 3 + strlen(
DL_TAIL) + strlen(binary_name) + strlen(
DIR_SEPP) + strlen(proc_path);
59 binary_name_so = (
char *)
omAlloc0( binary_name_so_length *
sizeof(
char) );
60 while((
p!=
NULL)&&(*
p!=
'\0'))
64 strcpy(binary_name_so,
p);
67 strcat(binary_name_so,binary_name);
69 if(!access(binary_name_so, R_OK)) {
found=
TRUE;
break; }
77 Warn(
"Could not find dynamic library: %s%s (path %s)",
78 binary_name,
DL_TAIL,proc_path);
81 WarnS(
"See the INSTALL section in the Singular manual for details.");
91 void *proc_ptr =
NULL;
97 WarnS(
"Could load a procedure from a dynamic library");
100 WarnS(
"See the INSTALL section in the Singular manual for details.");
117#define HAVE_ELF_SYSTEM
121#if (defined(__APPLE__) && defined(__MACH__)) && (!defined(HAVE_ELF_SYSTEM))
122#define HAVE_ELF_SYSTEM
126#if defined(__sun) && defined(__SVR4)
127#define HAVE_ELF_SYSTEM
130#if defined(HAVE_ELF_SYSTEM)
132#define DL_IMPLEMENTED
139 return dlopen(filename,RTLD_NOW|RTLD_NOLOAD) !=
NULL;
146 return dlopen(filename, RTLD_NOW|RTLD_GLOBAL);
149 if ((filename==
NULL) || (dlopen(filename,RTLD_NOW|RTLD_NOLOAD)==
NULL))
150 return(dlopen(filename, RTLD_NOW|RTLD_GLOBAL));
152 Werror(
"module %s already loaded",filename);
167 return(dlsym(handle, symbol));
172 return(dlclose (handle));
184#if defined(HPUX_9) || defined(HPUX_10)
185#define DL_IMPLEMENTED
188typedef char *((*func_ptr) ());
194 struct shl_descriptor *desc;
195 for (
int idx = 0; shl_get(idx, &desc) != -1; ++idx)
197 if (strcmp(filename, desc->filename) == 0)
return TRUE;
204 shl_t handle = shl_load(filename, BIND_DEFERRED, 0);
206 return ((
void *) handle);
209void *
dynl_sym(
void *handle,
const char *symbol)
214 handle = PROG_HANDLE;
216 if (shl_findsym((shl_t *) & handle, symbol, TYPE_PROCEDURE, &
f) == -1)
218 if (shl_findsym((shl_t *) & handle, symbol, TYPE_UNDEFINED, &
f) == -1)
228 shl_unload((shl_t) handle);
243#ifndef DL_IMPLEMENTED
255void *
dynl_sym(
void *handle,
const char *symbol)
267 STATIC_VAR char errmsg[] =
"support for dynamic loading not implemented";
unsigned char * proc[NUM_PROC]
char * feGetResource(const char id, int warn)
int dynl_check_opened(char *filename)
void * dynl_open_binary_warn(const char *binary_name, const char *msg)
void * dynl_sym_warn(void *handle, const char *proc, const char *msg)
STATIC_VAR BOOLEAN warn_handle
const char * dynl_error()
int dynl_close(void *handle)
void * dynl_sym(void *handle, const char *symbol)
STATIC_VAR BOOLEAN warn_proc
void * dynl_open(char *filename)
STATIC_VAR void * kernel_handle
#define DYNL_KERNEL_HANDLE
void Werror(const char *fmt,...)