public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Merge of gcc patches
@ 2014-11-18 10:17 Dominik Vogt
  2014-11-18 10:18 ` [PATCH 1/7] " Dominik Vogt
                   ` (8 more replies)
  0 siblings, 9 replies; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:17 UTC (permalink / raw)
  To: libffi-discuss

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

The following series of patches merges the changes in gcc's copy
of libffi since this gcc-commit:

  2012-12-26 16:28 green        * <libffi-last-merge> libffi merge

While I've tried to resolve conflicts in a sensible way, I've not
made any effort to check what the patches do or whether they are
(still) useful, so please double check before checking in.  libffi
still compiles after applying the patches 1 to 7 (without path
"0", see below), but I've not run any tests.

The "zeroth" patch is attached right to this message.  To me it
looks like a patch that is applied to gcc every time libffi is
merged, but there may be unrelated bits; I cannot judge that.  (The
patch conflicts with a later patch in the series, but the conflict
is easy to resolve.)

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0000-ChangeLog --]
[-- Type: text/plain, Size: 600 bytes --]

ChangeLog
2012-12-29  Andreas Schwab  <schwab@linux-m68k.org>

	* Makefile.am (ACLOCAL_AMFLAGS, TEXINFO_TEX, MAKEINFOFLAGS)
	(STAMP_GENINSRC, STAMP_BUILD_INFO, CLEANFILES)
	(MAINTAINERCLEANFILES): Define.
	(all-local, stamp-geninsrc, stamp-build-info): New targets.
	(doc/libffi.info): Depend on $(STAMP_BUILD_INFO)
	* configure.ac: Check for modern makeinfo.  Add support for
	--enable-generated-files-in-srcdir.
	* mdate-sh: New file.
	* testsuite/lib/libffi.exp (load_gcc_lib): Load from gcc testsuite
	lib dir.
	(libffi-init): Properly set library paths for multilibs and add
	path to libstdc++.

[-- Attachment #3: 0000-Makefile.am-ACLOCAL_AMFLAGS-TEXINFO_TEX-MAKEINFOFLAG.patch --]
[-- Type: text/x-diff, Size: 5944 bytes --]

From 84a69f2b23cf7d2ec83d02bb1ea65a9b2a3b7de8 Mon Sep 17 00:00:00 2001
From: schwab <schwab@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sat, 29 Dec 2012 16:25:27 +0000
Subject: [PATCH "0"/7] * Makefile.am (ACLOCAL_AMFLAGS, TEXINFO_TEX,
 MAKEINFOFLAGS) (STAMP_GENINSRC, STAMP_BUILD_INFO, CLEANFILES)
 (MAINTAINERCLEANFILES): Define. (all-local, stamp-geninsrc,
 stamp-build-info): New targets. (doc/libffi.info): Depend on
 $(STAMP_BUILD_INFO) * configure.ac: Check for modern makeinfo.  Add support
 for --enable-generated-files-in-srcdir. * mdate-sh: New file. *
 testsuite/lib/libffi.exp (load_gcc_lib): Load from gcc testsuite lib dir.
 (libffi-init): Properly set library paths for multilibs and add path to
 libstdc++.

---
 Makefile.am              | 41 ++++++++++++++++++++++++++++++++++++++++-
 configure.ac             | 25 +++++++++++++++++++++++++
 testsuite/lib/libffi.exp | 10 ++++++++--
 3 files changed, 73 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0e40451..c200efa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = foreign subdir-objects
 
-ACLOCAL_AMFLAGS = -I m4
+ACLOCAL_AMFLAGS = -I m4 -I .. -I ../config
 
 SUBDIRS = include testsuite man
 
@@ -53,8 +53,47 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj			\
 	 libffi.xcodeproj/project.pbxproj src/arm/trampoline.S		\
 	 libtool-ldflags ChangeLog.libffi-3.1
 
+# Automake Documentation:
+# If your package has Texinfo files in many directories, you can use the
+# variable TEXINFO_TEX to tell Automake where to find the canonical
+# `texinfo.tex' for your package. The value of this variable should be
+# the relative path from the current `Makefile.am' to `texinfo.tex'.
+TEXINFO_TEX   = ../gcc/doc/include/texinfo.tex
+
+# Defines info, dvi, pdf and html targets
+MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include
 info_TEXINFOS = doc/libffi.texi
 
+# AM_CONDITIONAL on configure option --generated-files-in-srcdir
+if GENINSRC
+STAMP_GENINSRC = stamp-geninsrc
+else
+STAMP_GENINSRC =
+endif
+
+# AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO])
+if BUILD_INFO
+STAMP_BUILD_INFO = stamp-build-info
+else
+STAMP_BUILD_INFO =
+endif
+
+all-local: $(STAMP_GENINSRC)
+
+stamp-geninsrc: doc/libffi.info
+	cp -p $(top_builddir)/doc/libffi.info $(srcdir)/doc/libffi.info
+	@touch $@
+
+doc/libffi.info: $(STAMP_BUILD_INFO)
+
+stamp-build-info: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
+	$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)/doc -o doc/libffi.info $(srcdir)/doc/libffi.texi
+	@touch $@
+
+
+CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) doc/libffi.info
+MAINTAINERCLEANFILES = $(srcdir)/doc/libffi.info
+
 ## ################################################################
 
 ##
diff --git a/configure.ac b/configure.ac
index 4a44bff..6889311 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,31 @@ AX_ENABLE_BUILDDIR
 
 AM_INIT_AUTOMAKE
 
+# See if makeinfo has been installed and is modern enough
+# that we can use it.
+ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
+                   [GNU texinfo.* \([0-9][0-9.]*\)],
+                   [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
+AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
+
+# We would like our source tree to be readonly. However when releases or
+# pre-releases are generated, the flex/bison generated files as well as the
+# various formats of manuals need to be included along with the rest of the
+# sources.  Therefore we have --enable-generated-files-in-srcdir to do
+# just that.
+AC_MSG_CHECKING(generated-files-in-srcdir)
+AC_ARG_ENABLE(generated-files-in-srcdir,
+AS_HELP_STRING([--enable-generated-files-in-srcdir],
+ [put copies of generated files in source dir intended for creating source tarballs for users without texinfo bison or flex]),
+[case "$enableval" in
+ yes) enable_generated_files_in_srcdir=yes ;;
+ no)  enable_generated_files_in_srcdir=no ;;
+ *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
+ esac],
+[enable_generated_files_in_srcdir=no])
+AC_MSG_RESULT($enable_generated_files_in_srcdir)
+AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
+
 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
 # We must force CC to /not/ be precious variables; otherwise
 # the wrong, non-multilib-adjusted value will be used in multilibs.
diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index 5051d31..b981473 100644
--- a/testsuite/lib/libffi.exp
+++ b/testsuite/lib/libffi.exp
@@ -16,7 +16,7 @@
 
 proc load_gcc_lib { filename } {
     global srcdir
-    load_file $srcdir/lib/$filename
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
 }
 
 load_lib dg.exp
@@ -94,6 +94,7 @@ proc libffi-init { args } {
     global srcdir
     global blddirffi
     global objdir
+    global blddircxx
     global TOOL_OPTIONS
     global tool
     global libffi_include
@@ -103,8 +104,10 @@ proc libffi-init { args } {
 
     global using_gcc
 
-    set blddirffi [pwd]/.. 
+    set blddirffi [lookfor_file [get_multilibs] libffi]
     verbose "libffi $blddirffi"
+    set blddircxx [lookfor_file [get_multilibs] libstdc++-v3]
+    verbose "libstdc++ $blddircxx"
 
     # Are we building with GCC?
     set tmp [grep ../config.status "GCC='yes'"]
@@ -144,6 +147,8 @@ proc libffi-init { args } {
 
     # add the library path for libffi.
     append ld_library_path ":${blddirffi}/.libs"
+    # add the library path for libstdc++ as well.
+    append ld_library_path ":${blddircxx}/src/.libs"
 
     verbose "ld_library_path: $ld_library_path"
 
@@ -156,6 +161,7 @@ proc libffi-init { args } {
     if { $libffi_dir != "" } {
 	set libffi_dir [file dirname ${libffi_dir}]
 	set libffi_link_flags "-L${libffi_dir}/.libs"
+	lappend libffi_link_flags "-L${blddircxx}/src/.libs"
     }
 
     set_ld_library_path_env_vars
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
  2014-11-18 10:18 ` [PATCH 1/7] " Dominik Vogt
@ 2014-11-18 10:18 ` Dominik Vogt
  2014-11-18 10:34   ` Richard Henderson
  2014-11-18 10:19 ` [PATCH 4/7] " Dominik Vogt
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:18 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 2.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0002-ChangeLog --]
[-- Type: text/plain, Size: 920 bytes --]

ChangeLog
2014-02-17  Eric Botcazou  <ebotcazou@adacore.com>

	PR libffi/60073
	* src/sparc/v8.S: Assemble only if !SPARC64.
	* src/sparc/v9.S: Remove obsolete comment.
	* src/sparc/ffitarget.h (enum ffi_abi): Add FFI_COMPAT_V9.
	(V8_ABI_P): New macro.
	(V9_ABI_P): Likewise.
	(FFI_EXTRA_CIF_FIELDS): Define only if SPARC64.
	* src/sparc/ffi.c (ffi_prep_args_v8): Compile only if !SPARC64.
	(ffi_prep_args_v9): Compile only if SPARC64.
	(ffi_prep_cif_machdep_core): Use V9_ABI_P predicate.
	(ffi_prep_cif_machdep): Guard access to nfixedargs field.
	(ffi_prep_cif_machdep_var): Likewise.
	(ffi_v9_layout_struct): Compile only if SPARC64.
	(ffi_call): Deal with FFI_V8PLUS and FFI_COMPAT_V9 and fix warnings.
	(ffi_prep_closure_loc): Use V9_ABI_P and V8_ABI_P predicates.
	(ffi_closure_sparc_inner_v8): Compile only if !SPARC64.
	(ffi_closure_sparc_inner_v9): Compile only if SPARC64.  Guard access
	to nfixedargs field.

[-- Attachment #3: 0002-PR-libffi-60073.patch --]
[-- Type: text/x-diff, Size: 18782 bytes --]

From efda7af2e3046b761ab2204c13ad6ae66535c408 Mon Sep 17 00:00:00 2001
From: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 17 Feb 2014 12:00:04 +0000
Subject: [PATCH 2/7] PR libffi/60073

* src/sparc/v8.S: Assemble only if !SPARC64.
* src/sparc/v9.S: Remove obsolete comment.
* src/sparc/ffitarget.h (enum ffi_abi): Add FFI_COMPAT_V9.
(V8_ABI_P): New macro.
(V9_ABI_P): Likewise.
(FFI_EXTRA_CIF_FIELDS): Define only if SPARC64.
* src/sparc/ffi.c (ffi_prep_args_v8): Compile only if !SPARC64.
(ffi_prep_args_v9): Compile only if SPARC64.
(ffi_prep_cif_machdep_core): Use V9_ABI_P predicate.
(ffi_prep_cif_machdep): Guard access to nfixedargs field.
(ffi_prep_cif_machdep_var): Likewise.
(ffi_v9_layout_struct): Compile only if SPARC64.
(ffi_call): Deal with FFI_V8PLUS and FFI_COMPAT_V9 and fix warnings.
(ffi_prep_closure_loc): Use V9_ABI_P and V8_ABI_P predicates.
(ffi_closure_sparc_inner_v8): Compile only if !SPARC64.
(ffi_closure_sparc_inner_v9): Compile only if SPARC64.  Guard access
to nfixedargs field.
---
 src/sparc/ffi.c       | 398 +++++++++++++++++++++++++++-----------------------
 src/sparc/ffitarget.h |  13 ++
 src/sparc/v8.S        |   5 +-
 src/sparc/v9.S        |   4 +-
 4 files changed, 235 insertions(+), 185 deletions(-)

diff --git a/src/sparc/ffi.c b/src/sparc/ffi.c
index 47cc9fd..12518e6 100644
--- a/src/sparc/ffi.c
+++ b/src/sparc/ffi.c
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    ffi.c - Copyright (c) 2011, 2013 Anthony Green
            Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc.
-   
+
    SPARC Foreign Function Interface 
 
    Permission is hereby granted, free of charge, to any person obtaining
@@ -34,93 +34,10 @@
 /* ffi_prep_args is called by the assembly routine once stack space
    has been allocated for the function's arguments */
 
-void ffi_prep_args_v8(char *stack, extended_cif *ecif)
-{
-  int i;
-  void **p_argv;
-  char *argp;
-  ffi_type **p_arg;
-
-  /* Skip 16 words for the window save area */
-  argp = stack + 16*sizeof(int);
-
-  /* This should only really be done when we are returning a structure,
-     however, it's faster just to do it all the time...
-
-  if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) */
-  *(int *) argp = (long)ecif->rvalue;
-
-  /* And 1 word for the  structure return value. */
-  argp += sizeof(int);
-
-#ifdef USING_PURIFY
-  /* Purify will probably complain in our assembly routine, unless we
-     zero out this memory. */
-
-  ((int*)argp)[0] = 0;
-  ((int*)argp)[1] = 0;
-  ((int*)argp)[2] = 0;
-  ((int*)argp)[3] = 0;
-  ((int*)argp)[4] = 0;
-  ((int*)argp)[5] = 0;
-#endif
-
-  p_argv = ecif->avalue;
-
-  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
-    {
-      size_t z;
-
-	  if ((*p_arg)->type == FFI_TYPE_STRUCT
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
-	      || (*p_arg)->type == FFI_TYPE_LONGDOUBLE
-#endif
-	      )
-	    {
-	      *(unsigned int *) argp = (unsigned long)(* p_argv);
-	      z = sizeof(int);
-	    }
-	  else
-	    {
-	      z = (*p_arg)->size;
-	      if (z < sizeof(int))
-		{
-		  z = sizeof(int);
-		  switch ((*p_arg)->type)
-		    {
-		    case FFI_TYPE_SINT8:
-		      *(signed int *) argp = *(SINT8 *)(* p_argv);
-		      break;
-		      
-		    case FFI_TYPE_UINT8:
-		      *(unsigned int *) argp = *(UINT8 *)(* p_argv);
-		      break;
-		      
-		    case FFI_TYPE_SINT16:
-		      *(signed int *) argp = *(SINT16 *)(* p_argv);
-		      break;
-		      
-		    case FFI_TYPE_UINT16:
-		      *(unsigned int *) argp = *(UINT16 *)(* p_argv);
-		      break;
-
-		    default:
-		      FFI_ASSERT(0);
-		    }
-		}
-	      else
-		{
-		  memcpy(argp, *p_argv, z);
-		}
-	    }
-	  p_argv++;
-	  argp += z;
-    }
-  
-  return;
-}
+#ifdef SPARC64
 
-int ffi_prep_args_v9(char *stack, extended_cif *ecif)
+int
+ffi_prep_args_v9(char *stack, extended_cif *ecif)
 {
   int i, ret = 0;
   int tmp;
@@ -248,12 +165,105 @@ int ffi_prep_args_v9(char *stack, extended_cif *ecif)
   return ret;
 }
 
+#else
+
+void
+ffi_prep_args_v8(char *stack, extended_cif *ecif)
+{
+  int i;
+  void **p_argv;
+  char *argp;
+  ffi_type **p_arg;
+
+  /* Skip 16 words for the window save area */
+  argp = stack + 16*sizeof(int);
+
+  /* This should only really be done when we are returning a structure,
+     however, it's faster just to do it all the time...
+
+  if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) */
+  *(int *) argp = (long)ecif->rvalue;
+
+  /* And 1 word for the  structure return value. */
+  argp += sizeof(int);
+
+#ifdef USING_PURIFY
+  /* Purify will probably complain in our assembly routine, unless we
+     zero out this memory. */
+
+  ((int*)argp)[0] = 0;
+  ((int*)argp)[1] = 0;
+  ((int*)argp)[2] = 0;
+  ((int*)argp)[3] = 0;
+  ((int*)argp)[4] = 0;
+  ((int*)argp)[5] = 0;
+#endif
+
+  p_argv = ecif->avalue;
+
+  for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
+    {
+      size_t z;
+
+	  if ((*p_arg)->type == FFI_TYPE_STRUCT
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+	      || (*p_arg)->type == FFI_TYPE_LONGDOUBLE
+#endif
+	      )
+	    {
+	      *(unsigned int *) argp = (unsigned long)(* p_argv);
+	      z = sizeof(int);
+	    }
+	  else
+	    {
+	      z = (*p_arg)->size;
+	      if (z < sizeof(int))
+		{
+		  z = sizeof(int);
+		  switch ((*p_arg)->type)
+		    {
+		    case FFI_TYPE_SINT8:
+		      *(signed int *) argp = *(SINT8 *)(* p_argv);
+		      break;
+
+		    case FFI_TYPE_UINT8:
+		      *(unsigned int *) argp = *(UINT8 *)(* p_argv);
+		      break;
+
+		    case FFI_TYPE_SINT16:
+		      *(signed int *) argp = *(SINT16 *)(* p_argv);
+		      break;
+
+		    case FFI_TYPE_UINT16:
+		      *(unsigned int *) argp = *(UINT16 *)(* p_argv);
+		      break;
+
+		    default:
+		      FFI_ASSERT(0);
+		    }
+		}
+	      else
+		{
+		  memcpy(argp, *p_argv, z);
+		}
+	    }
+	  p_argv++;
+	  argp += z;
+    }
+
+  return;
+}
+
+#endif
+
 /* Perform machine dependent cif processing */
-static ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif)
+
+static
+ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif)
 {
   int wordsize;
 
-  if (cif->abi != FFI_V9)
+  if (!V9_ABI_P (cif->abi))
     {
       wordsize = 4;
 
@@ -303,7 +313,7 @@ static ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif)
       break;
 
     case FFI_TYPE_STRUCT:
-      if (cif->abi == FFI_V9 && cif->rtype->size > 32)
+      if (V9_ABI_P (cif->abi) && cif->rtype->size > 32)
 	cif->flags = FFI_TYPE_VOID;
       else
 	cif->flags = FFI_TYPE_STRUCT;
@@ -313,7 +323,7 @@ static ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif)
     case FFI_TYPE_UINT8:
     case FFI_TYPE_SINT16:
     case FFI_TYPE_UINT16:
-      if (cif->abi == FFI_V9)
+      if (V9_ABI_P (cif->abi))
 	cif->flags = FFI_TYPE_INT;
       else
 	cif->flags = cif->rtype->type;
@@ -321,7 +331,7 @@ static ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif)
 
     case FFI_TYPE_SINT64:
     case FFI_TYPE_UINT64:
-      if (cif->abi == FFI_V9)
+      if (V9_ABI_P (cif->abi))
 	cif->flags = FFI_TYPE_INT;
       else
 	cif->flags = FFI_TYPE_SINT64;
@@ -334,20 +344,31 @@ static ffi_status ffi_prep_cif_machdep_core(ffi_cif *cif)
   return FFI_OK;
 }
 
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+ffi_status
+ffi_prep_cif_machdep(ffi_cif *cif)
 {
-  cif->nfixedargs = cif->nargs;
+#ifdef SPARC64
+  if (cif->abi != FFI_COMPAT_V9)
+    cif->nfixedargs = cif->nargs;
+#endif
   return ffi_prep_cif_machdep_core (cif);
 }
 
-ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
-				    unsigned int ntotalargs)
+ffi_status
+ffi_prep_cif_machdep_var(ffi_cif *cif, unsigned int nfixedargs,
+			 unsigned int ntotalargs)
 {
-  cif->nfixedargs = nfixedargs;
+#ifdef SPARC64
+  if (cif->abi != FFI_COMPAT_V9)
+    cif->nfixedargs = nfixedargs;
+#endif
   return ffi_prep_cif_machdep_core (cif);
 }
 
-int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt)
+#ifdef SPARC64
+
+int
+ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt)
 {
   ffi_type **ptr = &arg->elements[0];
 
@@ -380,6 +401,7 @@ int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *fl
   return off;
 }
 
+#endif
 
 #ifdef SPARC64
 extern int ffi_call_v9(void *, extended_cif *, unsigned, 
@@ -393,33 +415,37 @@ extern int ffi_call_v8(void *, extended_cif *, unsigned,
 void ffi_flush_icache (void *, size_t);
 #endif
 
-void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+void
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 {
   extended_cif ecif;
+#ifdef SPARC64
   void *rval = rvalue;
+#endif
 
   ecif.cif = cif;
   ecif.avalue = avalue;
-
-  /* If the return value is a struct and we don't have a return	*/
-  /* value address then we need to make one		        */
-
   ecif.rvalue = rvalue;
+
+  /* If the return value is a struct and we don't have a return value address,
+     then we need to make one.  */
   if (cif->rtype->type == FFI_TYPE_STRUCT)
     {
+      if (ecif.rvalue == NULL)
+	ecif.rvalue = alloca(cif->rtype->size);
+
+#ifdef SPARC64
       if (cif->rtype->size <= 32)
 	rval = alloca(64);
       else
-	{
-	  rval = NULL;
-	  if (rvalue == NULL)
-	    ecif.rvalue = alloca(cif->rtype->size);
-	}
+	rval = NULL;
+#endif
     }
 
   switch (cif->abi) 
     {
     case FFI_V8:
+    case FFI_V8PLUS:
 #ifdef SPARC64
       /* We don't yet support calling 32bit code from 64bit */
       FFI_ASSERT(0);
@@ -459,6 +485,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 #endif
 	      ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes,
 			  cif->flags, rvalue, call_struct);
+			  cif->flags, rvalue, (void (*)(void)) call_struct);
 	      ffi_closure_free(call_struct);
 	    }
 	  else
@@ -474,12 +501,13 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 	}
 #endif
       break;
