[ctypes-commit] ctypes/source/libffi/src/x86 ffi.c,1.1.2.3,1.1.2.4 ffi64.c,1.1.2.3,1.1.2.4 sysv.S,1.
Brought to you by:
theller
From: Hye-Shik C. <pe...@us...> - 2006-02-01 20:32:05
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src/x86 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9598/source/libffi/src/x86 Modified Files: Tag: branch_1_0 ffi.c ffi64.c sysv.S unix64.S win32.S Log Message: Update libffi to gcc head as of 2006/02/01. This fixes several unittest failures on 64bit platforms. Index: unix64.S =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/x86/Attic/unix64.S,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** unix64.S 31 Jan 2006 20:17:42 -0000 1.1.2.3 --- unix64.S 1 Feb 2006 20:31:52 -0000 1.1.2.4 *************** *** 32,36 **** /* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, ! void *raddr, void (*fnaddr)()); Bit o trickiness here -- ARGS+BYTES is the base of the stack frame --- 32,36 ---- /* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, ! void *raddr, void (*fnaddr)()); Bit o trickiness here -- ARGS+BYTES is the base of the stack frame *************** *** 40,44 **** .align 2 .globl ffi_call_unix64 ! .type ffi_call_unix64,@function ffi_call_unix64: --- 40,44 ---- .align 2 .globl ffi_call_unix64 ! .type ffi_call_unix64,@function ffi_call_unix64: *************** *** 54,57 **** --- 54,58 ---- movq %rdi, %r10 /* Save a copy of the register area. */ movq %r8, %r11 /* Save a copy of the target fn. */ + movl %r9d, %eax /* Set number of SSE registers. */ /* Load up all argument registers. */ *************** *** 62,73 **** movq 32(%r10), %r8 movq 40(%r10), %r9 ! movdqa 48(%r10), %xmm0 ! movdqa 64(%r10), %xmm1 ! movdqa 80(%r10), %xmm2 ! movdqa 96(%r10), %xmm3 ! movdqa 112(%r10), %xmm4 ! movdqa 128(%r10), %xmm5 ! movdqa 144(%r10), %xmm6 ! movdqa 160(%r10), %xmm7 /* Deallocate the reg arg area. */ --- 63,69 ---- movq 32(%r10), %r8 movq 40(%r10), %r9 ! testl %eax, %eax ! jnz .Lload_sse ! .Lret_from_load_sse: /* Deallocate the reg arg area. */ *************** *** 182,216 **** movq %rdx, 8(%rsi) ! /* Bits 11-31 contain the true size of the structure. Copy from the scratch area to the true destination. */ ! shrl $11, %ecx rep movsb ret .LUW3: .size ffi_call_unix64,.-ffi_call_unix64 .align 2 .globl ffi_closure_unix64 ! .type ffi_closure_unix64,@function ffi_closure_unix64: - .LUW4: - subq $200, %rsp .LUW5: ! movq %rdi, (%rsp) ! movq %rsi, 8(%rsp) ! movq %rdx, 16(%rsp) ! movq %rcx, 24(%rsp) ! movq %r8, 32(%rsp) ! movq %r9, 40(%rsp) ! movdqa %xmm0, 48(%rsp) ! movdqa %xmm1, 64(%rsp) ! movdqa %xmm2, 80(%rsp) ! movdqa %xmm3, 96(%rsp) ! movdqa %xmm4, 112(%rsp) ! movdqa %xmm5, 128(%rsp) ! movdqa %xmm6, 144(%rsp) ! movdqa %xmm7, 160(%rsp) movq %r10, %rdi --- 178,224 ---- movq %rdx, 8(%rsi) ! /* Bits 12-31 contain the true size of the structure. Copy from the scratch area to the true destination. */ ! shrl $12, %ecx rep movsb ret + + /* Many times we can avoid loading any SSE registers at all. + It's not worth an indirect jump to load the exact set of + SSE registers needed; zero or all is a good compromise. */ + .align 2 .LUW3: + .Lload_sse: + movdqa 48(%r10), %xmm0 + movdqa 64(%r10), %xmm1 + movdqa 80(%r10), %xmm2 + movdqa 96(%r10), %xmm3 + movdqa 112(%r10), %xmm4 + movdqa 128(%r10), %xmm5 + movdqa 144(%r10), %xmm6 + movdqa 160(%r10), %xmm7 + jmp .Lret_from_load_sse + + .LUW4: .size ffi_call_unix64,.-ffi_call_unix64 .align 2 .globl ffi_closure_unix64 ! .type ffi_closure_unix64,@function ffi_closure_unix64: .LUW5: ! /* The carry flag is set by the trampoline iff SSE registers ! are used. Don't clobber it before the branch instruction. */ ! leaq -200(%rsp), %rsp ! .LUW6: movq %rdi, (%rsp) ! movq %rsi, 8(%rsp) ! movq %rdx, 16(%rsp) ! movq %rcx, 24(%rsp) ! movq %r8, 32(%rsp) ! movq %r9, 40(%rsp) ! jc .Lsave_sse ! .Lret_from_save_sse: movq %r10, %rdi *************** *** 222,226 **** /* Deallocate stack frame early; return value is now in redzone. */ addq $200, %rsp ! .LUW6: /* The first byte of the return value contains the FFI_TYPE. */ --- 230,234 ---- /* Deallocate stack frame early; return value is now in redzone. */ addq $200, %rsp ! .LUW7: /* The first byte of the return value contains the FFI_TYPE. */ *************** *** 301,305 **** cmovnz %rdx, %rax ret ! .LUW7: .size ffi_closure_unix64,.-ffi_closure_unix64 --- 309,328 ---- cmovnz %rdx, %rax ret ! ! /* See the comment above .Lload_sse; the same logic applies here. */ ! .align 2 ! .LUW8: ! .Lsave_sse: ! movdqa %xmm0, 48(%rsp) ! movdqa %xmm1, 64(%rsp) ! movdqa %xmm2, 80(%rsp) ! movdqa %xmm3, 96(%rsp) ! movdqa %xmm4, 112(%rsp) ! movdqa %xmm5, 128(%rsp) ! movdqa %xmm6, 144(%rsp) ! movdqa %xmm7, 160(%rsp) ! jmp .Lret_from_save_sse ! ! .LUW9: .size ffi_closure_unix64,.-ffi_closure_unix64 *************** *** 328,332 **** .long .LASFDE1-.Lframe1 /* FDE CIE offset */ .long .LUW0-. /* FDE initial location */ ! .long .LUW3-.LUW0 /* FDE address range */ .uleb128 0x0 /* Augmentation size */ --- 351,355 ---- .long .LASFDE1-.Lframe1 /* FDE CIE offset */ .long .LUW0-. /* FDE initial location */ ! .long .LUW4-.LUW0 /* FDE address range */ .uleb128 0x0 /* Augmentation size */ *************** *** 334,344 **** .long .LUW1-.LUW0 ! /* New stack frame based off rbp. This is a itty bit of unwind ! trickery in that the CFA *has* changed. There is no easy way ! to describe it correctly on entry to the function. Fortunately, ! it doesn't matter too much since at all points we can correctly ! unwind back to ffi_call. Note that the location to which we ! moved the return address is (the new) CFA-8, so from the ! perspective of the unwind info, it hasn't moved. */ .byte 0xc /* DW_CFA_def_cfa, %rbp offset 32 */ .uleb128 6 --- 357,367 ---- .long .LUW1-.LUW0 ! /* New stack frame based off rbp. This is a itty bit of unwind ! trickery in that the CFA *has* changed. There is no easy way ! to describe it correctly on entry to the function. Fortunately, ! it doesn't matter too much since at all points we can correctly ! unwind back to ffi_call. Note that the location to which we ! moved the return address is (the new) CFA-8, so from the ! perspective of the unwind info, it hasn't moved. */ .byte 0xc /* DW_CFA_def_cfa, %rbp offset 32 */ .uleb128 6 *************** *** 346,349 **** --- 369,373 ---- .byte 0x80+6 /* DW_CFA_offset, %rbp offset 2*-8 */ .uleb128 2 + .byte 0xa /* DW_CFA_remember_state */ .byte 0x4 /* DW_CFA_advance_loc4 */ *************** *** 353,356 **** --- 377,385 ---- .uleb128 8 .byte 0xc0+6 /* DW_CFA_restore, %rbp */ + + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LUW3-.LUW2 + .byte 0xb /* DW_CFA_restore_state */ + .align 8 .LEFDE1: *************** *** 359,373 **** .LASFDE3: .long .LASFDE3-.Lframe1 /* FDE CIE offset */ ! .long .LUW4-. /* FDE initial location */ ! .long .LUW7-.LUW4 /* FDE address range */ .uleb128 0x0 /* Augmentation size */ .byte 0x4 /* DW_CFA_advance_loc4 */ ! .long .LUW5-.LUW4 .byte 0xe /* DW_CFA_def_cfa_offset */ .uleb128 208 .byte 0x4 /* DW_CFA_advance_loc4 */ ! .long .LUW6-.LUW5 .byte 0xe /* DW_CFA_def_cfa_offset */ .uleb128 8 .align 8 .LEFDE3: --- 388,410 ---- .LASFDE3: .long .LASFDE3-.Lframe1 /* FDE CIE offset */ ! .long .LUW5-. /* FDE initial location */ ! .long .LUW9-.LUW5 /* FDE address range */ .uleb128 0x0 /* Augmentation size */ + .byte 0x4 /* DW_CFA_advance_loc4 */ ! .long .LUW6-.LUW5 .byte 0xe /* DW_CFA_def_cfa_offset */ .uleb128 208 + .byte 0xa /* DW_CFA_remember_state */ + .byte 0x4 /* DW_CFA_advance_loc4 */ ! .long .LUW7-.LUW6 .byte 0xe /* DW_CFA_def_cfa_offset */ .uleb128 8 + + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LUW8-.LUW7 + .byte 0xb /* DW_CFA_restore_state */ + .align 8 .LEFDE3: Index: sysv.S =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/x86/Attic/sysv.S,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** sysv.S 31 Jan 2006 20:17:42 -0000 1.1.2.3 --- sysv.S 1 Feb 2006 20:31:52 -0000 1.1.2.4 *************** *** 1,4 **** /* ----------------------------------------------------------------------- ! sysv.S - Copyright (c) 1996, 1998, 2001, 2002, 2003 Red Hat, Inc. X86 Foreign Function Interface --- 1,4 ---- /* ----------------------------------------------------------------------- ! sysv.S - Copyright (c) 1996, 1998, 2001, 2002, 2003, 2005 Red Hat, Inc. X86 Foreign Function Interface *************** *** 131,134 **** --- 131,263 ---- .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV + .align 4 + FFI_HIDDEN (ffi_closure_SYSV) + .globl ffi_closure_SYSV + .type ffi_closure_SYSV, @function + + ffi_closure_SYSV: + .LFB2: + pushl %ebp + .LCFI2: + movl %esp, %ebp + .LCFI3: + subl $40, %esp + leal -24(%ebp), %edx + movl %edx, -12(%ebp) /* resp */ + leal 8(%ebp), %edx + movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */ + leal -12(%ebp), %edx + movl %edx, (%esp) /* &resp */ + #if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__ + call ffi_closure_SYSV_inner + #else + movl %ebx, 8(%esp) + .LCFI7: + call 1f + 1: popl %ebx + addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx + call ffi_closure_SYSV_inner@PLT + movl 8(%esp), %ebx + #endif + movl -12(%ebp), %ecx + cmpl $FFI_TYPE_INT, %eax + je .Lcls_retint + cmpl $FFI_TYPE_FLOAT, %eax + je .Lcls_retfloat + cmpl $FFI_TYPE_DOUBLE, %eax + je .Lcls_retdouble + cmpl $FFI_TYPE_LONGDOUBLE, %eax + je .Lcls_retldouble + cmpl $FFI_TYPE_SINT64, %eax + je .Lcls_retllong + .Lcls_epilogue: + movl %ebp, %esp + popl %ebp + ret + .Lcls_retint: + movl (%ecx), %eax + jmp .Lcls_epilogue + .Lcls_retfloat: + flds (%ecx) + jmp .Lcls_epilogue + .Lcls_retdouble: + fldl (%ecx) + jmp .Lcls_epilogue + .Lcls_retldouble: + fldt (%ecx) + jmp .Lcls_epilogue + .Lcls_retllong: + movl (%ecx), %eax + movl 4(%ecx), %edx + jmp .Lcls_epilogue + .LFE2: + .size ffi_closure_SYSV, .-ffi_closure_SYSV + + #if !FFI_NO_RAW_API + + #define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3) + #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4) + #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4) + #define CIF_FLAGS_OFFSET 20 + + .align 4 + FFI_HIDDEN (ffi_closure_raw_SYSV) + .globl ffi_closure_raw_SYSV + .type ffi_closure_raw_SYSV, @function + + ffi_closure_raw_SYSV: + .LFB3: + pushl %ebp + .LCFI4: + movl %esp, %ebp + .LCFI5: + pushl %esi + .LCFI6: + subl $36, %esp + movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */ + movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */ + movl %edx, 12(%esp) /* user_data */ + leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */ + movl %edx, 8(%esp) /* raw_args */ + leal -24(%ebp), %edx + movl %edx, 4(%esp) /* &res */ + movl %esi, (%esp) /* cif */ + call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */ + movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */ + cmpl $FFI_TYPE_INT, %eax + je .Lrcls_retint + cmpl $FFI_TYPE_FLOAT, %eax + je .Lrcls_retfloat + cmpl $FFI_TYPE_DOUBLE, %eax + je .Lrcls_retdouble + cmpl $FFI_TYPE_LONGDOUBLE, %eax + je .Lrcls_retldouble + cmpl $FFI_TYPE_SINT64, %eax + je .Lrcls_retllong + .Lrcls_epilogue: + addl $36, %esp + popl %esi + popl %ebp + ret + .Lrcls_retint: + movl -24(%ebp), %eax + jmp .Lrcls_epilogue + .Lrcls_retfloat: + flds -24(%ebp) + jmp .Lrcls_epilogue + .Lrcls_retdouble: + fldl -24(%ebp) + jmp .Lrcls_epilogue + .Lrcls_retldouble: + fldt -24(%ebp) + jmp .Lrcls_epilogue + .Lrcls_retllong: + movl -24(%ebp), %eax + movl -20(%ebp), %edx + jmp .Lrcls_epilogue + .LFE3: + .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV + #endif + .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: *************** *** 181,184 **** --- 310,378 ---- .align 4 .LEFDE1: + .LSFDE2: + .long .LEFDE2-.LASFDE2 /* FDE Length */ + .LASFDE2: + .long .LASFDE2-.Lframe1 /* FDE CIE offset */ + #ifdef __PIC__ + .long .LFB2-. /* FDE initial location */ + #else + .long .LFB2 + #endif + .long .LFE2-.LFB2 /* FDE address range */ + #ifdef __PIC__ + .byte 0x0 /* .uleb128 0x0; Augmentation size */ + #endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI2-.LFB2 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x8 /* .uleb128 0x8 */ + .byte 0x85 /* DW_CFA_offset, column 0x5 */ + .byte 0x2 /* .uleb128 0x2 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI3-.LCFI2 + .byte 0xd /* DW_CFA_def_cfa_register */ + .byte 0x5 /* .uleb128 0x5 */ + #if !defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE && defined __PIC__ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI7-.LCFI3 + .byte 0x83 /* DW_CFA_offset, column 0x3 */ + .byte 0xa /* .uleb128 0xa */ + #endif + .align 4 + .LEFDE2: + + #if !FFI_NO_RAW_API + + .LSFDE3: + .long .LEFDE3-.LASFDE3 /* FDE Length */ + .LASFDE3: + .long .LASFDE3-.Lframe1 /* FDE CIE offset */ + #ifdef __PIC__ + .long .LFB3-. /* FDE initial location */ + #else + .long .LFB3 + #endif + .long .LFE3-.LFB3 /* FDE address range */ + #ifdef __PIC__ + .byte 0x0 /* .uleb128 0x0; Augmentation size */ + #endif + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI4-.LFB3 + .byte 0xe /* DW_CFA_def_cfa_offset */ + .byte 0x8 /* .uleb128 0x8 */ + .byte 0x85 /* DW_CFA_offset, column 0x5 */ + .byte 0x2 /* .uleb128 0x2 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI5-.LCFI4 + .byte 0xd /* DW_CFA_def_cfa_register */ + .byte 0x5 /* .uleb128 0x5 */ + .byte 0x4 /* DW_CFA_advance_loc4 */ + .long .LCFI6-.LCFI5 + .byte 0x86 /* DW_CFA_offset, column 0x6 */ + .byte 0x3 /* .uleb128 0x3 */ + .align 4 + .LEFDE3: + + #endif #endif /* ifndef __x86_64__ */ Index: ffi64.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/x86/Attic/ffi64.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** ffi64.c 31 Jan 2006 20:17:42 -0000 1.1.2.3 --- ffi64.c 1 Feb 2006 20:31:52 -0000 1.1.2.4 *************** *** 43,47 **** extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, ! void *raddr, void (*fnaddr)()); /* All reference to register classes here is identical to the code in --- 43,47 ---- extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags, ! void *raddr, void (*fnaddr)(), unsigned ssecount); /* All reference to register classes here is identical to the code in *************** *** 304,311 **** flags |= 1 << 10; /* Mark the true size of the structure. */ ! flags |= cif->rtype->size << 11; } } - cif->flags = flags; /* Go over all arguments and determine the way they should be passed. --- 304,310 ---- flags |= 1 << 10; /* Mark the true size of the structure. */ ! flags |= cif->rtype->size << 12; } } /* Go over all arguments and determine the way they should be passed. *************** *** 332,335 **** --- 331,337 ---- } } + if (ssecount) + flags |= 1 << 11; + cif->flags = flags; cif->bytes = bytes; *************** *** 354,358 **** VOID above in ffi_prep_cif_machdep. */ ret_in_memory = (cif->rtype->type == FFI_TYPE_STRUCT ! && cif->flags == FFI_TYPE_VOID); if (rvalue == NULL && ret_in_memory) rvalue = alloca (cif->rtype->size); --- 356,360 ---- VOID above in ffi_prep_cif_machdep. */ ret_in_memory = (cif->rtype->type == FFI_TYPE_STRUCT ! && (cif->flags & 0xff) == FFI_TYPE_VOID); if (rvalue == NULL && ret_in_memory) rvalue = alloca (cif->rtype->size); *************** *** 425,429 **** ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args), ! cif->flags, rvalue, fn); } --- 427,431 ---- ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args), ! cif->flags, rvalue, fn, ssecount); } *************** *** 440,450 **** tramp = (volatile unsigned short *) &closure->tramp[0]; tramp[0] = 0xbb49; /* mov <code>, %r11 */ - tramp[5] = 0xba49; /* mov <data>, %r10 */ - tramp[10] = 0xff49; /* jmp *%r11 */ - tramp[11] = 0x00e3; *(void * volatile *) &tramp[1] = ffi_closure_unix64; *(void * volatile *) &tramp[6] = closure; closure->cif = cif; closure->fun = fun; --- 442,457 ---- tramp = (volatile unsigned short *) &closure->tramp[0]; + tramp[0] = 0xbb49; /* mov <code>, %r11 */ *(void * volatile *) &tramp[1] = ffi_closure_unix64; + tramp[5] = 0xba49; /* mov <data>, %r10 */ *(void * volatile *) &tramp[6] = closure; + /* Set the carry bit iff the function uses any sse registers. + This is clc or stc, together with the first byte of the jmp. */ + tramp[10] = cif->flags & (1 << 11) ? 0x49f9 : 0x49f8; + + tramp[11] = 0xe3ff; /* jmp *%r11 */ + closure->cif = cif; closure->fun = fun; Index: ffi.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/x86/Attic/ffi.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** ffi.c 31 Jan 2006 20:17:42 -0000 1.1.2.3 --- ffi.c 1 Feb 2006 20:31:52 -0000 1.1.2.4 *************** *** 242,265 **** static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, void** args, ffi_cif* cif); ! static void ffi_closure_SYSV (ffi_closure *) __attribute__ ((regparm(1))); ! static void ffi_closure_raw_SYSV (ffi_raw_closure *) __attribute__ ((regparm(1))); /* This function is jumped to by the trampoline */ ! static void ! ffi_closure_SYSV (closure) ffi_closure *closure; { - // this is our return value storage - long double res; - // our various things... ffi_cif *cif; void **arg_area; - unsigned short rtype; - void *resp = (void*)&res; - void *args = __builtin_dwarf_cfa (); cif = closure->cif; --- 242,263 ---- static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, void** args, ffi_cif* cif); ! void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *) __attribute__ ((regparm(1))); ! unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *) ! __attribute__ ((regparm(1))); ! void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *) __attribute__ ((regparm(1))); /* This function is jumped to by the trampoline */ ! unsigned int FFI_HIDDEN ! ffi_closure_SYSV_inner (closure, respp, args) ffi_closure *closure; + void **respp; + void *args; { // our various things... ffi_cif *cif; void **arg_area; cif = closure->cif; *************** *** 272,315 **** * structure return address. */ ! ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif); ! ! (closure->fun) (cif, resp, arg_area, closure->user_data); ! rtype = cif->flags; ! /* now, do a generic return based on the value of rtype */ ! if (rtype == FFI_TYPE_INT) ! { ! asm ("movl (%0),%%eax" : : "r" (resp) : "eax"); ! } ! else if (rtype == FFI_TYPE_FLOAT) ! { ! asm ("flds (%0)" : : "r" (resp) : "st" ); ! } ! else if (rtype == FFI_TYPE_DOUBLE) ! { ! asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" ); ! } ! else if (rtype == FFI_TYPE_LONGDOUBLE) ! { ! asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" ); ! } ! else if (rtype == FFI_TYPE_SINT64) ! { ! asm ("movl 0(%0),%%eax;" ! "movl 4(%0),%%edx" ! : : "r"(resp) ! : "eax", "edx"); ! } ! #ifdef X86_WIN32 ! else if (rtype == FFI_TYPE_SINT8) /* 1-byte struct */ ! { ! asm ("movsbl (%0),%%eax" : : "r" (resp) : "eax"); ! } ! else if (rtype == FFI_TYPE_SINT16) /* 2-bytes struct */ ! { ! asm ("movswl (%0),%%eax" : : "r" (resp) : "eax"); ! } ! #endif } --- 270,278 ---- * structure return address. */ ! ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif); ! (closure->fun) (cif, *respp, arg_area, closure->user_data); ! return cif->flags; } *************** *** 395,449 **** #if !FFI_NO_RAW_API - static void - ffi_closure_raw_SYSV (closure) - ffi_raw_closure *closure; - { - // this is our return value storage - long double res; - - // our various things... - ffi_raw *raw_args; - ffi_cif *cif; - unsigned short rtype; - void *resp = (void*)&res; - - /* get the cif */ - cif = closure->cif; - - /* the SYSV/X86 abi matches the RAW API exactly, well.. almost */ - raw_args = (ffi_raw*) __builtin_dwarf_cfa (); - - (closure->fun) (cif, resp, raw_args, closure->user_data); - - rtype = cif->flags; - - /* now, do a generic return based on the value of rtype */ - if (rtype == FFI_TYPE_INT) - { - asm ("movl (%0),%%eax" : : "r" (resp) : "eax"); - } - else if (rtype == FFI_TYPE_FLOAT) - { - asm ("flds (%0)" : : "r" (resp) : "st" ); - } - else if (rtype == FFI_TYPE_DOUBLE) - { - asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" ); - } - else if (rtype == FFI_TYPE_LONGDOUBLE) - { - asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" ); - } - else if (rtype == FFI_TYPE_SINT64) - { - asm ("movl 0(%0),%%eax; movl 4(%0),%%edx" - : : "r"(resp) - : "eax", "edx"); - } - } - - - - ffi_status ffi_prep_raw_closure (ffi_raw_closure* closure, --- 358,361 ---- Index: win32.S =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/x86/Attic/win32.S,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** win32.S 31 Jan 2006 20:17:42 -0000 1.1.2.3 --- win32.S 1 Feb 2006 20:31:52 -0000 1.1.2.4 *************** *** 258,259 **** --- 258,373 ---- .ffi_call_STDCALL_end: + + .globl _ffi_closure_SYSV + _ffi_closure_SYSV: + pushl %ebp + movl %esp, %ebp + subl $40, %esp + leal -24(%ebp), %edx + movl %edx, -12(%ebp) /* resp */ + leal 8(%ebp), %edx + movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */ + leal -12(%ebp), %edx + movl %edx, (%esp) /* &resp */ + call _ffi_closure_SYSV_inner + movl -12(%ebp), %ecx + cmpl $FFI_TYPE_INT, %eax + je .Lcls_retint + cmpl $FFI_TYPE_FLOAT, %eax + je .Lcls_retfloat + cmpl $FFI_TYPE_DOUBLE, %eax + je .Lcls_retdouble + cmpl $FFI_TYPE_LONGDOUBLE, %eax + je .Lcls_retldouble + cmpl $FFI_TYPE_SINT64, %eax + je .Lcls_retllong + cmpl $FFI_TYPE_SINT8, %eax /* 1-byte struct */ + je .Lcls_retstruct1 + cmpl $FFI_TYPE_SINT16, %eax /* 2-bytes struct */ + je .Lcls_retstruct2 + .Lcls_epilogue: + movl %ebp, %esp + popl %ebp + ret + .Lcls_retint: + movl (%ecx), %eax + jmp .Lcls_epilogue + .Lcls_retfloat: + flds (%ecx) + jmp .Lcls_epilogue + .Lcls_retdouble: + fldl (%ecx) + jmp .Lcls_epilogue + .Lcls_retldouble: + fldt (%ecx) + jmp .Lcls_epilogue + .Lcls_retllong: + movl (%ecx), %eax + movl 4(%ecx), %edx + jmp .Lcls_epilogue + .Lcls_retstruct1: + movsbl (%ecx), %eax + jmp .Lcls_epilogue + .Lcls_retstruct2: + movswl (%ecx), %eax + jmp .Lcls_epilogue + .ffi_closure_SYSV_end: + + #if !FFI_NO_RAW_API + + #define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3) + #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4) + #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4) + #define CIF_FLAGS_OFFSET 20 + + .balign 16 + .globl _ffi_closure_raw_SYSV + _ffi_closure_raw_SYSV: + pushl %ebp + movl %esp, %ebp + pushl %esi + subl $36, %esp + movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */ + movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */ + movl %edx, 12(%esp) /* user_data */ + leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */ + movl %edx, 8(%esp) /* raw_args */ + leal -24(%ebp), %edx + movl %edx, 4(%esp) /* &res */ + movl %esi, (%esp) /* cif */ + call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */ + movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */ + cmpl $FFI_TYPE_INT, %eax + je .Lrcls_retint + cmpl $FFI_TYPE_FLOAT, %eax + je .Lrcls_retfloat + cmpl $FFI_TYPE_DOUBLE, %eax + je .Lrcls_retdouble + cmpl $FFI_TYPE_LONGDOUBLE, %eax + je .Lrcls_retldouble + cmpl $FFI_TYPE_SINT64, %eax + je .Lrcls_retllong + .Lrcls_epilogue: + addl $36, %esp + popl %esi + popl %ebp + ret + .Lrcls_retint: + movl -24(%ebp), %eax + jmp .Lrcls_epilogue + .Lrcls_retfloat: + flds -24(%ebp) + jmp .Lrcls_epilogue + .Lrcls_retdouble: + fldl -24(%ebp) + jmp .Lrcls_epilogue + .Lrcls_retldouble: + fldt -24(%ebp) + jmp .Lrcls_epilogue + .Lrcls_retllong: + movl -24(%ebp), %eax + movl -20(%ebp), %edx + jmp .Lrcls_epilogue + .ffi_closure_raw_SYSV_end: + + #endif |