mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-21 22:59:16 +02:00
Added import-shared-object
This commit is contained in:
parent
a259755037
commit
c82e69a997
3 changed files with 19 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
||||||
Features
|
Features
|
||||||
|
|
||||||
- Arthur Maciel added `opaque?` and `opaque-null?` predicates to `(cyclone foreign)`.
|
- Arthur Maciel added `opaque?` and `opaque-null?` predicates to `(cyclone foreign)`.
|
||||||
|
- Added `import-shared-object` to `(scheme eval)` to allow loading a third party C shared library.
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
|
|
|
@ -6946,6 +6946,11 @@ void Cyc_import_shared_object(void *data, object cont, object filename, object e
|
||||||
}
|
}
|
||||||
dlerror(); /* Clear any existing error */
|
dlerror(); /* Clear any existing error */
|
||||||
|
|
||||||
|
if (string_len(entry_pt_fnc) == 0) {
|
||||||
|
// No entry point so this is a third party library.
|
||||||
|
// Just call into our continuation
|
||||||
|
return_closcall1(data, cont, boolean_t);
|
||||||
|
} else {
|
||||||
entry_pt = (function_type) dlsym(handle, string_str(entry_pt_fnc));
|
entry_pt = (function_type) dlsym(handle, string_str(entry_pt_fnc));
|
||||||
if (entry_pt == NULL) {
|
if (entry_pt == NULL) {
|
||||||
snprintf(buffer, 256, "%s, %s, %s", string_str(filename), string_str(entry_pt_fnc), dlerror());
|
snprintf(buffer, 256, "%s, %s, %s", string_str(filename), string_str(entry_pt_fnc), dlerror());
|
||||||
|
@ -6955,6 +6960,7 @@ void Cyc_import_shared_object(void *data, object cont, object filename, object e
|
||||||
mclosure1(clo, entry_pt, cont);
|
mclosure1(clo, entry_pt, cont);
|
||||||
entry_pt(data, 0, &clo, &clo);
|
entry_pt(data, 0, &clo, &clo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Read */
|
/** Read */
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
%import
|
%import
|
||||||
imported?
|
imported?
|
||||||
%set-import-dirs!
|
%set-import-dirs!
|
||||||
|
import-shared-object
|
||||||
|
;; Macros
|
||||||
*defined-macros*
|
*defined-macros*
|
||||||
get-macros
|
get-macros
|
||||||
macro:macro?
|
macro:macro?
|
||||||
|
@ -810,6 +812,9 @@
|
||||||
(define (imported? lis)
|
(define (imported? lis)
|
||||||
(c:lib-loaded? (lib:name->unique-string (lib:list->import-set lis))))
|
(c:lib-loaded? (lib:name->unique-string (lib:list->import-set lis))))
|
||||||
|
|
||||||
|
(define (import-shared-object filename)
|
||||||
|
(c:import-shared-obj filename ""))
|
||||||
|
|
||||||
;; Wrapper around the actual shared object import function
|
;; Wrapper around the actual shared object import function
|
||||||
(define-c c:import-shared-obj
|
(define-c c:import-shared-obj
|
||||||
"(void *data, int argc, closure _, object k, object fn, object entry_fnc)"
|
"(void *data, int argc, closure _, object k, object fn, object entry_fnc)"
|
||||||
|
|
Loading…
Add table
Reference in a new issue