+    case FFI_COMPAT_V9:
     case FFI_V9:
 #ifdef SPARC64
-      ffi_call_v9(ffi_prep_args_v9, &ecif, cif->bytes,
-		  cif->flags, rval, fn);
+      ffi_call_v9(ffi_prep_args_v9, &ecif, cif->bytes, cif->flags, rval, fn);
       if (rvalue && rval && cif->rtype->type == FFI_TYPE_STRUCT)
-	ffi_v9_layout_struct(cif->rtype, 0, (char *)rvalue, (char *)rval, ((char *)rval)+32);
+	ffi_v9_layout_struct(cif->rtype, 0, (char *)rvalue, (char *)rval,
+			     ((char *)rval)+32);
 #else
       /* And vice versa */
       FFI_ASSERT(0);
@@ -510,7 +538,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
 #ifdef SPARC64
   /* Trampoline address is equal to the closure address.  We take advantage
      of that to reduce the trampoline size by 8 bytes. */
-  if (cif->abi != FFI_V9)
+  if (!V9_ABI_P (cif->abi))
     return FFI_BAD_ABI;
   fn = (unsigned long) ffi_closure_v9;
   tramp[0] = 0x83414000;	/* rd	%pc, %g1	*/
@@ -520,7 +548,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
   *((unsigned long *) &tramp[4]) = fn;
 #else
   unsigned long ctx = (unsigned long) codeloc;
-  if (cif->abi != FFI_V8)
+  if (!V8_ABI_P (cif->abi))
     return FFI_BAD_ABI;
   fn = (unsigned long) ffi_closure_v8;
   tramp[0] = 0x03000000 | fn >> 10;	/* sethi %hi(fn), %g1	*/
@@ -549,74 +577,11 @@ ffi_prep_closure_loc (ffi_closure* closure,
   return FFI_OK;
 }
 
-int
-ffi_closure_sparc_inner_v8(ffi_closure *closure,
-  void *rvalue, unsigned long *gpr, unsigned long *scratch)
-{
-  ffi_cif *cif;
-  ffi_type **arg_types;
-  void **avalue;
-  int i, argn;
-
-  cif = closure->cif;
-  arg_types = cif->arg_types;
-  avalue = alloca(cif->nargs * sizeof(void *));
-
-  /* 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
-     )
-    rvalue = (void *) gpr[0];
-
-  /* Always skip the structure return address.  */
-  argn = 1;
-
-  /* Grab the addresses of the arguments from the stack frame.  */
-  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
-         )
-	{
-	  /* Straight copy of invisible reference.  */
-	  avalue[i] = (void *)gpr[argn++];
-	}
-      else if ((arg_types[i]->type == FFI_TYPE_DOUBLE
-	       || arg_types[i]->type == FFI_TYPE_SINT64
-	       || arg_types[i]->type == FFI_TYPE_UINT64)
-	       /* gpr is 8-byte aligned.  */
-	       && (argn % 2) != 0)
-	{
-	  /* Align on a 8-byte boundary.  */
-	  scratch[0] = gpr[argn];
-	  scratch[1] = gpr[argn+1];
-	  avalue[i] = scratch;
-	  scratch -= 2;
-	  argn += 2;
-	}
-      else
-	{
-	  /* Always right-justify.  */
-	  argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
-	  avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;
-	}
-    }
-
-  /* Invoke the closure.  */
-  (closure->fun) (cif, rvalue, avalue, closure->user_data);
-
-  /* Tell ffi_closure_sparc how to perform return type promotions.  */
-  return cif->rtype->type;
-}
+#ifdef SPARC64
 
 int
