"Dynamic-Loading of code modules"

dlfcn FORTH
* (LOADM) ( bstring -- sucess )

FORTH/BASE dlfcn ordinary primitive

* LOADM ( 'filename' -- )

dlmap the shared object (or share an already mapped object)
and run the per-thread initialization code. This is the
user-convenient function, otherwise use (LOADM)
 simulate:
   : LOADM  BL WORD   
     ((IS_MODULE_LOADED)) IF EXIT THEN 
     HERE (LOADM)  0= IF ." -- load failed: " HERE COUNT TYPE CR THEN ;

FORTH/BASE dlfcn ordinary primitive

* LOCAL-DLSYM ( [symbolname] -- address ) exec-only

lookup the symbol that follows and leave the address (or null)

FORTH/BASE dlfcn immediate primitive

LOCAL-DLCALL

[] no special info, see general notes

FORTH/BASE dlfcn immediate primitive

DLSYM

[] no special info, see general notes

FORTH/BASE dlfcn obsolete immediate

DLCALL

[] no special info, see general notes

FORTH/BASE dlfcn obsolete immediate

EXTENSIONS # if 0 && defined _target_os_linux && !defined __cplusplus
* accessing shared libraries - only available for i386-linux
CALL-C

[] no special info, see general notes

EXTENSIONS dlfcn ordinary primitive

# endif # ifdef PFE_HAVE_USELIB
USELIBRARY

[] no special info, see general notes

EXTENSIONS dlfcn ordinary primitive

# endif
* lt_dlinit ( -- ior )

initialiize library, usually open the program itself so that its
handles can be found under "0"

EXTENSIONS dlfcn ordinary primitive

* lt_dlopenext ( name-ptr,len -- handle-ptr|0 )

walk the searchpath for dlopen and try to open a binary module
under the given name with the usual file extension for the
current system.

EXTENSIONS dlfcn ordinary primitive

* lt_dlsym ( name-ptr,len handle -- symbol-addr|0)

try to find the name in the binary module denoted by its handle
.. if handle is null, use the main body of the program

EXTENSIONS dlfcn ordinary primitive

* lt_dlclose ( handle -- ior )

close handle that was returned by lt_dlopenext

EXTENSIONS dlfcn ordinary primitive

* lt_dlerror ( -- z-string* )

returns string describing the last dlerror as for lt_dlopenext
and lt_dlsym

EXTENSIONS dlfcn ordinary primitive