From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14785 invoked by alias); 18 Nov 2014 10:18:26 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 14774 invoked by uid 89); 18 Nov 2014 10:18:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp16.uk.ibm.com Received: from e06smtp16.uk.ibm.com (HELO e06smtp16.uk.ibm.com) (195.75.94.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 18 Nov 2014 10:18:25 +0000 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Nov 2014 10:18:21 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 18 Nov 2014 10:18:19 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3DF5B1B08040 for ; Tue, 18 Nov 2014 10:18:30 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sAIAIIDc60424440 for ; Tue, 18 Nov 2014 10:18:18 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sAIAIIhp029916 for ; Tue, 18 Nov 2014 03:18:18 -0700 Received: from bl3ahm9f.de.ibm.com (dyn-9-152-212-122.boeblingen.de.ibm.com [9.152.212.122]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sAIAIHFf029907 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 18 Nov 2014 03:18:18 -0700 Received: from dvogt by bl3ahm9f.de.ibm.com with local (Exim 4.76) (envelope-from ) id 1XqfrV-0007F2-Hi; Tue, 18 Nov 2014 11:18:17 +0100 Date: Tue, 18 Nov 2014 10:18:00 -0000 From: Dominik Vogt To: libffi-discuss@sourceware.org Subject: [PATCH 1/7] Merge of gcc patches Message-ID: <20141118101817.GB26714@linux.vnet.ibm.com> Reply-To: libffi-discuss@sourceware.org Mail-Followup-To: libffi-discuss@sourceware.org References: <20141118101743.GA26714@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="61jdw2sOBCFtR2d/" Content-Disposition: inline In-Reply-To: <20141118101743.GA26714@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14111810-0025-0000-0000-00000274DBCF X-IsSubscribed: yes X-SW-Source: 2014/txt/msg00225.txt.bz2 --61jdw2sOBCFtR2d/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 64 Patch 1. Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany --61jdw2sOBCFtR2d/ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0001-ChangeLog Content-length: 529 ChangeLog 2014-02-13 Eric Botcazou PR libffi/60073 * src/sparc/ffitarget.h (FFI_TARGET_SPECIFIC_VARIADIC): Define. (FFI_EXTRA_CIF_FIELDS): Likewise. (FFI_NATIVE_RAW_API): Move around. * src/sparc/ffi.c (ffi_prep_cif_machdep_core): New function from... (ffi_prep_cif_machdep): ...here. Call ffi_prep_cif_machdep_core. (ffi_prep_cif_machdep_var): New function. (ffi_closure_sparc_inner_v9): Do not pass anonymous FP arguments in FP registers. * doc/libffi.texi (Introduction): Fix inaccuracy. --61jdw2sOBCFtR2d/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-PR-libffi-60073.patch" Content-length: 5273 >From 4a17a637e5913042bf5f7a0bfe5226cf8080991c Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Thu, 13 Feb 2014 16:18:13 +0000 Subject: [PATCH 1/7] PR libffi/60073 * src/sparc/ffitarget.h (FFI_TARGET_SPECIFIC_VARIADIC): Define. (FFI_EXTRA_CIF_FIELDS): Likewise. (FFI_NATIVE_RAW_API): Move around. * src/sparc/ffi.c (ffi_prep_cif_machdep_core): New function from... (ffi_prep_cif_machdep): ...here. Call ffi_prep_cif_machdep_core. (ffi_prep_cif_machdep_var): New function. (ffi_closure_sparc_inner_v9): Do not pass anonymous FP arguments in FP registers. * doc/libffi.texi (Introduction): Fix inaccuracy. --- doc/libffi.texi | 6 +++--- src/sparc/ffi.c | 29 ++++++++++++++++++++++++----- src/sparc/ffitarget.h | 7 ++++--- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/doc/libffi.texi b/doc/libffi.texi index b1c9bc3..267e23e 100644 --- a/doc/libffi.texi +++ b/doc/libffi.texi @@ -63,14 +63,14 @@ section entitled ``GNU General Public License''. @node Introduction @chapter What is libffi? -Compilers for high level languages generate code that follow certain +Compilers for high-level languages generate code that follow certain conventions. These conventions are necessary, in part, for separate compilation to work. One such convention is the @dfn{calling convention}. The calling convention is a set of assumptions made by the compiler about where function arguments will be found on entry to a function. A calling convention also specifies where the return -value for a function is found. The calling convention is also -sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}. +value for a function is found. The calling convention is part of +what is called the @dfn{ABI} or @dfn{Application Binary Interface}. @cindex calling convention @cindex ABI @cindex Application Binary Interface diff --git a/src/sparc/ffi.c b/src/sparc/ffi.c index 9f0fded..47cc9fd 100644 --- a/src/sparc/ffi.c +++ b/src/sparc/ffi.c @@ -249,7 +249,7 @@ int ffi_prep_args_v9(char *stack, extended_cif *ecif) } /* Perform machine dependent cif processing */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +static ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif) { int wordsize; @@ -334,6 +334,19 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) return FFI_OK; } +ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +{ + cif->nfixedargs = cif->nargs; + return ffi_prep_cif_machdep_core (cif); +} + +ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs, + unsigned int ntotalargs) +{ + cif->nfixedargs = nfixedargs; + return ffi_prep_cif_machdep_core (cif); +} + int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt) { ffi_type **ptr = &arg->elements[0]; @@ -616,8 +629,7 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure, /* Copy the caller's structure return address so that the closure returns the data directly to the caller. */ - if (cif->flags == FFI_TYPE_VOID - && cif->rtype->type == FFI_TYPE_STRUCT) + if (cif->flags == FFI_TYPE_VOID && cif->rtype->type == FFI_TYPE_STRUCT) { rvalue = (void *) gpr[0]; /* Skip the structure return address. */ @@ -631,6 +643,10 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure, /* Grab the addresses of the arguments from the stack frame. */ for (i = 0; i < cif->nargs; i++) { + /* If the function is variadic, FP arguments are passed in FP + registers only if the corresponding parameter is named. */ + const int named = (i < cif->nfixedargs); + if (arg_types[i]->type == FFI_TYPE_STRUCT) { if (arg_types[i]->size > 16) @@ -645,7 +661,9 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure, 0, (char *) &gpr[argn], (char *) &gpr[argn], - (char *) &fpr[argn]); + named + ? (char *) &fpr[argn] + : (char *) &gpr[argn]); avalue[i] = &gpr[argn]; argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG; } @@ -661,6 +679,7 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure, argn++; #endif if (i < fp_slot_max + && named && (arg_types[i]->type == FFI_TYPE_FLOAT || arg_types[i]->type == FFI_TYPE_DOUBLE #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE @@ -674,7 +693,7 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure, } /* Invoke the closure. */ - (closure->fun) (cif, rvalue, avalue, closure->user_data); + closure->fun (cif, rvalue, avalue, closure->user_data); /* Tell ffi_closure_sparc how to perform return type promotions. */ return cif->rtype->type; diff --git a/src/sparc/ffitarget.h b/src/sparc/ffitarget.h index d89f787..a1f5e49 100644 --- a/src/sparc/ffitarget.h +++ b/src/sparc/ffitarget.h @@ -58,16 +58,17 @@ typedef enum ffi_abi { } ffi_abi; #endif +#define FFI_TARGET_SPECIFIC_VARIADIC 1 +#define FFI_EXTRA_CIF_FIELDS unsigned int nfixedargs + /* ---- Definitions for closures ----------------------------------------- */ #define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - #ifdef SPARC64 #define FFI_TRAMPOLINE_SIZE 24 #else #define FFI_TRAMPOLINE_SIZE 16 #endif +#define FFI_NATIVE_RAW_API 0 #endif - -- 1.8.4.2 --61jdw2sOBCFtR2d/--