* libguile/foreign.c (scm_i_foreign_call): Fix the computation of
ARG_SIZE wrt. alignment. Arrange so that the address ARGS[i] is
aligned, rather than checking whether OFF is aligned. Have the RVALUE
be at least word-aligned, which fixes calls to `char'-returning
functions on `armv5tel-*-linux-gnueabi'.
* libguile/foreign.c (sym_null_pointer_error): New variable.
(null_pointer_error): New function.
(scm_foreign_set_x): Raise an error if attempting to modify
NULL_POINTER.
(scm_foreign_to_bytevector): Use `null_pointer_error ()' instead of
`scm_misc_error ()'.
* test-suite/tests/foreign.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add tests/foreign.test.
* test-suite/lib.scm (exception:null-pointer-error): New variable.
* libguile/foreign.c (scm_take_foreign_pointer): Allocate RET in
GC-scanned memory. This fixes a bug where the object pointed to by
SCM_CIF in the pair returned by `cif_to_procedure ()' would be
reclaimed (as a consequence of commit
087aa6aa31).
* libguile/foreign.c (sym_null, null_pointer): New variables.
(scm_foreign_to_bytevector): Raise an error when PTR is NULL.
(scm_init_foreign): Define SYM_NULL.
* module/system/foreign.scm (%null-pointer): New exported binding.
* libguile/foreign.c (scm_make_foreign_function): Use
`scm_gc_malloc_pointerless ()' when allocating memory for CIF.
(pack): Likewise for the `FFI_TYPE_STRUCT' case.
* libguile/Makefile.am (lib_LTLIBRARIES): Instead of just "libguile.la",
make "libguile-@EFFECTIVE_VERSION@.la". This allows multiple versions
of Guile to be installed at once. See
http://www106.pair.com/rhp/parallel.html for a rationale.
(libguile_@GUILE_EFFECTIVE_VERSION@_la_CFLAGS):
(libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
(EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
(libguile_@GUILE_EFFECTIVE_VERSION@_la_DEPENDENCIES):
(libguile_@GUILE_EFFECTIVE_VERSION@_la_LIBADD):
(libguile_@GUILE_EFFECTIVE_VERSION@_la_LDFLAGS): Fixup automake vars
to include the effective version.
(guile_LDADD): Fix up the spelling of libguile.
* libguile/bytevectors.c (scm_bootstrap_bytevectors):
* libguile/foreign.c (scm_register_foreign):
* libguile/i18n.c (scm_bootstrap_i18n):
* libguile/instructions.c (scm_bootstrap_instructions):
* libguile/objcodes.c (scm_bootstrap_objcodes):
* libguile/programs.c (scm_bootstrap_programs):
* libguile/vm.c (scm_bootstrap_vm): Register extensions using e.g.
"libguile-2.0" as the libname -- i.e., including the effective version
in the libname.
* module/ice-9/i18n.scm:
* module/rnrs/bytevector.scm:
* module/rnrs/io/ports.scm:
* module/system/foreign.scm:
* module/system/vm/instruction.scm:
* module/system/vm/objcode.scm:
* module/system/vm/program.scm:
* module/system/vm/vm.scm: When doing a load-extension for something in
Guile, use the effective version also.
* meta/guile-2.0-uninstalled.pc.in (Libs):
* meta/guile-2.0.pc.in (Libs): Use -lguile-@EFFECTIVE_VERSION@. This
change should mean that code built against Guile should not be
affected by the libguile rename.
* guile-readline/Makefile.am (libguilereadline_v_@LIBGUILEREADLINE_MAJOR@_la_LIBADD):
* srfi/Makefile.am
(libguile_srfi_srfi_1_v_@LIBGUILE_SRFI_SRFI_1_MAJOR@_la_LIBADD):
(libguile_srfi_srfi_4_v_@LIBGUILE_SRFI_SRFI_4_MAJOR@_la_LIBADD):
(libguile_srfi_srfi_13_14_v_@LIBGUILE_SRFI_SRFI_13_14_MAJOR@_la_LIBADD):
(libguile_srfi_srfi_60_v_@LIBGUILE_SRFI_SRFI_60_MAJOR@_la_LIBADD):
* test-suite/standalone/Makefile.am (test_num2integral_LDADD):
(test_round_LDADD):
(libtest_asmobs_la_LIBADD):
(libtest_ffi_la_LIBADD):
(test_list_LDADD):
(test_unwind_LDADD):
(test_conversion_LDADD):
(test_loose_ends_LDADD):
(test_scm_c_read_LDADD):
(test_scm_take_locale_symbol_LDADD):
(test_scm_take_u8vector_LDADD):
(libtest_extensions_la_LIBADD):
(test_with_guile_module_LDADD):
(test_scm_with_guile_LDADD): Fix up the spelling of libguile.la.
* libguile/foreign.h:
* libguile/foreign.c (scm_foreign_set_finalizer_x): New function, for a
limited form of finalization (like `free').
(scm_alignof, scm_sizeof, parse_ffi_type, fill_ffi_type): For the
purposes of make-foreign-function, treat '* (the asterisk symbol) as a
pointer.
* module/system/foreign.scm: Export foreign-set-finalizer!.
* libguile/foreign.c (scm_foreign_ref, scm_foreign_set_x)
(scm_i_foreign_print, fill_ffi_type, cif_to_procedure, unpack): Turn a
number of asserts into proper errors.
* libguile/Makefile.am (AM_CPPFLAGS): Move LIBFFI_CFLAGS here (from
AM_CFLAGS), allowing snarfing to work.
* libguile/foreign.h (scm_make_foreign_function): New public function.
* libguile/foreign.c: Flesh out an implementation of foreign functions.
(scm_take_foreign_pointer): Bugfix for the case in which we have a
finalizer.
* module/system/foreign.scm: Export `make-foreign-function'.
* libguile/foreign.h:
* libguile/foreign.c (scm_foreign_ref, scm_foreign_set_x): Remove all
bits about offsets and aliasing; bytevectors are much better at that.
(scm_foreign_to_bytevector, scm_bytevector_to_foreign): New functions
for getting at the bytes of a memory region.
* module/system/foreign.scm (foreign->bytevector, bytevector->foreign):
Export these.
* libguile/foreign.h:
* libguile/init.c: Change so that init just registers an extension,
later called by foreign.scm.
* libguile/foreign.c (scm_init_foreign): Define constants for the
various foreign types.
* module/Makefile.am:
* module/system/foreign.scm: New module, for the foreign function
interface.
* libguile/foreign.c:
* libguile/foreign.h: Rework interface to be more pointer-centric.
Details are:
(SCM_FOREIGN_TYPE_STRUCT, SCM_FOREIGN_TYPE_POINTER): Removed; now the
pointer in a foreign is first-class. If it points to a native type
like uint32, then it still has a tag; but if it points to something
else, like a struct or a pointer or something, then its type is VOID
(i.e., void*).
(SCM_FOREIGN_POINTER): Rename from SCM_FOREIGN_OBJECT.
(SCM_FOREIGN_VALUE_REF, SCM_FOREIGN_VALUE_SET): Rename from
SCM_FOREIGN_OBJECT_REF and SCM_FOREIGN_OBJECT_SET, to indicate that
they only work with value types.
(SCM_FOREIGN_HAS_FINALIZER): Reserve a bit to indicate if the foreign
pointer in question has a finalizer registered.
(SCM_FOREIGN_LEN): For void* pointers, optionally store the length in
bytes of the associated memory region.
(SCM_FOREIGN_VALUE_P): Rename from SCM_FOREIGN_SIMPLE_P.
(SCM_VALIDATE_FOREIGN_VALUE): Rename from SCM_VALIDATE_FOREIGN_SIMPLE.
(scm_take_foreign_pointer): Rename from scm_c_take_foreign. Remove
scm_c_from_foreign.
(scm_foreign_type): New accessor.
(scm_foreign_ref, scm_foreign_set_x): Take some optional args, used
when dereferencing void pointers.
* libguile/dynl.h:
* libguile/dynl.c (scm_dynamic_pointer): New function, used by
scm_dynamic_func. Adapt code to foreign.h changes.
* libguile/goops.c (scm_enable_primitive_generic_x)
(scm_set_primitive_generic_x): Use the SCM_SET_SUBR_GENERIC macro.
* libguile/gsubr.c (create_gsubr): Adapt to API change.
* libguile/gsubr.h (SCM_SUBRF, SCM_SUBR_GENERIC): Store the pointer
directly, not indirected.
* libguile/snarf.h (SCM_DEFINE, SCM_IMMUTABLE_FOREIGN): Store subr
pointers directly. Adapt to SCM_FOREIGN_TYPE_VOID change.
* libguile/vm-i-system.c (subr-call): Access the void* directly.
* libguile/foreign.h:
* libguile/foreign.c: New files, implementing simple wrappers around
foreign values, such as those that one might link in dynamically from
a library.
* libguile/tags.h (scm_tc7_foreign): Take a tc7 for foreign values.
* libguile.h:
* libguile/init.c: Add foreign.h to headers and init.
* libguile/print.c (iprin1): Add printer for foreign values.
* libguile/gc.c (scm_i_tag_name): Case for foreign values.
* libguile/goops.c (scm_class_of, create_standard_classes): Add a class
for foreign values.
* libguile/evalext.c (scm_self_evaluating_p): Add case for foreign
values.
* libguile/Makefile.am: Add foreign.[ch] to the build.