cmp: ffi: cast `ecl_make_foreign_data' 3rd argument to *(void **)

Some compilers doesn't allow putting function pointers when parameter
type is declared (void *), but it's necessary if we want to use
callbacks. Fixes #99.

Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
This commit is contained in:
Daniel Kochmański 2015-07-31 14:19:35 +02:00
parent 515d844270
commit ab50a55fb1
5 changed files with 6 additions and 6 deletions

View file

@ -41,7 +41,7 @@
(si::put-sysprop ',name :callback
(list
(ffi:c-inline () () :object
,(format nil "ecl_make_foreign_data(@':pointer-void,0,~a)" c-name)
,(format nil "ecl_make_foreign_data(@':pointer-void,0,*(void**)~a)" c-name)
:one-liner t)))))
)))

View file

@ -657,7 +657,7 @@ extern ECL_API cl_object si_make_dynamic_callback(cl_narg, cl_object fun, cl_obj
extern ECL_API cl_object si_free_ffi_closure(cl_object closure);
/* Only foreign data types can be coerced to a pointer */
#define ecl_make_pointer(x) ecl_make_foreign_data(ECL_NIL,0,(x))
#define ecl_make_pointer(x) ecl_make_foreign_data(ECL_NIL,0,*(void **)(x))
#define ecl_to_pointer(x) ecl_foreign_data_pointer_safe(x)
extern ECL_API cl_object ecl_make_foreign_data(cl_object tag, cl_index size, void *data);
extern ECL_API cl_object ecl_allocate_foreign_data(cl_object tag, cl_index size);

View file

@ -319,7 +319,7 @@
(defun make-pointer (addr type)
(c-inline (type (size-of-foreign-type type) addr) (:object :unsigned-long :unsigned-long) :object
"ecl_make_foreign_data(#0, #1, (void*)#2)"
"ecl_make_foreign_data(#0, #1, *(void**)#2)"
:side-effects t
:one-liner t))
@ -548,7 +548,7 @@
`(si::find-foreign-symbol ,c-name ,module ',type ,(size-of-foreign-type type)))
(t
`(c-inline () () :object
,(format nil "ecl_make_foreign_data(@~S, ~A, &~A)"
,(format nil "ecl_make_foreign_data(@~S, ~A, *(void **)~A)"
type (size-of-foreign-type type) c-name)
:side-effects t :one-liner t)))))
(if can-deref

View file

@ -41,7 +41,7 @@
(si::put-sysprop ',name :callback
(list
(ffi:c-inline () () :object
,(format nil "ecl_make_foreign_data(@':pointer-void,0,~a)" c-name)
,(format nil "ecl_make_foreign_data(@':pointer-void,0,*(void**)~a)" c-name)
:one-liner t)))))
)))

View file

@ -216,7 +216,7 @@
((:cstring)
(wt "ecl_cstring_to_base_string_or_nil(" loc ")"))
((:pointer-void)
(wt "ecl_make_foreign_data(Cnil, 0, " loc ")"))
(wt "ecl_make_foreign_data(Cnil, 0, *(void**)" loc ")"))
(otherwise
(coercion-error))))
((:pointer-void)