This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch libgcc]: Fix float128 soft-float for mingw targets


2012/2/27 Joseph S. Myers <joseph@codesourcery.com>:
> As explained in codingconventions.html, soft-fp is imported from glibc.
> For files that come from glibc, you can only copy in the glibc versions,
> unchanged.

Ok, thanks for explaination.

> Thus, you should submit this fix to libc-alpha. ?You'll need to explain
> what the differences in struct layout actually are. ?In my view, rather
> than adding any __MINGW32__ conditionals in the header, you should instead
> have an _FP_STRUCT_LAYOUT macro that sfp-machine.h can define, and that
> soft-fp.h defines to empty if not defined in sfp-machine.h. ?That way
> quad.h can use _FP_STRUCT_LAYOUT and you avoid any conditionals on
> __MINGW32__ in any of the core soft-fp code.

Ok, I adjusted patch according to your suggestion.  The need for
marking bitfield struct/union definitions by a struct-layout-attribute
for mingw targets is that for those targets the default is ms_struct
layout.  This is in some points about bitfields different.

For gcc_struct variant bitfields with different types get merged
together, but for ms_struct  bitfields are getting merged together
only, if they have same type.  As in those structures - I modified in
this patch - we have varying types for bitfields, this struct-layout
attribute is required.

> I would have expected any struct layout issue to apply to the other
> headers (single.h, double.h, extended.h) just as to quad.h, so if you're
> only changing one header you'll need to explain why the issue doesn't
> affect the others.

Yes, I noticed the issue only for quad.h, and other routines seems not
to be used on IA mingw hosts.  Nevertheless I revised my patch to mark
also bitfield-structures in extended.h
by _FP_STRUCT_LAYOUT macro.

> --
> Joseph S. Myers
> joseph@codesourcery.com


ChangeLog

2012-02-28  Kai Tietz  <ktietz@redhat.com>

	* config/i386/sfp-machine.h (_FP_STRUCT_LAYOUT): Define it
	for mingw-targets as attribute gcc_struct.
	* soft-fp/soft-fp.h (_FP_STRUCT_LAYOUT): If not defined,
	define it as empty macro.
	* soft-fp/quad.h: Mark bitfield-structures by _FP_STRUCT_LAYOUT.
	* soft-fp/extended.h: Mark bitfield-structures by _FP_STRUCT_LAYOUT.

Patch tested for i686-w64-mingw32, x86_64-w64-mingw32, and for
x86_64-unknown-linux-gnu (with full regression-testing for all
languages including Ada and Obj-c++).

Ok for apply?

Regards,
Kai

Index: config/i386/sfp-machine.h
===================================================================
--- config/i386/sfp-machine.h	(revision 184486)
+++ config/i386/sfp-machine.h	(working copy)
@@ -1,3 +1,8 @@
+#ifdef __MINGW32__
+  /* Make sure we are using gnu-style bitfield handling.  */
+#define _FP_STRUCT_LAYOUT  __attribute__ ((gcc_struct))
+#endif
+
 #ifdef __x86_64__
 #include "config/i386/64/sfp-machine.h"
 #else
Index: soft-fp/extended.h
===================================================================
--- soft-fp/extended.h	(revision 184486)
+++ soft-fp/extended.h	(working copy)
@@ -64,7 +64,7 @@
 union _FP_UNION_E
 {
    XFtype flt;
-   struct
+   struct _FP_STRUCT_LAYOUT
    {
 #if __BYTE_ORDER == __BIG_ENDIAN
       unsigned long pad1 : _FP_W_TYPE_SIZE;
@@ -263,7 +263,7 @@
 union _FP_UNION_E
 {
   XFtype flt;
-  struct {
+  struct _FP_STRUCT_LAYOUT {
 #if __BYTE_ORDER == __BIG_ENDIAN
     _FP_W_TYPE pad  : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
     unsigned sign   : 1;
Index: soft-fp/quad.h
===================================================================
--- soft-fp/quad.h	(revision 184486)
+++ soft-fp/quad.h	(working copy)
@@ -67,7 +67,7 @@
 union _FP_UNION_Q
 {
    TFtype flt;
-   struct
+   struct _FP_STRUCT_LAYOUT
    {
 #if __BYTE_ORDER == __BIG_ENDIAN
       unsigned sign : 1;
@@ -174,7 +174,8 @@
   struct {
     _FP_W_TYPE a, b;
   } longs;
-  struct {
+  struct _FP_STRUCT_LAYOUT
+  {
 #if __BYTE_ORDER == __BIG_ENDIAN
     unsigned sign    : 1;
     unsigned exp     : _FP_EXPBITS_Q;
Index: soft-fp/soft-fp.h
===================================================================
--- soft-fp/soft-fp.h	(revision 184486)
+++ soft-fp/soft-fp.h	(working copy)
@@ -210,4 +210,8 @@
 extern void abort (void);
 #endif

+#ifndef _FP_STRUCT_LAYOUT
+#define _FP_STRUCT_LAYOUT
 #endif
+
+#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]