public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* Fix powerpc breakage from 6e8a4460
@ 2014-11-10  4:24 Alan Modra
  2014-11-10  9:51 ` Dominik Vogt
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2014-11-10  4:24 UTC (permalink / raw)
  To: libffi-discuss; +Cc: Richard Henderson, Lynn A. Boger

The addition of FFI_TYPE_COMPLEX broke powerpc libffi, showing up as
four testsuite failures on powerpc64le.  This fixes the breakage and
ensures a more spectacular set of failures if something like this
happens again.

	* src/powerpc/ffitarget.h: #error on unexpected FFI_TYPE_LAST.
	(FFI_PPC_TYPE_LAST): Define.
	(FFI_TYPE_UINT128): Define in terms of FFI_PPC_TYPE_LAST.
	(FFI_SYSV_TYPE_SMALL_STRUCT, FFI_V2_TYPE_FLOAT_HOMOG): Likewise.
	(FFI_V2_TYPE_DOUBLE_HOMOG, FFI_V2_TYPE_SMALL_STRUCT): Likewise.
---
 src/powerpc/ffitarget.h | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/powerpc/ffitarget.h b/src/powerpc/ffitarget.h
index b47b0f5..84aa586 100644
--- a/src/powerpc/ffitarget.h
+++ b/src/powerpc/ffitarget.h
@@ -142,19 +142,30 @@ typedef enum ffi_abi {
 # define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs
 #endif
 
-/* For additional types like the below, take care about the order in
-   ppc_closures.S. They must follow after the FFI_TYPE_LAST.  */
+/* ppc_closure.S and linux64_closure.S expect this.  */
+#define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER
+
+/* We define additional types below.  If generic types are added that
+   must be supported by powerpc libffi then it is likely that
+   FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in
+   ppc_closure.S and linux64_closure.S be extended.  */
+
+#if !(FFI_TYPE_LAST == FFI_PPC_TYPE_LAST		\
+      || (FFI_TYPE_LAST == FFI_TYPE_COMPLEX		\
+	  && !defined FFI_TARGET_HAS_COMPLEX_TYPE))
+# error "You likely have a broken powerpc libffi"
+#endif
 
 /* Needed for soft-float long-double-128 support.  */
-#define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1)
+#define FFI_TYPE_UINT128 (FFI_PPC_TYPE_LAST + 1)
 
 /* Needed for FFI_SYSV small structure returns.  */
-#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2)
+#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_PPC_TYPE_LAST + 2)
 
 /* Used by ELFv2 for homogenous structure returns.  */
-#define FFI_V2_TYPE_FLOAT_HOMOG		(FFI_TYPE_LAST + 1)
-#define FFI_V2_TYPE_DOUBLE_HOMOG	(FFI_TYPE_LAST + 2)
-#define FFI_V2_TYPE_SMALL_STRUCT	(FFI_TYPE_LAST + 3)
+#define FFI_V2_TYPE_FLOAT_HOMOG		(FFI_PPC_TYPE_LAST + 1)
+#define FFI_V2_TYPE_DOUBLE_HOMOG	(FFI_PPC_TYPE_LAST + 2)
+#define FFI_V2_TYPE_SMALL_STRUCT	(FFI_PPC_TYPE_LAST + 3)
 
 #if _CALL_ELF == 2
 # define FFI_TRAMPOLINE_SIZE 32

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: Fix powerpc breakage from 6e8a4460
  2014-11-10  4:24 Fix powerpc breakage from 6e8a4460 Alan Modra
@ 2014-11-10  9:51 ` Dominik Vogt
  2014-11-11 13:19   ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Vogt @ 2014-11-10  9:51 UTC (permalink / raw)
  To: libffi-discuss

On Mon, Nov 10, 2014 at 02:54:42PM +1030, Alan Modra wrote:
> The addition of FFI_TYPE_COMPLEX broke powerpc libffi, showing up as
> four testsuite failures on powerpc64le.  This fixes the breakage and
> ensures a more spectacular set of failures if something like this
> happens again.
> 
> 	* src/powerpc/ffitarget.h: #error on unexpected FFI_TYPE_LAST.
...
> +/* ppc_closure.S and linux64_closure.S expect this.  */
> +#define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER
> +
> +/* We define additional types below.  If generic types are added that
> +   must be supported by powerpc libffi then it is likely that
> +   FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in
> +   ppc_closure.S and linux64_closure.S be extended.  */

Does this affect only powerpc?  Is there any risk of breaking other
platforms too?

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

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

* Re: Fix powerpc breakage from 6e8a4460
  2014-11-10  9:51 ` Dominik Vogt
@ 2014-11-11 13:19   ` Alan Modra
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Modra @ 2014-11-11 13:19 UTC (permalink / raw)
  To: Dominik Vogt; +Cc: libffi-discuss

On Mon, Nov 10, 2014 at 10:51:07AM +0100, Dominik Vogt wrote:
> On Mon, Nov 10, 2014 at 02:54:42PM +1030, Alan Modra wrote:
> > The addition of FFI_TYPE_COMPLEX broke powerpc libffi, showing up as
> > four testsuite failures on powerpc64le.  This fixes the breakage and
> > ensures a more spectacular set of failures if something like this
> > happens again.
> > 
> > 	* src/powerpc/ffitarget.h: #error on unexpected FFI_TYPE_LAST.
> ...
> > +/* ppc_closure.S and linux64_closure.S expect this.  */
> > +#define FFI_PPC_TYPE_LAST FFI_TYPE_POINTER
> > +
> > +/* We define additional types below.  If generic types are added that
> > +   must be supported by powerpc libffi then it is likely that
> > +   FFI_PPC_TYPE_LAST needs increasing *and* the jump tables in
> > +   ppc_closure.S and linux64_closure.S be extended.  */
> 
> Does this affect only powerpc?  Is there any risk of breaking other
> platforms too?

My patch only fixes powerpc.  I hadn't looked at other targets,
but a quick grep shows at least alpha-osf, ia64, and some x86 targets
were broken by changing FFI_TYPE_LAST.

-- 
Alan Modra
Australia Development Lab, IBM

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-10  4:24 Fix powerpc breakage from 6e8a4460 Alan Modra
2014-11-10  9:51 ` Dominik Vogt
2014-11-11 13:19   ` Alan Modra

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