1
0
mirror of https://github.com/janet-lang/janet synced 2025-07-05 11:32:54 +00:00

Only enable FFI on x86-64, non-windows OSes.

This commit is contained in:
Calvin Rose 2022-06-08 09:50:31 -05:00
parent 3f27d78ab5
commit f92aac14aa
3 changed files with 27 additions and 24 deletions

View File

@ -232,7 +232,7 @@ JANET_CORE_FN(cfun_ffi_signature,
}
static void *janet_ffi_getpointer(const Janet *argv, int32_t n) {
switch(janet_type(argv[n])) {
switch (janet_type(argv[n])) {
default:
janet_panicf("bad slot #%d, expected pointer convertable type, got %v", argv[n]);
case JANET_POINTER:
@ -385,7 +385,7 @@ static Janet janet_ffi_sysv64(JanetFFISignature *signature, void *function_point
default:
/* fallthrough */
case 0:
__asm__( FFI_ASM_PRELUDE
__asm__(FFI_ASM_PRELUDE
"call *%2\n\t"
"mov %%rax, %0\n\t"
"mov %%rdx, %1"
@ -394,7 +394,7 @@ static Janet janet_ffi_sysv64(JanetFFISignature *signature, void *function_point
: "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11");
return janet_ffi_from64(ret, signature->ret_type);
case 1:
__asm__( FFI_ASM_PRELUDE
__asm__(FFI_ASM_PRELUDE
"call *%2\n\t"
"movq %%xmm0, %0\n\t"
"movq %%xmm1, %1"

View File

@ -163,10 +163,13 @@ extern "C" {
#define JANET_DYNAMIC_MODULES
#endif
/* Enable or disable the FFI library. */
/* Enable or disable the FFI library. Currently, FFI only enabled on
* x86-64, non-windows operating systems. */
#ifndef JANET_NO_FFI
#if !defined(JANET_WINDOWS) && (defined(__x86_64__) || defined(_M_X64))
#define JANET_FFI
#endif
#endif
/* Enable or disable the assembler. Enabled by default. */
#ifndef JANET_NO_ASSEMBLER