summaryrefslogtreecommitdiff
path: root/libguile/foreign.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-19use the new finalizer helpersAndy Wingo1-21/+4
* libguile/foreign.c (scm_set_pointer_finalizer_x) * libguile/ports.c (finalize_port, scm_c_make_port_with_encoding) (open_iconv_descriptors) * libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob) * libguile/struct.c (scm_i_alloc_struct) * libguile/weak-set.c (weak_gc_finalizer) (scm_c_register_weak_gc_callback) * libguile/weak-table.c (scm_c_register_weak_gc_callback) (weak_gc_finalizer) * libguile/numbers.c (make_bignum): Use the new API.
2012-02-08Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+12
Conflicts: GUILE-VERSION libguile/gc-malloc.c libguile/ports.c
2012-02-02Implement scm_to_pointerMark H Weaver1-0/+9
* libguile/foreign.c, libguile/foreign.h (scm_to_pointer): New C function. * test-suite/standalone/test-loose-ends.c: Add test.
2012-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-3/+3
* libguile/alist.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/bitvectors.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/generalized-arrays.c: * libguile/hashtab.c: * libguile/ioext.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/promises.c: * libguile/simpos.c: * libguile/socket.c: * libguile/srfi-1.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/symbols.c: * libguile/threads.c: * libguile/weak-table.c: * libguile/weak-vector.c: Make the variable names in the C docstrings more consistent. Replace a few instances of @var with @code when appropriate.
2012-01-31Revert "add SCM_HEAP_OBJECT_BASE"Andy Wingo1-2/+2
This reverts commit 47ed8656db8800f3ad20a40eb2c4e9ef3dc891e3. Conflicts: libguile/foreign.c
2012-01-30Merge commit '3d51e57cfb0404db568a6adfde2a346d3fd9907e'Andy Wingo1-2/+0
Conflicts: libguile/foreign.c libguile/hashtab.c module/ice-9/psyntax-pp.scm module/language/tree-il/compile-glil.scm
2012-01-30Merge commit '9b0975f1dc41ddd10d81fb5b0965b9e9a54ef37a'Andy Wingo1-3/+4
Conflicts: libguile/foreign.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2012-01-23FFI: Fix `set-pointer-finalizer!' to leave the type cell unchanged.Ludovic Courtès1-2/+0
This is a followup to 690a0112e55823aa8b862daeddcf44cea97e7917 ("Remove the "has finalizer?" bit from pointer objects.") * libguile/foreign.c (scm_set_pointer_finalizer_x): Leave the type cell unchanged. Before, `equal?' would break on pointers on which `set-pointer-finalizer!' had been called. * test-suite/tests/foreign.test ("make-pointer")["equal? modulo finalizer (set-pointer-finalizer!)"]: New test.
2012-01-14Fix signed/unsigned pointer mismatches.Ludovic Courtès1-3/+4
* libguile/foreign.c (scm_pointer_to_bytevector, scm_bytevector_to_pointer): Use pointers of the same signedness.
2011-12-19Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-24/+46
Conflicts: libguile/feature.c m4/gnulib-cache.m4 module/ice-9/deprecated.scm module/language/tree-il/peval.scm
2011-12-19FFI: Properly unpack small integer return values in closure call.Andreas Schwab1-9/+31
Fixes <http://debbugs.gnu.org/10203>. * libguile/foreign.c (unpack): Add parameter return_value_p. Properly store integer return values smaller than int. (scm_i_foreign_call): Update call to unpack. (invoke_closure): Likewise.
2011-12-14Use `alignof_type' instead of `alignof'.Ludovic Courtès1-15/+15
* libguile/foreign.c: Use `alignof_type' instead of `alignof'; the latter was removed from Gnulib's <alignof.h> in 408e170e3ae81f73fb65686c5834693d89a96594 (Nov. 1 2011). * libguile/vm-i-scheme.c: Likewise.
2011-12-01Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+13
Conflicts: configure.ac libguile/fluids.c libguile/gc.c libguile/gc.h libguile/objcodes.c libguile/procprop.c libguile/vm.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2011-11-26FFI: Hold a weak reference to the procedure passed to `procedure->pointer'.Ludovic Courtès1-2/+4
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference to PROC. * test-suite/tests/foreign.test ("procedure->pointer")["procedure is retained"]: New test.
2011-11-16FFI: Hold a weak reference to the CIF made by `procedure->pointer'.Ludovic Courtès1-3/+11
* libguile/foreign.c (scm_procedure_to_pointer): Keep a weak reference to CIF so that it is not reclaimed before POINTER. Before that it could be reclaimed and typically reused to store the CIF of another procedure with the same arity, leading to obscure wrong-type-arg errors.
2011-11-08locking for putc, putsAndy Wingo1-2/+2
* libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
2011-10-24add SCM_HEAP_OBJECT_BASEAndy Wingo1-2/+2
* libguile/tags.h (SCM_HEAP_OBJECT_BASE): New macro. Given a SCM, returns a pointer to the start of its memory area on the heap. * libguile/bytevectors.c: * libguile/fluids.c: * libguile/foreign.c: * libguile/gc.h: * libguile/guardians.c: * libguile/numbers.h: * libguile/ports.c: * libguile/smob.c: * libguile/struct.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Use it.
2011-10-24add SCM_HEAP_OBJECT_PAndy Wingo1-1/+1
* libguile/tags.h (SCM_HEAP_OBJECT_P): New macro, an alias for SCM_NIMP. * libguile/arrays.c: * libguile/debug.c: * libguile/foreign.c: * libguile/gdbint.c: * libguile/guardians.c: * libguile/list.c: * libguile/modules.c: * libguile/options.c: * libguile/smob.c: * libguile/validate.h: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Use it instead of SCM_NIMP or !SCM_IMP.
2011-10-24add SCM_{PACK,UNPACK}_POINTERAndy Wingo1-3/+3
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros. The old SCM2PTR and PTR2SCM were defined in such a way that round-tripping through a pointer could lose precision, even in the case in which you weren't interested in actually dereferencing the pointer, it was simply that you needed to plumb a SCM through APIs that take pointers. These new macros are more like SCM_PACK and SCM_UNPACK, but for pointer types. The bit representation of the pointer should be the same as the scm_t_bits representation. * libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS pointers. We are going to try tagging the SCM object itself in the future, and I don't think that keeping this support is worth its cost. It probably doesn't work anyway. * libguile/backtrace.c: * libguile/bytevectors.c: * libguile/continuations.c: * libguile/fluids.c: * libguile/foreign.c: * libguile/gc.h: * libguile/guardians.c: * libguile/hashtab.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/smob.c: * libguile/strings.c: * libguile/symbols.c: * libguile/vm.c: * libguile/weak-set.c: * libguile/weak-table.c: * libguile/weak-vector.c: Update many sites to use the new macros.
2011-10-24convert internal weak hash table users to use the weak table apiAndy Wingo1-5/+2
The weak table API isn't public yet. It could be after some review. But we can go ahead and use it now internally. * libguile/foreign.c: * libguile/goops.c: * libguile/objprop.c: * libguile/procprop.c: * libguile/smob.c: * libguile/srcprop.c: Update weak table users to new API. No locking needed!
2011-05-09Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-10/+39
2011-05-08Fix small integer return value packing on big endian machines.Ludovic Courtès1-10/+39
* libguile/foreign.c (pack): Add `return_value_p' parameter. Update callers. When RETURN_VALUE_P is true, assume LOC points to an `ffi_arg', and cast its results to the relevant type. This fixes packing of integer return values smaller than `int' on SPARC64 and PowerPC64. Reported by Nelson H. F. Beebe <beebe@math.utah.edu>.
2011-05-07bytevectors have internal parent fieldAndy Wingo1-2/+2
* libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Bump, giving bytevectors another word: a parent pointer. Will allow for sub-bytevectors and efficient mmap bindings. * libguile/bytevectors.c (make_bytevector): (make_bytevector_from_buffer): Init parent to #f. (scm_c_take_bytevector, scm_c_take_typed_bytevector): Another argument, the parent, which gets set in the bytevector. * libguile/foreign.c (scm_pointer_to_bytevector): Use the parent field instead of registering a weak reference from bytevector to foreign pointer. * libguile/objcodes.c (scm_objcode_to_bytecode): Use the parent field to avoid copying the objcode. * libguile/srfi-4.c (DEFINE_SRFI_4_C_FUNCS): * libguile/strings.c (scm_from_stringn): * libguile/vm.c (really_make_boot_program): * libguile/r6rs-ports.c (scm_get_bytevector_some) (scm_get_bytevector_all, bytevector_output_port_procedure): Set the parent to #f.
2011-04-01string->pointer and pointer->string have optional encoding argAndy Wingo1-14/+65
* test-suite/tests/foreign.test ("pointer<->string"): Add test cases. * libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): Add optional encoding, and in the pointer->string case, length arguments. * libguile/foreign.h: Update prototypes of internal functions. Shouldn't affect ABI as they are internal. * doc/ref/api-foreign.texi (Void Pointers and Byte Access): Update docs.
2011-03-29Fix `procedure->pointer' for functions returning `void'.Ludovic Courtès1-0/+3
* libguile/foreign.c (unpack): Handle `FFI_TYPE_VOID'. * test-suite/tests/foreign.test ("procedure->pointer")["procedures returning void"]: New test. Reported by Tristan Colgate <tcolgate@gmail.com>.
2011-03-17add pointer->scm, scm->pointerAndy Wingo1-0/+28
* libguile/foreign.c (scm_pointer_to_scm, scm_scm_to_pointer): New functions, useful to pass and receive SCM values to and from foreign functions. * module/system/foreign.scm: Export the new functions. * doc/ref/api-foreign.texi (Foreign Variables): Add docs. * test-suite/tests/foreign.test ("pointer<->scm"): Tests.
2011-03-10FFI: Return the right alignment for structures.Ludovic Courtès1-2/+18
* libguile/foreign.c (scm_alignof): Fix handling of structure alignment. Reported by Aidan Gauland <aidalgol@no8wireless.co.nz>. * test-suite/tests/foreign.test ("structs")["alignof { int8, double, int8 }", "int8, { int8, double, int8 }, int16"]: New tests.
2011-02-10make static hash table access thread-safe in foreign.cAndy Wingo1-0/+5
* libguile/foreign.c (register_weak_reference): Wrap static hash table access in a mutex.
2011-02-09Improve type checking when invoking foreign functions.Ludovic Courtès1-0/+4
* libguile/foreign.c (unpack): Make sure X is a pointer before using `SCM_POINTER_VALUE'. * test-suite/tests/foreign.test ("pointer->procedure"): New test prefix.
2011-01-30Add `pointer?'.Ludovic Courtès1-0/+10
* libguile/foreign.c (scm_pointer_p): New function. * libguile/foreign.h (scm_pointer_p): New declaration. * module/system/foreign.scm: Export `pointer?'. * test-suite/tests/foreign.test ("null pointer")["pointer?"]: New test. ("make-pointer")["pointer?"]: New test. * doc/ref/api-foreign.texi (Foreign Variables): Document `pointer?'.
2011-01-30Remove the "has finalizer?" bit from pointer objects.Ludovic Courtès1-4/+1
* libguile/foreign.h (SCM_POINTER_HAS_FINALIZER): Remove. * libguile/foreign.c (scm_from_pointer): Store nothing more than `scm_tc7_pointer' in the type slot.
2011-01-27objcode type is an enumeration, not flagsAndy Wingo1-2/+2
* libguile/objcodes.h (SCM_OBJCODE_TYPE_MMAP) (SCM_OBJCODE_TYPE_BYTEVECTOR, SCM_OBJCODE_TYPE_SLICE) (SCM_OBJCODE_TYPE_STATIC): Enumerate objcode types instead of expressing them as flags. (SCM_OBJCODE_TYPE): Type is held in bits 8-15. (SCM_OBJCODE_FLAGS): Flags are now shifted by 16 bits, not 8. (SCM_MAKE_OBJCODE_TAG): New helper. * libguile/continuations.c (STATIC_OBJCODE_TAG): * libguile/control.c (STATIC_OBJCODE_TAG): * libguile/foreign.c (STATIC_OBJCODE_TAG): * libguile/gsubr.c (STATIC_OBJCODE_TAG): * libguile/smob.c (STATIC_OBJCODE_TAG): * libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice) (scm_bytecode_to_objcode): : Use SCM_MAKE_OBJCODE_TAG.
2010-12-04make-string et al nulls memory if not given an initializerAndy Wingo1-0/+2
* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the memory block, so users need to make sure it is initialized. * libguile/bitvectors.c (scm_c_make_bitvector): * libguile/bytevectors.c (scm_make_bytevector): * libguile/strings.c (scm_c_make_string): If no initializer is given, initialize the bytes to 0. Prevents information leakage if an app uses make-string et al without initializers. * libguile/foreign.c (make_cif): Initialize this too, to prevent leakage in the struct holes. Paranoia...
2010-11-19Include <alloca.h> wherever `alloca' is used.Ludovic Courtès1-0/+1
Patch provided by <carlo.bramix@libero.it> (tiny change). * libguile/control.c, libguile/fluids.c, libguile/foreign.c, libguile/hashtab.c, libguile/strings.c: Include <alloca.h>.
2010-11-11Add FFI support for `short' and `unsigned short'.Ludovic Courtès1-0/+26
* libguile/foreign.c (sym_short, sym_unsigned_short): New variables. (scm_init_foreign): Define Scheme variables SYM_SHORT and SYM_UNSIGNED_SHORT. * module/system/foreign.scm (short, unsigned-short): New exports. (integer-ref, integer-set): Support (= (sizeof TYPE) 2). (%read-short, %write-short!, %read-unsigned-short, %write-unsigned-short!): New variables. (*writers*): Add support for `short' and `unsigned-short'. (*readers*): Likewise. * test-suite/tests/foreign.test ("structs")["int8, pointer, short, double"]: New test.
2010-09-06Rename `make-foreign-function' to `pointer->procedure'.Ludovic Courtès1-3/+3
* 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-03Add `procedure->pointer' to the FFI.Ludovic Courtès1-26/+114
* 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-08-15Add `string->pointer' and `pointer->string' to the FFI.Ludovic Courtès1-14/+49
* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): New functions. * libguile/foreign.h (scm_string_to_pointer, scm_pointer_to_string): New declarations. * module/system/foreign.scm: Export `string->pointer' and `pointer->string'. * test-suite/tests/foreign.test ("pointer<->string"): New test prefix. * doc/ref/api-foreign.texi (Void Pointers and Byte Access): Add `string->pointer' and `pointer->string'.
2010-08-06add docs for extensiondir; misc other fixesAndy Wingo1-2/+2
* libguile/foreign.c (scm_i_pointer_print): Print in hexadecimal. * doc/ref/api-foreign.texi (Modules and Extensions): Update for "extensiondir", and a discussion of Guile versions. (Foreign Variables): Fix discussion of types. (Void Pointers and Byte Access): Fix typo.
2010-07-28Update the FFI doc.Ludovic Courtès1-11/+7
* doc/ref/api-foreign.texi (Foreign Types): Remove bits about typed foreign pointers. Add `void'. (Foreign Variables): Update the doc of `dynamic-pointer' and the `numptob' example. Remove `foreign-set!' and `foreign-ref'. Add `pointer-address', `make-pointer', `%null-pointer', and `null-pointer?' (Void Pointers and Byte Access): Make it clear that wrapped pointers are untyped. Remove `void' from here. Replace `foreign->bytevector' and `bytevector->foreign' by `pointer->bytevector' and `bytevector->pointer'. Add `dereference-pointer' and the rest of the `numptob' example. (Dynamic FFI): Update examples. Remove `%null-pointer' from here. * libguile/dynl.c (scm_dynamic_pointer): Update docstring. * libguile/foreign.c (scm_dereference_pointer, scm_pointer_to_bytevector): Likewise. * module/system/foreign.scm (null-pointer?): Add docstring.
2010-07-28Remove unused parameter from `bytevector->pointer'.Ludovic Courtès1-17/+6
* libguile/foreign.c (scm_bytevector_to_pointer): Remove unused LEN parameter. Update docstring.
2010-07-28Always return `%null-pointer' when creating a NULL pointer with no finalizer.Ludovic Courtès1-20/+20
* libguile/foreign.c (scm_make_pointer): Always call out to `scm_from_pointer'. (scm_from_pointer): Return NULL_POINTER when PTR and FINALIZER are NULL.
2010-07-28Use "pointer" instead of "foreign" when dealing with wrapped pointers.Ludovic Courtès1-64/+63
* 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-26Add `dereference-pointer' to `(system foreign)'.Ludovic Courtès1-0/+13
* libguile/foreign.c (scm_dereference_pointer): New function. * libguile/foreign.h (scm_dereference_pointer): New declaration. * module/system/foreign.scm (dereference-pointer): Likewise. * test-suite/tests/foreign.test ("foreign<->bytevector")["dereference-pointer"]: New test.
2010-07-26Simplify the (system foreign) API.Ludovic Courtès1-203/+78
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-05-30Fix argument and return value alignment in `scm_i_foreign_call'.Ludovic Courtès1-16/+21
* 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'.
2010-05-30Fix parenthesizing of the `ROUND_UP' macro; factorize.Ludovic Courtès1-3/+0
* libguile/_scm.h (ROUND_UP): New macro. * libguile/continuations.c (ROUND_UP): Remove. * libguile/control.c (ROUND_UP): Remove. * libguile/foreign.c (ROUND_UP): Remove.
2010-05-20%null-pointer properly alignedAndy Wingo1-7/+5
* libguile/foreign.c: Allocate %null-pointer on the heap, to assure proper alignment.
2010-04-09Raise an error when attempting to modify the value of `%null-pointer'.Ludovic Courtès1-1/+17
* 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.
2010-04-09Allocate foreign pointer objects in GC-scanned memory.Ludovic Courtès1-5/+1
* 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 087aa6aa312a8d0af51fa9b2f7bfc1332ad97338).