-ffi_closure_sparc_inner_v9(ffi_closure *closure,
-  void *rvalue, unsigned long *gpr, double *fpr)
+ffi_closure_sparc_inner_v9(ffi_closure *closure, void *rvalue,
+			   unsigned long *gpr, double *fpr)
 {
   ffi_cif *cif;
   ffi_type **arg_types;
@@ -645,7 +610,8 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure,
     {
       /* 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);
+      const int named
+	= (cif->abi == FFI_COMPAT_V9 ? 1 : i < cif->nfixedargs);
 
       if (arg_types[i]->type == FFI_TYPE_STRUCT)
 	{
@@ -665,7 +631,8 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure,
 				   ? (char *) &fpr[argn]
 				   : (char *) &gpr[argn]);
 	      avalue[i] = &gpr[argn];
-	      argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+	      argn
+	        += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
 	    }
 	}
       else
@@ -698,3 +665,72 @@ ffi_closure_sparc_inner_v9(ffi_closure *closure,
   /* Tell ffi_closure_sparc how to perform return type promotions.  */
   return cif->rtype->type;
 }
+
+#else
+
+int
+ffi_closure_sparc_inner_v8(ffi_closure *closure, void *rvalue,
+			   unsigned long *gpr, unsigned long *scratch)
+{
+  ffi_cif *cif;
+  ffi_type **arg_types;
+  void **avalue;
+  int i, argn;
+
+  cif = closure->cif;
+  arg_types = cif->arg_types;
+  avalue = alloca(cif->nargs * sizeof(void *));
+
+  /* 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
+     )
+    rvalue = (void *) gpr[0];
+
+  /* Always skip the structure return address.  */
+  argn = 1;
+
+  /* Grab the addresses of the arguments from the stack frame.  */
+  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
+         )
+	{
+	  /* Straight copy of invisible reference.  */
+	  avalue[i] = (void *)gpr[argn++];
+	}
+      else if ((arg_types[i]->type == FFI_TYPE_DOUBLE
+	       || arg_types[i]->type == FFI_TYPE_SINT64
+	       || arg_types[i]->type == FFI_TYPE_UINT64)
+	       /* gpr is 8-byte aligned.  */
+	       && (argn % 2) != 0)
+	{
+	  /* Align on a 8-byte boundary.  */
+	  scratch[0] = gpr[argn];
+	  scratch[1] = gpr[argn+1];
+	  avalue[i] = scratch;
+	  scratch -= 2;
+	  argn += 2;
+	}
+      else
+	{
+	  /* Always right-justify.  */
+	  argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+	  avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;
+	}
+    }
+
+  /* Invoke the closure.  */
+  closure->fun (cif, rvalue, avalue, closure->user_data);
+
+  /* Tell ffi_closure_sparc how to perform return type promotions.  */
+  return cif->rtype->type;
+}
+
+#endif
diff --git a/src/sparc/ffitarget.h b/src/sparc/ffitarget.h
index a1f5e49..6489ac0 100644
--- a/src/sparc/ffitarget.h
+++ b/src/sparc/ffitarget.h
@@ -48,6 +48,8 @@ typedef enum ffi_abi {
   FFI_FIRST_ABI = 0,
   FFI_V8,
   FFI_V8PLUS,
+  /* See below for the COMPAT_V9 rationale.  */
+  FFI_COMPAT_V9,
   FFI_V9,
   FFI_LAST_ABI,
 #ifdef SPARC64
@@ -58,8 +60,19 @@ typedef enum ffi_abi {
 } ffi_abi;
 #endif
 
+#define V8_ABI_P(abi) ((abi) == FFI_V8 || (abi) == FFI_V8PLUS)
+#define V9_ABI_P(abi) ((abi) == FFI_COMPAT_V9 || (abi) == FFI_V9)
+
 #define FFI_TARGET_SPECIFIC_VARIADIC 1
+
+/* The support of variadic functions was broken in the original implementation
+   of the FFI_V9 ABI.  This has been fixed by adding one extra field to the
+   CIF structure (nfixedargs field), which means that the ABI of libffi itself
+   has changed.  In order to support applications using the original ABI, we
+   have renamed FFI_V9 into FFI_COMPAT_V9 and defined a new FFI_V9 value.  */
+#ifdef SPARC64
 #define FFI_EXTRA_CIF_FIELDS unsigned int nfixedargs
+#endif
 
 /* ---- Definitions for closures ----------------------------------------- */
 
diff --git a/src/sparc/v8.S b/src/sparc/v8.S
index 6bf7ac0..d5af887 100644
--- a/src/sparc/v8.S
+++ b/src/sparc/v8.S
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    v8.S - Copyright (c) 2013  The Written Word, Inc.
 	  Copyright (c) 1996, 1997, 2003, 2004, 2008  Red Hat, Inc.
-   
+
    SPARC Foreign Function Interface 
 
    Permission is hereby granted, free of charge, to any person obtaining
@@ -29,6 +29,8 @@
 #include <fficonfig.h>
 #include <ffi.h>
 
+#ifndef SPARC64
+
 #define STACKFRAME 96		/* Minimum stack framesize for SPARC */
 #define ARGS (64+4)		/* Offset of register area in frame */
 
@@ -340,6 +342,7 @@ done2:
 	.byte	0x1f	! uleb128 0x1f
 	.align	WS
 .LLEFDE2:
+#endif
 
 #if defined __ELF__ && defined __linux__
 	.section	.note.GNU-stack,"",@progbits
diff --git a/src/sparc/v9.S b/src/sparc/v9.S
index bf31a2b..2c97673 100644
--- a/src/sparc/v9.S
+++ b/src/sparc/v9.S
@@ -1,6 +1,6 @@
 /* -----------------------------------------------------------------------
    v9.S - Copyright (c) 2000, 2003, 2004, 2008 Red Hat, Inc.
-   
+
    SPARC 64-bit Foreign Function Interface 
 
    Permission is hereby granted, free of charge, to any person obtaining
@@ -29,8 +29,6 @@
 #include <ffi.h>
 
 #ifdef SPARC64
-/* Only compile this in for 64bit builds, because otherwise the object file
-   will have inproper architecture due to used instructions.  */
 
 #define STACKFRAME 176		/* Minimum stack framesize for SPARC 64-bit */
 #define STACK_BIAS 2047
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
@ 2014-11-18 10:18 ` Dominik Vogt
  2014-11-18 10:33   ` Richard Henderson
  2014-11-18 10:18 ` [PATCH 2/7] " Dominik Vogt
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:18 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 1.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 529 bytes --]

ChangeLog
2014-02-13  Eric Botcazou  <ebotcazou@adacore.com>

	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.

[-- Attachment #3: 0001-PR-libffi-60073.patch --]
[-- Type: text/x-diff, Size: 5272 bytes --]

From 4a17a637e5913042bf5f7a0bfe5226cf8080991c Mon Sep 17 00:00:00 2001
From: ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
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


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 3/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
                   ` (2 preceding siblings ...)
  2014-11-18 10:19 ` [PATCH 4/7] " Dominik Vogt
@ 2014-11-18 10:19 ` Dominik Vogt
  2014-11-18 10:40   ` Richard Henderson
  2014-11-18 10:20 ` [PATCH 6/7] " Dominik Vogt
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:19 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 3.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0003-ChangeLog --]
[-- Type: text/plain, Size: 122 bytes --]

