1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

Fix procedure->pointer' for functions returning void'.

* 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>.
This commit is contained in:
Ludovic Courtès 2011-03-29 23:35:24 +02:00
parent 572eef50c2
commit 443f25dcff
2 changed files with 13 additions and 0 deletions

View file

@ -905,6 +905,9 @@ unpack (const ffi_type *type, void *loc, SCM x)
SCM_VALIDATE_POINTER (1, x); SCM_VALIDATE_POINTER (1, x);
*(void **) loc = SCM_POINTER_VALUE (x); *(void **) loc = SCM_POINTER_VALUE (x);
break; break;
case FFI_TYPE_VOID:
/* Do nothing. */
break;
default: default:
abort (); abort ();
} }

View file

@ -225,6 +225,16 @@
(arg3 (map (cut / <> 4.0) (iota 123 100 4)))) (arg3 (map (cut / <> 4.0) (iota 123 100 4))))
(equal? (map proc arg1 arg2 arg3) (equal? (map proc arg1 arg2 arg3)
(map proc* arg1 arg2 arg3))) (map proc* arg1 arg2 arg3)))
(throw 'unresolved)))
(pass-if "procedures returning void"
(if (defined? 'procedure->pointer)
(let* ((called? #f)
(proc (lambda () (set! called? #t)))
(pointer (procedure->pointer void proc '()))
(proc* (pointer->procedure void pointer '())))
(proc*)
called?)
(throw 'unresolved)))) (throw 'unresolved))))