From patchwork Wed Feb 22 19:30:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 142524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C2A7DB6FA5 for ; Thu, 23 Feb 2012 06:31:07 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1330543868; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Received-SPF:Received:MIME-Version:Received:Received:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=vQSZg1ID2nUx2EsC51j7hxe5vhU=; b=glk0ybiOPEG5/3k4V2RkiVkmC4e/5kmuOXFIF74bt5j3phmAu0Ai6KVixCLbuE U+4woijvXtUTK9gseCZxhmtli6uFIO+PdVSxBxWKByo3SmNPAJZKhhg6S4q7f0er +0uw3P5bfSqTVlRvJjUOZ4/rlaF17CVIXh5dh35iizFDQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received-SPF:Authentication-Results:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=wlROFYsEJLnTbOeMKjwFb7JLvGDShM9Oxlr84bNMp+BI6Ardr1nzQrDSlCeL54 Ufn7GC3NMR2fxE5KcgbhQtDAl2QnPLq7us0L213e3eIrQewdOVyapzRkBqGzz+UU +Q+/TUvBl6L8qBGRxR5ofb/XYh9T2SG/mbxPxoNLvekqc=; Received: (qmail 29009 invoked by alias); 22 Feb 2012 19:31:00 -0000 Received: (qmail 28994 invoked by uid 22791); 22 Feb 2012 19:30:58 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_IB X-Spam-Check-By: sourceware.org Received: from mail-tul01m020-f175.google.com (HELO mail-tul01m020-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Feb 2012 19:30:18 +0000 Received: by obhx4 with SMTP id x4so490573obh.20 for ; Wed, 22 Feb 2012 11:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of ktietz70@googlemail.com designates 10.182.231.38 as permitted sender) client-ip=10.182.231.38; Authentication-Results: mr.google.com; spf=pass (google.com: domain of ktietz70@googlemail.com designates 10.182.231.38 as permitted sender) smtp.mail=ktietz70@googlemail.com; dkim=pass header.i=ktietz70@googlemail.com Received: from mr.google.com ([10.182.231.38]) by 10.182.231.38 with SMTP id td6mr18157586obc.47.1329939017952 (num_hops = 1); Wed, 22 Feb 2012 11:30:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.231.38 with SMTP id td6mr15500374obc.47.1329939017848; Wed, 22 Feb 2012 11:30:17 -0800 (PST) Received: by 10.182.33.103 with HTTP; Wed, 22 Feb 2012 11:30:17 -0800 (PST) Date: Wed, 22 Feb 2012 20:30:17 +0100 Message-ID: Subject: [patch libffi]: Fix problem 52221 From: Kai Tietz To: GCC Patches , libffi-discuss@sourceware.org Cc: Anthony Green X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, this fixes the remaining issues found by libjava for use of libffi. ChangeLog 2012-02-22 Kai Tietz PR libffi/52221 * src/x86/ffi.c (ffi_closure_raw_THISCALL): New prototype. (ffi_prep_raw_closure_loc): Use ffi_closure_raw_THISCALL for thiscall-convention. (ffi_raw_call): Use ffi_prep_args_raw. * src/x86/win32.S (ffi_closure_raw_THISCALL): Add implementation for stub. Tested for i686-w64-mingw32, and regression-tested for x86_64-unknown-linux-gnu. Ok for apply? Regards, Kai Index: src/x86/ffi.c =================================================================== --- src/x86/ffi.c (revision 184486) +++ src/x86/ffi.c (working copy) @@ -447,6 +447,8 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *) __attribute__ ((regparm(1))); #ifdef X86_WIN32 +void FFI_HIDDEN ffi_closure_raw_THISCALL (ffi_raw_closure *) + __attribute__ ((regparm(1))); void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *) __attribute__ ((regparm(1))); void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *) @@ -747,7 +749,7 @@ } else if (cif->abi == FFI_THISCALL) { - FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], &ffi_closure_raw_SYSV, + FFI_INIT_TRAMPOLINE_THISCALL (&closure->tramp[0], &ffi_closure_raw_THISCALL, codeloc, cif->bytes); } #endif @@ -795,7 +797,7 @@ #ifdef X86_WIN32 case FFI_SYSV: case FFI_STDCALL: - ffi_call_win32(ffi_prep_args, &ecif, cif->abi, cif->bytes, cif->flags, + ffi_call_win32(ffi_prep_args_raw, &ecif, cif->abi, cif->bytes, cif->flags, ecif.rvalue, fn); break; case FFI_THISCALL: @@ -823,7 +825,7 @@ cif->abi = abi = FFI_THISCALL; if (passed_regs < 1 && abi == FFI_THISCALL) cif->abi = abi = FFI_STDCALL; - ffi_call_win32(ffi_prep_args, &ecif, abi, cif->bytes, cif->flags, + ffi_call_win32(ffi_prep_args_raw, &ecif, abi, cif->bytes, cif->flags, ecif.rvalue, fn); } break; Index: src/x86/win32.S =================================================================== --- src/x86/win32.S (revision 184486) +++ src/x86/win32.S (working copy) @@ -264,6 +264,18 @@ #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4) #define CIF_FLAGS_OFFSET 20 +ffi_closure_raw_THISCALL PROC NEAR + push ebp + mov ebp, esp + push esi + sub esp, 36 + mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif + mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data + mov [esp + 12], edx + lea edx, [ebp + 12], edx + jmp stubraw +ffi_closure_raw_SYSV ENDP + ffi_closure_raw_SYSV PROC NEAR USES esi ;; the ffi_closure ctx is passed in eax by the trampoline. @@ -272,6 +284,7 @@ mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data mov [esp + 12], edx ;; user_data lea edx, [ebp + 8] +stubraw: mov [esp + 8], edx ;; raw_args lea edx, [ebp - 24] mov [esp + 4], edx ;; &res @@ -722,7 +735,21 @@ #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_THISCALL +#ifndef __OS2__ + .def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef +#endif +_ffi_closure_raw_THISCALL: + 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 12(%ebp), %edx /* __builtin_dwarf_cfa () */ + jmp .stubraw # This assumes we are using gas. .balign 16 .globl _ffi_closure_raw_SYSV @@ -742,6 +769,7 @@ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */ movl %edx, 12(%esp) /* user_data */ leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */ +.stubraw: movl %edx, 8(%esp) /* raw_args */ leal -24(%ebp), %edx movl %edx, 4(%esp) /* &res */