mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
Use compiler default convention on x64 Windows
This commit is contained in:
parent
1481ceb000
commit
fb82d8cf1e
2 changed files with 11 additions and 46 deletions
|
@ -1,16 +1,16 @@
|
|||
#include "miniffi.h"
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#if defined(__MINGW64__) || defined(__linux__) || defined(__APPLE__)
|
||||
mffi_value miniffi_call_intern(MINIFFI_FUNC target, MiniFFIFuncArgs *p, int nparams) {
|
||||
assert(nparams <= 8);
|
||||
assert(nparams <= 10);
|
||||
return target(p->params[0], p->params[1], p->params[2], p->params[3],
|
||||
p->params[4], p->params[5], p->params[6], p->params[7]);
|
||||
p->params[4], p->params[5], p->params[6],
|
||||
p->params[7], p->params[8], p->params[9]);
|
||||
}
|
||||
#else
|
||||
#else // 32-bit Windows
|
||||
#define INTEL_ASM ".intel_syntax noprefix\n"
|
||||
__attribute__((noinline))
|
||||
#ifndef __MINGW64__
|
||||
mffi_value miniffi_call_intern(MINIFFI_FUNC target, MiniFFIFuncArgs *p, int nparams) {
|
||||
mffi_value ret;
|
||||
void *old_esp = 0;
|
||||
|
@ -52,40 +52,4 @@ mffi_value miniffi_call_intern(MINIFFI_FUNC target, MiniFFIFuncArgs *p, int npar
|
|||
);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
mffi_value miniffi_call_intern(MINIFFI_FUNC target, MiniFFIFuncArgs *p, int nparams) {
|
||||
mffi_value ret;
|
||||
asm volatile(INTEL_ASM
|
||||
|
||||
"test rax, rax\n"
|
||||
"jz mffi_call_void\n"
|
||||
|
||||
"cmp rax, 4\n"
|
||||
"jle mffi_call_low\n"
|
||||
|
||||
"shl rax, 3\n"
|
||||
|
||||
"mffi_call_loop:\n"
|
||||
"sub rax, 8\n"
|
||||
"mov rbx, [rsi+rax]\n"
|
||||
"push rbx\n"
|
||||
"cmp rax, 32\n"
|
||||
"jg mffi_call_loop\n"
|
||||
|
||||
"mffi_call_low:\n"
|
||||
"mov rcx, [rsi]\n"
|
||||
"mov rdx, [rsi+8]\n"
|
||||
"mov r8, [rsi+16]\n"
|
||||
"mov r9, [rsi+24]\n"
|
||||
|
||||
"mffi_call_void:\n"
|
||||
"call rdi\n"
|
||||
|
||||
: "=a"(ret)
|
||||
: "a"(nparams), "S"(p), "D"(target)
|
||||
: "r8", "r9", "rbx", "rcx", "rdx"
|
||||
);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
#define MINIFFI_MAX_ARGS 10l
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#define MINIFFI_MAX_ARGS 8l
|
||||
typedef unsigned long mffi_value;
|
||||
typedef mffi_value (*MINIFFI_FUNC)(mffi_value, mffi_value,
|
||||
mffi_value, mffi_value,
|
||||
mffi_value, mffi_value,
|
||||
mffi_value, mffi_value,
|
||||
mffi_value, mffi_value);
|
||||
#else // Windows
|
||||
#define MINIFFI_MAX_ARGS 32l
|
||||
#ifdef __MINGW64__
|
||||
typedef uint64_t mffi_value;
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue