public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: libffi-discuss@sourceware.org
Cc: davem@davemloft.net
Subject: [PATCH 1/8] sparc: Eliminate long double ifdefs
Date: Tue, 28 Oct 2014 19:46:00 -0000	[thread overview]
Message-ID: <1414525555-21256-2-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1414525555-21256-1-git-send-email-rth@twiddle.net>

---
 src/sparc/ffi.c | 46 ++++++++++++++++------------------------------
 1 file changed, 16 insertions(+), 30 deletions(-)

diff --git a/src/sparc/ffi.c b/src/sparc/ffi.c
index 9f0fded..c2a0d14 100644
--- a/src/sparc/ffi.c
+++ b/src/sparc/ffi.c
@@ -27,9 +27,19 @@
 
 #include <ffi.h>
 #include <ffi_common.h>
-
 #include <stdlib.h>
 
+/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
+   all further uses in this file will refer to the 128-bit type.  */
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+# if FFI_TYPE_LONGDOUBLE != 4
+#  error FFI_TYPE_LONGDOUBLE out of date
+# endif
+#else
+# undef FFI_TYPE_LONGDOUBLE
+# define FFI_TYPE_LONGDOUBLE 4
+#endif
+
 
 /* ffi_prep_args is called by the assembly routine once stack space
    has been allocated for the function's arguments */
@@ -72,10 +82,7 @@ void ffi_prep_args_v8(char *stack, extended_cif *ecif)
       size_t z;
 
 	  if ((*p_arg)->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-	      || (*p_arg)->type == FFI_TYPE_LONGDOUBLE
-#endif
-	      )
+	      || (*p_arg)->type == FFI_TYPE_LONGDOUBLE)
 	    {
 	      *(unsigned int *) argp = (unsigned long)(* p_argv);
 	      z = sizeof(int);
@@ -176,9 +183,7 @@ int ffi_prep_args_v9(char *stack, extended_cif *ecif)
 	  /* FALLTHROUGH */
 	case FFI_TYPE_FLOAT:
 	case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 	case FFI_TYPE_LONGDOUBLE:
-#endif
 	  ret = 1; /* We should promote into FP regs as well as integer.  */
 	  break;
 	}
@@ -296,9 +301,7 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
     case FFI_TYPE_VOID:
     case FFI_TYPE_FLOAT:
     case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
     case FFI_TYPE_LONGDOUBLE:
-#endif
       cif->flags = cif->rtype->type;
       break;
 
@@ -351,9 +354,7 @@ int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *fl
 	  break;
 	case FFI_TYPE_FLOAT:
 	case FFI_TYPE_DOUBLE:
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 	case FFI_TYPE_LONGDOUBLE:
-#endif
 	  memmove(ret + off, flt + off, (*ptr)->size);
 	  off += (*ptr)->size;
 	  break;
@@ -412,10 +413,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
       FFI_ASSERT(0);
 #else
       if (rvalue && (cif->rtype->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-	  || cif->flags == FFI_TYPE_LONGDOUBLE
-#endif
-	  ))
+	  || cif->flags == FFI_TYPE_LONGDOUBLE))
 	{
 	  /* For v8, we need an "unimp" with size of returning struct */
 	  /* behind "call", so we alloc some executable space for it. */
@@ -551,11 +549,7 @@ ffi_closure_sparc_inner_v8(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_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE  
-      || cif->flags == FFI_TYPE_LONGDOUBLE
-#endif
-     )
+  if (cif->flags == FFI_TYPE_STRUCT || cif->flags == FFI_TYPE_LONGDOUBLE)
     rvalue = (void *) gpr[0];
 
   /* Always skip the structure return address.  */
@@ -565,10 +559,7 @@ ffi_closure_sparc_inner_v8(ffi_closure *closure,
   for (i = 0; i < cif->nargs; i++)
     {
       if (arg_types[i]->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-	  || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
-#endif
-         )
+	  || arg_types[i]->type == FFI_TYPE_LONGDOUBLE)
 	{
 	  /* Straight copy of invisible reference.  */
 	  avalue[i] = (void *)gpr[argn++];
@@ -656,17 +647,12 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure,
 	  argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 
 	  /* Align on a 16-byte boundary.  */
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 	  if (arg_types[i]->type == FFI_TYPE_LONGDOUBLE && (argn % 2) != 0)
 	    argn++;
-#endif
 	  if (i < fp_slot_max
 	      && (arg_types[i]->type == FFI_TYPE_FLOAT
 		  || arg_types[i]->type == FFI_TYPE_DOUBLE
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-		  || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
-#endif
-		  ))
+		  || arg_types[i]->type == FFI_TYPE_LONGDOUBLE))
 	    avalue[i] = ((char *) &fpr[argn]) - arg_types[i]->size;
 	  else
 	    avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;
-- 
1.9.3

  parent reply	other threads:[~2014-10-28 19:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 19:46 [PATCH 0/8] Go closures for Sparc Richard Henderson
2014-10-28 19:46 ` [PATCH 3/8] sparc: Rewrite everything Richard Henderson
2014-10-29 18:10   ` David Miller
2014-10-29 20:01     ` Richard Henderson
2014-10-29 20:11       ` David Miller
2014-10-29 20:44         ` Richard Henderson
2014-10-30  4:52           ` David Miller
2014-10-28 19:46 ` Richard Henderson [this message]
2014-10-28 19:46 ` [PATCH 4/8] sparc: Preprocess float point struct return Richard Henderson
2014-10-28 19:46 ` [PATCH 2/8] sparc: Tidy up symbols Richard Henderson
2014-10-28 19:46 ` [PATCH 8/8] sparc: Re-add abi compliant structure support Richard Henderson
2014-10-28 19:46 ` [PATCH 5/8] sparc: Handle more cases of structure return directly Richard Henderson
2014-10-28 19:46 ` [PATCH 7/8] sparc: Add support for Go closures Richard Henderson
2014-10-28 19:46 ` [PATCH 6/8] sparc: Add support for complex types 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=1414525555-21256-2-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=davem@davemloft.net \
    --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).