ChangeLog
2014-04-22  Jakub Jelinek  <jakub@redhat.com>

	PR other/43620
	* configure.ac (AM_INIT_AUTOMAKE): Add no-dist.

[-- Attachment #3: 0003-PR-other-43620.patch --]
[-- Type: text/x-diff, Size: 676 bytes --]

From ca8b3f328137c90995a11745b0e5ab423ed66899 Mon Sep 17 00:00:00 2001
From: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 24 Apr 2014 21:17:32 +0000
Subject: [PATCH 3/7] PR other/43620

* configure.ac (AM_INIT_AUTOMAKE): Add no-dist.
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 4a44bff..afad32c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ esac
 
 AX_ENABLE_BUILDDIR
 
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([no-dist])
 
 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
 # We must force CC to /not/ be precious variables; otherwise
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 4/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
  2014-11-18 10:18 ` [PATCH 1/7] " Dominik Vogt
  2014-11-18 10:18 ` [PATCH 2/7] " Dominik Vogt
@ 2014-11-18 10:19 ` Dominik Vogt
  2014-11-18 10:41   ` Richard Henderson
  2014-11-18 10:19 ` [PATCH 3/7] " Dominik Vogt
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:19 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 4.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0004-ChangeLog --]
[-- Type: text/plain, Size: 143 bytes --]

ChangeLog
2014-05-20  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* testsuite/lib/libffi.exp (load_gcc_lib): Register loaded libs.

[-- Attachment #3: 0004-testsuite-lib-libffi.exp-load_gcc_lib-Register-loade.patch --]
[-- Type: text/x-diff, Size: 754 bytes --]

From 4adc90da7f6d6f069f79a27362473e3d7bfac7b3 Mon Sep 17 00:00:00 2001
From: jasonwucj <jasonwucj@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 20 May 2014 08:20:06 +0000
Subject: [PATCH 4/7] testsuite/lib/libffi.exp (load_gcc_lib): Register
 loaded libs.

---
 testsuite/lib/libffi.exp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index 5051d31..b1dd1fa 100644
--- a/testsuite/lib/libffi.exp
+++ b/testsuite/lib/libffi.exp
@@ -15,8 +15,10 @@
 # <http://www.gnu.org/licenses/>.
 
 proc load_gcc_lib { filename } {
-    global srcdir
+    global srcdir loaded_libs
+
     load_file $srcdir/lib/$filename
+    set loaded_libs($filename) ""
 }
 
 load_lib dg.exp
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 6/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
                   ` (3 preceding siblings ...)
  2014-11-18 10:19 ` [PATCH 3/7] " Dominik Vogt
@ 2014-11-18 10:20 ` Dominik Vogt
  2014-11-18 10:36   ` Richard Henderson
  2014-11-18 10:20 ` [PATCH 5/7] " Dominik Vogt
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:20 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 6.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0006-ChangeLog --]
[-- Type: text/plain, Size: 170 bytes --]

ChangeLog
2014-07-21  Uros Bizjak  <ubizjak@gmail.com>

	* src/alpha/ffi.c: Do not include stdlib.h.
	(ffi_closure_osf_inner) <default>: Use FFI_ASSERT instead of abort.

[-- Attachment #3: 0006-src-alpha-ffi.c-Do-not-include-stdlib.h.patch --]
[-- Type: text/x-diff, Size: 959 bytes --]

From f23173472d9d81fb18fdbc6ad8687ea7f26ce3d0 Mon Sep 17 00:00:00 2001
From: uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 25 Jul 2014 09:01:45 +0000
Subject: [PATCH 6/7] * src/alpha/ffi.c: Do not include stdlib.h.
 (ffi_closure_osf_inner) <default>: Use FFI_ASSERT instead of abort.

---
 src/alpha/ffi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/alpha/ffi.c b/src/alpha/ffi.c
index 192f691..cf0a730 100644
--- a/src/alpha/ffi.c
+++ b/src/alpha/ffi.c
@@ -27,7 +27,6 @@
 
 #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.  */
@@ -273,7 +272,7 @@ ffi_closure_osf_inner(ffi_closure *closure, void *rvalue, unsigned long *argp)
 	  break;
 
 	default:
-	  abort ();
+	  FFI_ASSERT (0);
 	}
 
       argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 5/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
                   ` (4 preceding siblings ...)
  2014-11-18 10:20 ` [PATCH 6/7] " Dominik Vogt
@ 2014-11-18 10:20 ` Dominik Vogt
  2014-11-18 10:42   ` Richard Henderson
  2014-11-18 10:21 ` [PATCH 7/7] " Dominik Vogt
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:20 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 5.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0005-ChangeLog --]
[-- Type: text/plain, Size: 156 bytes --]

ChangeLog
2014-07-04  Thomas Schwinge  <thomas@codesourcery.com>

	* testsuite/lib/libffi.exp (libffi-dg-runtest): Change interface
	match to dg-runtest's.

[-- Attachment #3: 0005-Normalize-interface-for-all-dg-runtest.patch --]
[-- Type: text/x-diff, Size: 1265 bytes --]

From 824a9fb6e11a03bb24d583336da99be10e008738 Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 4 Jul 2014 05:28:17 +0000
Subject: [PATCH 5/7] Normalize interface for all *-dg-runtest.

---
 testsuite/lib/libffi.exp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testsuite/lib/libffi.exp b/testsuite/lib/libffi.exp
index b1dd1fa..da4e878 100644
--- a/testsuite/lib/libffi.exp
+++ b/testsuite/lib/libffi.exp
@@ -251,7 +251,7 @@ proc search_for { file pattern } {
 
 # Modified dg-runtest that can cycle through a list of optimization options
 # as c-torture does.
-proc libffi-dg-runtest { testcases default-extra-flags } {
+proc libffi-dg-runtest { testcases flags default-extra-flags } {
     global runtests
 
     foreach test $testcases {
@@ -272,9 +272,9 @@ proc libffi-dg-runtest { testcases default-extra-flags } {
 
 	set nshort [file tail [file dirname $test]]/[file tail $test]
 
-	foreach flags $option_list {
-	    verbose "Testing $nshort, $flags" 1
-	    dg-test $test $flags ${default-extra-flags}
+	foreach flags_t $option_list {
+	    verbose "Testing $nshort, $flags $flags_t" 1
+	    dg-test $test "$flags $flags_t" ${default-extra-flags}
 	}
     }
 }
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 7/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
                   ` (5 preceding siblings ...)
  2014-11-18 10:20 ` [PATCH 5/7] " Dominik Vogt
@ 2014-11-18 10:21 ` 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
  8 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 10:21 UTC (permalink / raw)
  To: libffi-discuss

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

