public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@redhat.com>
To: libffi-discuss@sourceware.org
Subject: Re: [PATCH 1/7] Merge of gcc patches
Date: Tue, 18 Nov 2014 13:13:00 -0000	[thread overview]
Message-ID: <546B45EF.4030108@redhat.com> (raw)
In-Reply-To: <546B2063.6040709@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 134 bytes --]

This is my take on the change, as it should apply to mainline.
For convenience, pushed to
  git://github/rth7680/libffi.git sparc

r~

[-- Attachment #2: 0001-sparc-Define-FFI_TARGET_SPECIFIC_VARIADIC-for-v9.patch --]
[-- Type: text/x-patch, Size: 3670 bytes --]

From 542e004710e3f1d7c137bba305a16538cd6257d6 Mon Sep 17 00:00:00 2001
From: Richard Henderson <rth@twiddle.net>
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


  reply	other threads:[~2014-11-18 13:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18 10:17 [PATCH 0/7] " Dominik Vogt
2014-11-18 10:18 ` [PATCH 2/7] " Dominik Vogt
2014-11-18 10:34   ` Richard Henderson
2014-11-18 10:18 ` [PATCH 1/7] " Dominik Vogt
2014-11-18 10:33   ` Richard Henderson
2014-11-18 13:13     ` Richard Henderson [this message]
2014-11-18 10:19 ` [PATCH 3/7] " Dominik Vogt
2014-11-18 10:40   ` Richard Henderson
2014-11-18 10:19 ` [PATCH 4/7] " Dominik Vogt
2014-11-18 10:41   ` Richard Henderson
2014-11-18 10:20 ` [PATCH 5/7] " Dominik Vogt
2014-11-18 10:42   ` Richard Henderson
2014-11-18 10:20 ` [PATCH 6/7] " Dominik Vogt
2014-11-18 10:36   ` Richard Henderson
2014-11-18 11:06     ` Dominik Vogt
2014-11-18 11:34       ` Richard Henderson
2014-11-18 11:57         ` Dominik Vogt
2014-11-18 10:21 ` [PATCH 7/7] " Dominik Vogt
2014-11-18 10:37   ` Richard Henderson
2014-11-18 10:32 ` [PATCH 0/7] " Richard Henderson
2014-11-18 10:47 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=546B45EF.4030108@redhat.com \
    --to=rth@redhat.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).