1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-08 01:28:06 +00:00

Address #1165 - Allow for partial ffi support without totally removing testing.

Query at runtime which calling conventions are supported, including
a placeholder :none.
This commit is contained in:
Calvin Rose
2023-06-08 09:06:34 -05:00
parent 5e152d30db
commit 866d83579e
2 changed files with 29 additions and 2 deletions

View File

@@ -22,7 +22,12 @@
(start-suite)
# We should get ARM support...
(def has-ffi (and (dyn 'ffi/native) (= (os/arch) :x64)))
(def has-ffi (dyn 'ffi/native))
(def has-full-ffi
(and has-ffi
(when-let [entry (dyn 'ffi/calling-conventions)]
(def fficc (entry :value))
(> (length (fficc)) 1)))) # all arches support :none
# FFI check
# d80356158
@@ -31,7 +36,7 @@
(compwhen has-ffi
(ffi/defbind memcpy :ptr [dest :ptr src :ptr n :size]))
(compwhen has-ffi
(compwhen has-full-ffi
(def buffer1 @"aaaa")
(def buffer2 @"bbbb")
(memcpy buffer1 buffer2 4)