2014-05-11 Bernd Edlinger <bernd.edlinger@hotmail.de>

Fix current cygwin-64 build problems.
	* src/java_raw_api.c: Remove if !defined(FFI_NO_RAW_API).
	* src/x86/ffi.c: Add if defined(__CYGWIN__).
	* src/x86/win64.S (ffi_closure_win64, ffi_call_win64): Added
	handling for FFI_TYPE_UINT64, FFI_TYPE_POINTER and FFI_TYPE_INT.
	Added SEH information.  Fixed formatting.
This commit is contained in:
Bernd Edlinger
2014-09-20 06:51:45 -04:00
committed by Anthony Green
parent 32cb2ce81d
commit bfcbf329c5
3 changed files with 118 additions and 66 deletions

View File

@@ -39,7 +39,7 @@
#include <ffi_common.h>
#include <stdlib.h>
#if !defined(NO_JAVA_RAW_API) && !defined(FFI_NO_RAW_API)
#if !defined(NO_JAVA_RAW_API)
size_t
ffi_java_raw_size (ffi_cif *cif)
@@ -371,4 +371,4 @@ ffi_prep_java_raw_closure (ffi_java_raw_closure* cl,
#endif /* FFI_CLOSURES */
#endif /* !FFI_NATIVE_RAW_API */
#endif /* !FFI_NO_RAW_API */
#endif /* !NO_JAVA_RAW_API */

View File

@@ -28,7 +28,7 @@
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#if !defined(__x86_64__) || defined(_WIN64)
#if !defined(__x86_64__) || defined(_WIN64) || defined(__CYGWIN__)
#ifdef _WIN64
#include <windows.h>

View File

@@ -209,20 +209,45 @@ ret_float$:
ret_double$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
jne SHORT ret_sint64$
jne SHORT ret_uint64$
mov rax, QWORD PTR RVALUE[rbp]
movlpd QWORD PTR [rax], xmm0
jmp SHORT ret_void$
ret_sint64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
jne ret_void$
ret_uint64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT64
jne SHORT ret_sint64$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_sint64$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
jne SHORT ret_pointer$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_pointer$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_POINTER
jne SHORT ret_int$
mov rcx, QWORD PTR RVALUE[rbp]
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_int$:
cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_INT
jne SHORT ret_void$
mov rcx, QWORD PTR RVALUE[rbp]
cdqe
mov QWORD PTR [rcx], rax
jmp SHORT ret_void$
ret_void$:
xor rax, rax
@@ -255,6 +280,7 @@ END
#
.balign 16
.globl SYMBOL_NAME(ffi_closure_win64)
.seh_proc SYMBOL_NAME(ffi_closure_win64)
SYMBOL_NAME(ffi_closure_win64):
# copy register arguments onto stack
test $1,%r11
@@ -289,35 +315,36 @@ SYMBOL_NAME(ffi_closure_win64):
movlpd %xmm3, 32(%rsp)
.Ldone:
#.ALLOCSTACK 40
.seh_stackalloc 40
sub $40, %rsp
#.ENDPROLOG
.seh_endprologue
mov %rax, %rcx # context is first parameter
mov %rsp, %rdx # stack is second parameter
add $48, %rdx # point to start of arguments
mov $SYMBOL_NAME(ffi_closure_win64_inner), %rax
leaq SYMBOL_NAME(ffi_closure_win64_inner)(%rip), %rax
callq *%rax # call the real closure function
add $40, %rsp
movq %rax, %xmm0 # If the closure returned a float,
# ffi_closure_win64_inner wrote it to rax
retq
.ffi_closure_win64_end:
.seh_endproc
.balign 16
.globl SYMBOL_NAME(ffi_call_win64)
.seh_proc SYMBOL_NAME(ffi_call_win64)
SYMBOL_NAME(ffi_call_win64):
# copy registers onto stack
mov %r9,32(%rsp)
mov %r8,24(%rsp)
mov %rdx,16(%rsp)
mov %rcx,8(%rsp)
#.PUSHREG rbp
.seh_pushreg rbp
push %rbp
#.ALLOCSTACK 48
.seh_stackalloc 48
sub $48,%rsp
#.SETFRAME rbp, 32
.seh_setframe rbp, 32
lea 32(%rsp),%rbp
#.ENDPROLOG
.seh_endprologue
mov CIF_BYTES(%rbp),%eax
add $15, %rax
@@ -443,26 +470,51 @@ Lch_done:
.Lret_double:
cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
jne .Lret_sint64
jne .Lret_uint64
mov RVALUE(%rbp), %rax
movlpd %xmm0, (%rax)
jmp .Lret_void
.Lret_sint64:
cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
jne .Lret_void
.Lret_uint64:
cmpl $FFI_TYPE_UINT64, CIF_FLAGS(%rbp)
jne .Lret_sint64
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_sint64:
cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
jne .Lret_pointer
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_pointer:
cmpl $FFI_TYPE_POINTER, CIF_FLAGS(%rbp)
jne .Lret_int
mov RVALUE(%rbp), %rcx
mov %rax, (%rcx)
jmp .Lret_void
.Lret_int:
cmpl $FFI_TYPE_INT, CIF_FLAGS(%rbp)
jne .Lret_void
mov RVALUE(%rbp), %rcx
cltq
movq %rax, (%rcx)
jmp .Lret_void
.Lret_void:
xor %rax, %rax
lea 16(%rbp), %rsp
pop %rbp
retq
.ffi_call_win64_end:
.seh_endproc
#endif /* !_MSC_VER */