Support the WIN64/EFI64 calling convention on all X86_64 platforms

Add a new calling convention FFI_EFI64, alias FFI_WIN64, on all X86_64
platforms.  This allows libffi compiled on a 64-bit x86 platform to call
EFI functions.

Compile in ffiw64.c and win64.S on all X86_64 platforms.  When compiled
for a platform other than X86_WIN64, ffiw64.c suffixes its functions
with _efi64, to avoid conflict with the platform's actual
implementations of those functions.
This commit is contained in:
Josh Triplett
2015-07-26 17:18:16 -07:00
parent 6de51f3e04
commit 1f6b5a91f4
4 changed files with 44 additions and 8 deletions
+9 -7
View File
@@ -30,6 +30,10 @@
#include <stdint.h>
#ifdef X86_WIN64
#define EFI64(name) name
#else
#define EFI64(name) name##_efi64
#endif
struct win64_call_frame
{
@@ -44,7 +48,7 @@ extern void ffi_call_win64 (void *stack, struct win64_call_frame *,
void *closure) FFI_HIDDEN;
ffi_status
ffi_prep_cif_machdep (ffi_cif *cif)
EFI64(ffi_prep_cif_machdep)(ffi_cif *cif)
{
int flags, n;
@@ -159,13 +163,13 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue,
}
void
ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
EFI64(ffi_call)(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
ffi_call_int (cif, fn, rvalue, avalue, NULL);
}
void
ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue,
EFI64(ffi_call_go)(ffi_cif *cif, void (*fn)(void), void *rvalue,
void **avalue, void *closure)
{
ffi_call_int (cif, fn, rvalue, avalue, closure);
@@ -176,7 +180,7 @@ extern void ffi_closure_win64(void) FFI_HIDDEN;
extern void ffi_go_closure_win64(void) FFI_HIDDEN;
ffi_status
ffi_prep_closure_loc (ffi_closure* closure,
EFI64(ffi_prep_closure_loc)(ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*),
void *user_data,
@@ -206,7 +210,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
}
ffi_status
ffi_prep_go_closure (ffi_go_closure* closure, ffi_cif* cif,
EFI64(ffi_prep_go_closure)(ffi_go_closure* closure, ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*))
{
if (cif->abi != FFI_WIN64)
@@ -277,5 +281,3 @@ ffi_closure_win64_inner(ffi_cif *cif,
fun (cif, rvalue, avalue, user_data);
return flags;
}
#endif /* X86_WIN64 */