Patch 7.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0007-ChangeLog --]
[-- Type: text/plain, Size: 195 bytes --]

ChangeLog
2014-10-15  Ian Lance Taylor  <iant@google.com>

	* configure.ac: If the compiler supports -Qunused-arguments, use
	it when running the compiler on .s files.
	* configure: Regenerated.

[-- Attachment #3: 0007-configure.ac-If-the-compiler-supports-Qunused-argume.patch --]
[-- Type: text/x-diff, Size: 2233 bytes --]

From dd32f429246bdfb929d5bebd1aa268d5eecd8de4 Mon Sep 17 00:00:00 2001
From: ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 15 Oct 2014 15:32:41 +0000
Subject: [PATCH 7/7] configure.ac: If the compiler supports
 -Qunused-arguments,

use it when running the compiler on .s files.
---
 configure.ac | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/configure.ac b/configure.ac
index afad32c..b662f39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,6 +367,15 @@ AC_C_BIGENDIAN
 
 GCC_AS_CFI_PSEUDO_OP
 
+AC_CACHE_CHECK([if compiler supports -Qunused-arguments],
+[libffi_cv_c_unused_arguments],
+[CFLAGS_hold=$CFLAGS
+CFLAGS="$CFLAGS -Qunused-arguments"
+AC_COMPILE_IFELSE([[int i;]],
+[libffi_cv_c_unused_arguments=yes],
+[libffi_cv_c_unused_arguments=no])
+CFLAGS=$CFLAGS_hold])
+
 if test x$TARGET = xSPARC; then
     AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
 	libffi_cv_as_sparc_ua_pcrel, [
@@ -403,9 +412,14 @@ if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64
 	libffi_cv_as_x86_pcrel, [
 	libffi_cv_as_x86_pcrel=no
 	echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
+	CFLAGS_hold=$CFLAGS
+	if test "$libffi_cv_c_unused_arguments" = yes; then
+	    CFLAGS="$CFLAGS -Qunused-arguments"
+	fi
 	if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
 	    libffi_cv_as_x86_pcrel=yes
 	fi
+	CFLAGS=$CFLAGS_hold
 	])
     if test "x$libffi_cv_as_x86_pcrel" = xyes; then
 	AC_DEFINE(HAVE_AS_X86_PCREL, 1,
@@ -489,10 +503,15 @@ EOF
 	libffi_cv_as_x86_64_unwind_section_type=no
 	# we ensure that we can compile _and_ link an assembly file containing an @unwind section
 	# since the compiler can support it and not the linker (ie old binutils)
+	CFLAGS_hold=$CFLAGS
+	if test "$libffi_cv_c_unused_arguments" = yes; then
+	    CFLAGS="$CFLAGS -Qunused-arguments"
+	fi
 	if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
            $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
 	    libffi_cv_as_x86_64_unwind_section_type=yes
 	fi
+	CFLAGS=$CFLAGS_hold
 	])
     if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
 	AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
                   ` (6 preceding siblings ...)
  2014-11-18 10:21 ` [PATCH 7/7] " Dominik Vogt
@ 2014-11-18 10:32 ` Richard Henderson
  2014-11-18 10:47 ` Richard Henderson
  8 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:32 UTC (permalink / raw)
  To: libffi-discuss

On 11/18/2014 11:17 AM, Dominik Vogt wrote:
> The following series of patches merges the changes in gcc's copy
> of libffi since this gcc-commit:
> 
>   2012-12-26 16:28 green        * <libffi-last-merge> libffi merge
> 
> While I've tried to resolve conflicts in a sensible way, I've not
> made any effort to check what the patches do or whether they are
> (still) useful, so please double check before checking in.  libffi
> still compiles after applying the patches 1 to 7 (without path
> "0", see below), but I've not run any tests.
> 
> The "zeroth" patch is attached right to this message.  To me it
> looks like a patch that is applied to gcc every time libffi is
> merged, but there may be unrelated bits; I cannot judge that.  (The
> patch conflicts with a later patch in the series, but the conflict
> is easy to resolve.)

I wonder how much of this we could merge with an

  AM_CONDITIONAL(IN_GCC, ...)

where the setting of IN_GCC of course changes between the standalone and
in-tree builds.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/7] Merge of gcc patches
  2014-11-18 10:18 ` [PATCH 1/7] " Dominik Vogt
@ 2014-11-18 10:33   ` Richard Henderson
  2014-11-18 13:13     ` Richard Henderson
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:33 UTC (permalink / raw)
  To: libffi-discuss

The idea behind this patch still applies, but of course
the actual code has moved to a new file.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/7] Merge of gcc patches
  2014-11-18 10:18 ` [PATCH 2/7] " Dominik Vogt
@ 2014-11-18 10:34   ` Richard Henderson
  0 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:34 UTC (permalink / raw)
  To: libffi-discuss

This has effectively already been applied.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/7] Merge of gcc patches
  2014-11-18 10:20 ` [PATCH 6/7] " Dominik Vogt
@ 2014-11-18 10:36   ` Richard Henderson
  2014-11-18 11:06     ` Dominik Vogt
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:36 UTC (permalink / raw)
  To: libffi-discuss

This has in effect already been applied.  Note that FFI_TYPE_VOID now appears
in the switch statement.  The abort now only applies to true out-of-bounds, aka
corrupt, ffi_type data.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 7/7] Merge of gcc patches
  2014-11-18 10:21 ` [PATCH 7/7] " Dominik Vogt
@ 2014-11-18 10:37   ` Richard Henderson
  0 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:37 UTC (permalink / raw)
  To: libffi-discuss

I guess this is for clang, since I don't recognize the argument.

