Michael Gran
93b8ab2994
for dynamic-link tests, mingw needs to link to msvcrt
...
* test-suite/standalone/test-ffi: link msvcrt for mingw
* test-suite/standalone/test-foreign-object-scm: link msvcrt for mingw
2021-01-21 15:32:45 -08:00
Mike Gran
4ce31fd387
Can't recursively search DLLs with FFI on Cygwin
...
* doc/ref/api-foreign.text (dynamic-link): document problems with recursive DLLs.
* test-suite/standalone/test-ffi (global): with Cygwin, dynamic-link C library explicitly
* test-suite/standalone/test-foreign-object-scm (libc-ptr): with Cygwin, link C library explicitly
* test-suite/tests/foreign.test (qsort): with Cygwin, link C library explicitly
2017-03-05 12:45:54 -08:00
Mark H Weaver
5ccc3764b3
Support calling foreign functions of 10 arguments or more.
...
* libguile/foreign.c (OBJCODE_HEADER, META_HEADER, META): Change these
into higher-order macros.
(GEN_CODE): New higher-order macro based on 'CODE'.
(M_STATIC, M_DYNAMIC): New macros.
(CODE): Reimplement using 'GEN_CODE' and 'M_STATIC'.
(make_objcode_trampoline): New static function.
(large_objcode_trampolines, large_objcode_trampolines_mutex): New
static variables.
(get_objcode_trampoline): New static function.
(cif_to_procedure): Use 'get_objcode_trampoline'.
* test-suite/standalone/test-ffi-lib.c (test_ffi_sum_many):
New function.
* test-suite/standalone/test-ffi: Add test.
2013-02-28 04:11:35 -05:00
Ludovic Courtès
2ee073587a
Rename make-foreign-function' to
pointer->procedure'.
...
* libguile/foreign.c (scm_make_foreign_function): Rename to...
(scm_pointer_to_procedure): ... this.
* libguile/foreign.h: Adjust accordingly.
* module/system/foreign.scm: Likewise.
* test-suite/standalone/test-ffi: Likewise.
* test-suite/tests/foreign.test: Likewise.
* doc/ref/api-foreign.texi: Likewise.
2010-09-06 22:24:44 +02:00
Ludovic Courtès
760538bf75
Add license header to `test-ffi'.
...
* test-suite/standalone/test-ffi: Add license header.
2010-09-03 15:32:31 +02:00
Ludovic Courtès
3318635666
Add `procedure->pointer' to the FFI.
...
* libguile/foreign.c (make_cif): New procedure, with code formerly in
`scm_make_foreign_function'.
(scm_make_foreign_function): Use it.
(invoke_closure, scm_procedure_to_pointer)[FFI_CLOSURES]: New
functions.
* libguile/foreign.h (scm_procedure_to_pointer): New declaration.
* module/system/foreign.scm: Export `procedure->pointer' when available.
* test-suite/standalone/test-ffi (f-callback-1, f-callback-2): New
procedures and related tests.
* test-suite/standalone/test-ffi-lib.c (test_ffi_callback_1,
test_ffi_callback_2): New functions.
* test-suite/tests/foreign.test ("procedure->pointer"): New test prefix.
* doc/ref/api-foreign.texi (Dynamic FFI): Document `procedure->pointer'.
2010-09-03 15:26:37 +02:00
Ludovic Courtès
5b46a8c2c8
Use "pointer" instead of "foreign" when dealing with wrapped pointers.
...
* libguile/foreign.h (scm_t_foreign_finalizer): Rename to...
(scm_t_pointer_finalizer): ... this.
(SCM_FOREIGN_P): Rename to...
(SCM_POINTER_P): this.
(SCM_VALIDATE_FOREIGN): Rename to...
(SCM_VALIDATE_POINTER): ... this.
(SCM_FOREIGN_HAS_FINALIZER): Rename to...
(SCM_POINTER_HAS_FINALIZER): ... this.
(scm_take_foreign_pointer): Rename to...
(scm_from_pointer): ... this.
(scm_foreign_address): Rename to...
(scm_pointer_address): ... this.
(scm_foreign_to_bytevector): Rename to...
(scm_pointer_to_bytevector): ... this.
(scm_foreign_set_finalizer_x): Rename to...
(scm_set_pointer_finalizer_x): ... this.
(scm_bytevector_to_foreign): Rename to...
(scm_bytevector_to_pointer): ... this.
(scm_i_foreign_print): Rename to...
(scm_i_pointer_print): ... this.
* libguile/foreign.c: Update accordingly.
* libguile/tags.h (scm_tc7_foreign): Rename to...
(scm_tc7_pointer): ... this.
* libguile/foreign.c, libguile/deprecated.c, libguile/dynl.c,
libguile/evalext.c, libguile/gc.c, libguile/goops.c, libguile/gsubr.c,
libguile/gsubr.h, libguile/print.c, libguile/snarf.h,
libguile/vm-i-system.c, module/system/foreign.scm,
test-suite/standalone/test-ffi, test-suite/tests/foreign.test: Update
accordingly.
2010-07-28 12:24:25 +02:00
Ludovic Courtès
d4149a510e
Simplify the (system foreign) API.
...
Suggested by Neil Jerram.
* libguile/foreign.h (SCM_FOREIGN_TYPE, SCM_FOREIGN_VALUE_REF,
SCM_FOREIGN_VALUE_SET, SCM_FOREIGN_LEN, SCM_FOREIGN_TYPED_P,
SCM_FOREIGN_VALUE_P, SCM_VALIDATE_FOREIGN_VALUE, scm_foreign_set_x,
scm_foreign_type): Remove.
(scm_foreign_ref): Rename to...
(scm_foreign_address): ... this.
(scm_take_foreign_pointer): Update.
(SCM_FOREIGN_POINTER): Remove CTYPE argument. Update callers.
(scm_make_pointer): New declaration.
* libguile/foreign.c (scm_to_uintptr, scm_from_uintptr): New macros.
(scm_make_pointer): New function.
(scm_take_foreign_pointer): Remove TYPE and LEN arguments. Update
callers.
(scm_foreign_ref): Remove to...
(scm_foreign_address): ... this. Remove type-related code.
(scm_foreign_set_x): Remove.
(scm_foreign_to_bytevector): Change argument order; make LEN argument
compulsory.
(scm_i_foreign_print): Remove type printing.
(unpack): Remove foreign-type checking.
* libguile/deprecated.c (scm_dynamic_args_call): Update accordingly.
* libguile/dynl.c (scm_dynamic_pointer): Remove the TYPE and LEN
arguments; update callers. Update to the new foreign API.
* libguile/dynl.h (scm_dynamic_pointer): Update.
* libguile/gsubr.c (create_gsubr): Update to the new foreign API.
* libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Ditto.
* libguile/snarf.h (SCM_IMMUTABLE_FOREIGN): Ditto.
* libguile/vm-i-system.c (subr_call): Ditto.
* module/system/foreign.scm (null-pointer?): New procedure.
* test-suite/standalone/test-ffi: Update to the new
`bytevector->foreign' signature.
* test-suite/tests/foreign.test ("null pointer")["null pointer
identity", "null-pointer? %null-pointer"]: New tests.
["foreign-set! other-null-pointer", "foreign->bytevector
other-null-pointer"]: Remove.
("make-pointer", "foreign<->bytevector"): New test prefixes.
2010-07-26 19:38:52 +02:00
Andy Wingo
07d22c0259
rename (rnrs bytevector) to (rnrs bytevectors)
...
* module/rnrs/bytevectors.scm: Rename to (rnrs bytevectors), from (rnrs
bytevector), to match the name from the R6RS.
* benchmark-suite/benchmarks/bytevectors.bm:
* doc/ref/api-data.texi:
* doc/ref/api-foreign.texi:
* libguile/bytevectors.c:
* module/6/rnrs.scm:
* module/language/assembly.scm:
* module/language/assembly/compile-bytecode.scm:
* module/language/assembly/decompile-bytecode.scm:
* module/language/glil/compile-assembly.scm:
* module/language/tree-il/primitives.scm:
* module/srfi/srfi-4.scm:
* module/srfi/srfi-4/gnu.scm:
* module/system/foreign.scm:
* test-suite/standalone/test-ffi:
* test-suite/tests/asm-to-bytecode.test:
* test-suite/tests/bytevectors.test:
* test-suite/tests/foreign.test:
* test-suite/tests/r6rs-ports.test: Update all referrers.
2010-06-01 13:26:11 +02:00
Ludovic Courtès
8b8ce935ed
Have `test-ffi' run all the tests even after a failure.
...
* test-suite/standalone/test-ffi (failed?): New variable.
(test): Set `failed?' to #t upon error and display an error message.
Have the exit code depend on FAILED?.
2010-05-30 22:56:17 +02:00
Ludovic Courtès
d12f974b43
Change `dynamic-link' to return a global handle when the argument is omitted.
...
* libguile/dynl.c (sysdep_dynl_link): Handle FNAME == NULL.
(scm_dynamic_link): Make argument optional. Adjust body accordingly.
* test-suite/standalone/test-ffi (global, strerror, strlen): New
bindings.
Add test for these bindings.
* doc/ref/api-modules.texi (Low level dynamic linking): Update
description of `dynamic-link'.
2010-03-17 00:54:01 +01:00
Andy Wingo
17d819d4c4
add a test for ffi and pointers
...
* test-suite/standalone/test-ffi:
* test-suite/standalone/test-ffi-lib.c: Add a pointer test.
2010-01-27 22:25:29 +01:00
Andy Wingo
c612ed59ab
add a test for foreign functions taking struct args
...
* test-suite/standalone/test-ffi (f-sum-struct):
* test-suite/standalone/test-ffi-lib.c (test_ffi_sum_struct): Add a
struct test. Wheee....
2010-01-26 22:56:42 +01:00
Andy Wingo
37371ea1ba
add ffi tests
...
* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-ffi:
* test-suite/standalone/test-ffi-lib.c: Add some tests for the ffi.
2010-01-26 22:56:42 +01:00