From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27322 invoked by alias); 18 Nov 2014 13:13:27 -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 27269 invoked by uid 89); 18 Nov 2014 13:13:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 18 Nov 2014 13:13:25 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAIDDNZS001519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 18 Nov 2014 08:13:24 -0500 Received: from pike.twiddle.home (vpn1-5-51.ams2.redhat.com [10.36.5.51]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAIDDLhI013038 for ; Tue, 18 Nov 2014 08:13:22 -0500 Message-ID: <546B45EF.4030108@redhat.com> Date: Tue, 18 Nov 2014 13:13:00 -0000 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: libffi-discuss@sourceware.org Subject: Re: [PATCH 1/7] Merge of gcc patches References: <20141118101743.GA26714@linux.vnet.ibm.com> <20141118101817.GB26714@linux.vnet.ibm.com> <546B2063.6040709@redhat.com> In-Reply-To: <546B2063.6040709@redhat.com> Content-Type: multipart/mixed; boundary="------------030001000207080900040901" X-IsSubscribed: yes X-SW-Source: 2014/txt/msg00244.txt.bz2 This is a multi-part message in MIME format. --------------030001000207080900040901 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-length: 134 This is my take on the change, as it should apply to mainline. For convenience, pushed to git://github/rth7680/libffi.git sparc r~ --------------030001000207080900040901 Content-Type: text/x-patch; name="0001-sparc-Define-FFI_TARGET_SPECIFIC_VARIADIC-for-v9.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-sparc-Define-FFI_TARGET_SPECIFIC_VARIADIC-for-v9.patch" Content-length: 3671 >From 542e004710e3f1d7c137bba305a16538cd6257d6 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 18 Nov 2014 05:07:00 -0800 Subject: [PATCH] sparc: Define FFI_TARGET_SPECIFIC_VARIADIC for v9 This is a port of http://gcc.gnu.org/viewcvs?rev=207763&root=gcc&view=rev aka GCC PR libffi/60073, to the rewritten Sparc codebase. Supposedly, we should have seen failures with the existing libffi.call/cls_double_va.c testcase, but I hadn't. Perhaps a gcc newer than 4.6.3 is required to see that... --- src/sparc/ffi64.c | 30 +++++++++++++++++++++++------- src/sparc/ffitarget.h | 9 +++++++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/sparc/ffi64.c b/src/sparc/ffi64.c index a4e41d2..340b198 100644 --- a/src/sparc/ffi64.c +++ b/src/sparc/ffi64.c @@ -159,8 +159,8 @@ ffi_struct_float_copy (int size_mask, void *vd, void *vi, void *vf) /* Perform machine dependent cif processing */ -ffi_status FFI_HIDDEN -ffi_prep_cif_machdep(ffi_cif *cif) +static ffi_status +ffi_prep_cif_machdep_core(ffi_cif *cif) { ffi_type *rtype = cif->rtype; int rtt = rtype->type; @@ -304,6 +304,20 @@ ffi_prep_cif_machdep(ffi_cif *cif) return FFI_OK; } +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep(ffi_cif *cif) +{ + cif->nfixedargs = cif->nargs; + return ffi_prep_cif_machdep_core(cif); +} + +ffi_status FFI_HIDDEN +ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned nfixedargs, unsigned ntotalargs) +{ + cif->nfixedargs = nfixedargs; + return ffi_prep_cif_machdep_core(cif); +} + extern void ffi_call_v9(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue, size_t bytes, void *closure) FFI_HIDDEN; @@ -495,11 +509,12 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif, { ffi_type **arg_types; void **avalue; - int i, argn, argx, nargs, flags; + int i, argn, argx, nargs, flags, nfixedargs; arg_types = cif->arg_types; nargs = cif->nargs; flags = cif->flags; + nfixedargs = cif->nfixedargs; avalue = alloca(nargs * sizeof(void *)); @@ -517,6 +532,7 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif, /* Grab the addresses of the arguments from the stack frame. */ for (i = 0; i < nargs; i++, argn = argx) { + int named = i < nfixedargs; ffi_type *ty = arg_types[i]; void *a = &gpr[argn]; size_t z; @@ -532,7 +548,7 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif, else { argx = argn + ALIGN (z, 8) / 8; - if (argn < 16) + if (named && argn < 16) { int size_mask = ffi_struct_float_mask (ty, 0); int argn_mask = (0xffff00 >> argn) & 0xff00; @@ -546,15 +562,15 @@ ffi_closure_sparc_inner_v9(ffi_cif *cif, case FFI_TYPE_LONGDOUBLE: argn = ALIGN (argn, 2); - a = (argn < 16 ? fpr : gpr) + argn; + a = (named && argn < 16 ? fpr : gpr) + argn; argx = argn + 2; break; case FFI_TYPE_DOUBLE: - if (argn <= 16) + if (named && argn < 16) a = fpr + argn; break; case FFI_TYPE_FLOAT: - if (argn <= 16) + if (named && argn < 16) a = fpr + argn; a += 4; break; diff --git a/src/sparc/ffitarget.h b/src/sparc/ffitarget.h index 6982903..2f4cd9a 100644 --- a/src/sparc/ffitarget.h +++ b/src/sparc/ffitarget.h @@ -57,8 +57,13 @@ typedef enum ffi_abi { } ffi_abi; #endif -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION -#define FFI_TARGET_HAS_COMPLEX_TYPE +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION 1 +#define FFI_TARGET_HAS_COMPLEX_TYPE 1 + +#ifdef SPARC64 +# define FFI_TARGET_SPECIFIC_VARIADIC 1 +# define FFI_EXTRA_CIF_FIELDS unsigned int nfixedargs +#endif /* ---- Definitions for closures ----------------------------------------- */ -- 1.9.3 --------------030001000207080900040901--