I see no harm in it, though, honestly I don't see why we keep toggling it in
and out.  Perhaps better to just include it all the time, since IMO it's a
stupid warning that we'd rather not be bothered with.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/7] Merge of gcc patches
  2014-11-18 10:19 ` [PATCH 3/7] " Dominik Vogt
@ 2014-11-18 10:40   ` Richard Henderson
  0 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:40 UTC (permalink / raw)
  To: libffi-discuss

On 11/18/2014 11:19 AM, Dominik Vogt wrote:
> 	PR other/43620
> 	* configure.ac (AM_INIT_AUTOMAKE): Add no-dist.

Unless we don't care about "make dist" for standalone libffi at all, then we
can't include this.

Anthony, do you actually do anything with "make dist" when you do a release, or
do you just tag the git repository?


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/7] Merge of gcc patches
  2014-11-18 10:19 ` [PATCH 4/7] " Dominik Vogt
@ 2014-11-18 10:41   ` Richard Henderson
  0 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:41 UTC (permalink / raw)
  To: libffi-discuss

On 11/18/2014 11:19 AM, Dominik Vogt wrote:
> 	* testsuite/lib/libffi.exp (load_gcc_lib): Register loaded libs.

Looks good.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/7] Merge of gcc patches
  2014-11-18 10:20 ` [PATCH 5/7] " Dominik Vogt
@ 2014-11-18 10:42   ` Richard Henderson
  0 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:42 UTC (permalink / raw)
  To: libffi-discuss

On 11/18/2014 11:19 AM, Dominik Vogt wrote:
> 	* testsuite/lib/libffi.exp (libffi-dg-runtest): Change interface
> 	match to dg-runtest's.

Looks good.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/7] Merge of gcc patches
  2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
                   ` (7 preceding siblings ...)
  2014-11-18 10:32 ` [PATCH 0/7] " Richard Henderson
@ 2014-11-18 10:47 ` Richard Henderson
  8 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 10:47 UTC (permalink / raw)
  To: libffi-discuss

By the by, I've been testing a merge the other direction:

  git://github.com/rth7680/gcc.git rth/ffi

It's much less systematic than your merge this direction,
and it did in fact miss that Sparc variadic patch.

Curiously, there are no testsuite failures on sparc64, so
there must be some test case that we're missing...


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/7] Merge of gcc patches
  2014-11-18 10:36   ` Richard Henderson
@ 2014-11-18 11:06     ` Dominik Vogt
  2014-11-18 11:34       ` Richard Henderson
  0 siblings, 1 reply; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 11:06 UTC (permalink / raw)
  To: libffi-discuss

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

On Tue, Nov 18, 2014 at 11:35:50AM +0100, Richard Henderson wrote:
> This has in effect already been applied.  Note that FFI_TYPE_VOID now appears
> in the switch statement.  The abort now only applies to true out-of-bounds, aka
> corrupt, ffi_type data.

Ah, I see.  The first half of the patch still looks useful though.
Updated patch attached.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0006-ChangeLog --]
[-- Type: text/plain, Size: 101 bytes --]

ChangeLog
2014-07-21  Uros Bizjak  <ubizjak@gmail.com>

	* src/alpha/ffi.c: Do not include stdlib.h.

[-- Attachment #3: 0006-src-alpha-ffi.c-Do-not-include-stdlib.h.patch --]
[-- Type: text/x-diff, Size: 645 bytes --]

From 4478b515536ee437f78221c3062ee00727962764 Mon Sep 17 00:00:00 2001
From: uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 25 Jul 2014 09:01:45 +0000
Subject: [PATCH 6/7] src/alpha/ffi.c: Do not include stdlib.h.

---
 src/alpha/ffi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/alpha/ffi.c b/src/alpha/ffi.c
index 192f691..7d72b0c 100644
--- a/src/alpha/ffi.c
+++ b/src/alpha/ffi.c
@@ -27,7 +27,6 @@
 
 #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.  */
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/7] Merge of gcc patches
  2014-11-18 11:06     ` Dominik Vogt
@ 2014-11-18 11:34       ` Richard Henderson
  2014-11-18 11:57         ` Dominik Vogt
  0 siblings, 1 reply; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 11:34 UTC (permalink / raw)
  To: libffi-discuss

On 11/18/2014 12:06 PM, Dominik Vogt wrote:
> 	* src/alpha/ffi.c: Do not include stdlib.h.

But we still do use abort in there.  One could argue that perhaps this belongs
in ffi_common.h, but it's not currently included there so I don't see simply
removing it as the right thing to do.


r~

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 6/7] Merge of gcc patches
  2014-11-18 11:34       ` Richard Henderson
@ 2014-11-18 11:57         ` Dominik Vogt
  0 siblings, 0 replies; 21+ messages in thread
From: Dominik Vogt @ 2014-11-18 11:57 UTC (permalink / raw)
  To: libffi-discuss

On Tue, Nov 18, 2014 at 12:34:02PM +0100, Richard Henderson wrote:
> On 11/18/2014 12:06 PM, Dominik Vogt wrote:
> > 	* src/alpha/ffi.c: Do not include stdlib.h.
> 
> But we still do use abort in there.  One could argue that perhaps this belongs
> in ffi_common.h, but it's not currently included there so I don't see simply
> removing it as the right thing to do.

Oh, you're right.  I didn't make the connection that abort() comes
from stdlib.h.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/7] Merge of gcc patches
  2014-11-18 10:33   ` Richard Henderson
@ 2014-11-18 13:13     ` Richard Henderson
  0 siblings, 0 replies; 21+ messages in thread
From: Richard Henderson @ 2014-11-18 13:13 UTC (permalink / raw)
  To: libffi-discuss

[-- 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


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2014-11-18 13:13 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18 10:17 [PATCH 0/7] Merge of gcc patches Dominik Vogt
2014-11-18 10:18 ` [PATCH 1/7] " Dominik Vogt
2014-11-18 10:33   ` Richard Henderson
2014-11-18 13:13     ` Richard Henderson
2014-11-18 10:18 ` [PATCH 2/7] " Dominik Vogt
2014-11-18 10:34   ` Richard Henderson
2014-11-18 10:19 ` [PATCH 4/7] " Dominik Vogt
2014-11-18 10:41   ` Richard Henderson
2014-11-18 10:19 ` [PATCH 3/7] " Dominik Vogt
2014-11-18 10:40   ` 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:20 ` [PATCH 5/7] " Dominik Vogt
2014-11-18 10:42   ` Richard Henderson
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

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).