Skip to contentSkip to conversation

softfloat: fix for C99

PATCH Applied Avi Kivity 3 participants 6 messages Dec 27, 2011 – Mar 17, 2012

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 softfloat: fix for C99

C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers. Switch to ordinary initializer syntax.

---
 fpu/softfloat-specialize.h |    8 ++++----
 fpu/softfloat.h            |    2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)
fpu/softfloat-specialize.h +4 -4
index c5e2dab..4902450 100644
@@ -89,8 +89,8 @@ const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 ));
 #define floatx80_default_nan_low  LIT64( 0xC000000000000000 )
 #endif
 
-const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
-                                                    floatx80_default_nan_low);
+const floatx80 floatx80_default_nan
+    = make_floatx80_init(floatx80_default_nan_high, floatx80_default_nan_low);
 
 /*----------------------------------------------------------------------------
 | The pattern for a default generated quadruple-precision NaN.  The `high' and
@@ -104,8 +104,8 @@ const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
 #define float128_default_nan_low  LIT64( 0x0000000000000000 )
 #endif
 
-const float128 float128_default_nan = make_float128(float128_default_nan_high,
-                                                    float128_default_nan_low);
+const float128 float128_default_nan
+    = make_float128_init(float128_default_nan_high, float128_default_nan_low);
 
 /*----------------------------------------------------------------------------
 | Raises the exceptions specified by `flags'.  Floating-point traps can be
fpu/softfloat.h +2 -0
index 07c2929..2ce4110 100644
@@ -129,6 +129,7 @@ typedef struct {
     uint16_t high;
 } floatx80;
 #define make_floatx80(exp, mant) ((floatx80) { mant, exp })
+#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
 typedef struct {
 #ifdef HOST_WORDS_BIGENDIAN
     uint64_t high, low;
@@ -137,6 +138,7 @@ typedef struct {
 #endif
 } float128;
 #define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ })
+#define make_float128_init(high_, low_) { .high = high_, .low = low_ }
 
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE floating-point underflow tininess-detection mode.
Signature · 1 line
1.7.7.1
Acked-by on v1 1/1
#1 lore raw

Am 27.12.2011 16:11, schrieb Avi Kivity:

Quoted 5 lines

C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers. Switch to ordinary initializer syntax.

For the record, tested with --extra-cflags=-std=gnu99.

fpu/softfloat-specialize.h const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 )); · line 93

Quoted 12 lines
fpu/softfloat-specialize.h +2 -2
index c5e2dab..4902450 100644
@@ -89,8 +89,8 @@ const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 ));
 #define floatx80_default_nan_low  LIT64( 0xC000000000000000 )
 #endif
 
-const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
-                                                    floatx80_default_nan_low);
+const floatx80 floatx80_default_nan
+    = make_floatx80_init(floatx80_default_nan_high, floatx80_default_nan_low);

Calling it init_floatx80 would avoid the line break, but I'm okay with it either way.

Thanks,
Andreas

$ gcc --version
gcc (SUSE Linux) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw

Am 27.12.2011 17:15, schrieb Andreas Färber:

Quoted 5 lines

Am 27.12.2011 16:11, schrieb Avi Kivity:

Quoted 4 lines

C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers. Switch to ordinary initializer syntax.

Quoted 14 lines
Quoted 1 line

For the record, tested with --extra-cflags=-std=gnu99.

Quoted 8 lines
fpu/softfloat-specialize.h +0 -0
index c5e2dab..4902450 100644
@@ -89,8 +89,8 @@ const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 ));
 #define floatx80_default_nan_low  LIT64( 0xC000000000000000 )
 #endif
 
Quoted 7 lines

fpu/softfloat-specialize.h const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 )); · line 93

Quoted 4 lines
fpu/softfloat-specialize.h +2 -2
-const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
-                                                    floatx80_default_nan_low);
+const floatx80 floatx80_default_nan
+    = make_floatx80_init(floatx80_default_nan_high, floatx80_default_nan_low);

Calling it init_floatx80 would avoid the line break, but I'm okay with it either way.

Ping! Avi, you didn't indicate whether you were going to simplify this patch or whether you're waiting for someone to apply it as is?

Regards,
Andreas

Quoted 10 lines

Thanks,
Andreas

$ gcc --version
gcc (SUSE Linux) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
author
#3 lore raw
Quoted 31 lines · Andreas Färber

Am 27.12.2011 17:15, schrieb Andreas Färber:

Quoted 5 lines

Am 27.12.2011 16:11, schrieb Avi Kivity:

Quoted 4 lines

C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers. Switch to ordinary initializer syntax.

Quoted 14 lines
Quoted 1 line

For the record, tested with --extra-cflags=-std=gnu99.

Quoted 8 lines
fpu/softfloat-specialize.h +0 -0
index c5e2dab..4902450 100644
@@ -89,8 +89,8 @@ const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 ));
 #define floatx80_default_nan_low  LIT64( 0xC000000000000000 )
 #endif
 
Quoted 7 lines

fpu/softfloat-specialize.h const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 )); · line 93

Quoted 4 lines
fpu/softfloat-specialize.h +2 -2
-const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
-                                                    floatx80_default_nan_low);
+const floatx80 floatx80_default_nan
+    = make_floatx80_init(floatx80_default_nan_high, floatx80_default_nan_low);

Calling it init_floatx80 would avoid the line break, but I'm okay with it either way.

Quoted 3 lines

Ping! Avi, you didn't indicate whether you were going to simplify this patch or whether you're waiting for someone to apply it as is?

Actually I forgot all about it. If everyone's okay with it as is I'd like it to be applied, otherwise I'll respin. Copying some maintainers completely at random.

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw

Am 09.02.2012 17:38, schrieb Avi Kivity:

Quoted 32 lines · Andreas Färber
Quoted 31 lines

Am 27.12.2011 17:15, schrieb Andreas Färber:

Quoted 5 lines

Am 27.12.2011 16:11, schrieb Avi Kivity:

Quoted 4 lines

C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers. Switch to ordinary initializer syntax.

Quoted 21 lines
Quoted 1 line

For the record, tested with --extra-cflags=-std=gnu99.

fpu/softfloat-specialize.h const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 )); · line 93

Quoted 12 lines
fpu/softfloat-specialize.h +2 -2
index c5e2dab..4902450 100644
@@ -89,8 +89,8 @@ const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 ));
 #define floatx80_default_nan_low  LIT64( 0xC000000000000000 )
 #endif
 
-const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
-                                                    floatx80_default_nan_low);
+const floatx80 floatx80_default_nan
+    = make_floatx80_init(floatx80_default_nan_high, floatx80_default_nan_low);

Calling it init_floatx80 would avoid the line break, but I'm okay with it either way.

Quoted 7 lines
Quoted 3 lines

Ping! Avi, you didn't indicate whether you were going to simplify this patch or whether you're waiting for someone to apply it as is?

Actually I forgot all about it. If everyone's okay with it as is I'd like it to be applied, otherwise I'll respin. Copying some maintainers completely at random.

Ping?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Applied
#5 lore raw
In reply to Avi Kivity

Thanks, applied.

Quoted 60 lines · Avi Kivity

C99 appears to consider compound literals as non-constants, and complains when they are used in static initializers.  Switch to ordinary initializer syntax.

---
 fpu/softfloat-specialize.h |    8 ++++----
 fpu/softfloat.h            |    2 ++

 2 files changed, 6 insertions(+), 4 deletions(-)
fpu/softfloat-specialize.h +2 -2
index c5e2dab..4902450 100644
@@ -89,8 +89,8 @@ const float64 float64_default_nan = const_float64(LIT64( 0xFFF8000000000000 ));
  #define floatx80_default_nan_low  LIT64( 0xC000000000000000 )
  #endif
 
-const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
-                                                    floatx80_default_nan_low);
+const floatx80 floatx80_default_nan
+    = make_floatx80_init(floatx80_default_nan_high, floatx80_default_nan_low);
 
  /*----------------------------------------------------------------------------

 | The pattern for a default generated quadruple-precision NaN.  The `high' and

fpu/softfloat-specialize.h +2 -2
@@ -104,8 +104,8 @@ const floatx80 floatx80_default_nan = make_floatx80(floatx80_default_nan_high,
  #define float128_default_nan_low  LIT64( 0x0000000000000000 )
  #endif
 
-const float128 float128_default_nan = make_float128(float128_default_nan_high,
-                                                    float128_default_nan_low);
+const float128 float128_default_nan
+    = make_float128_init(float128_default_nan_high, float128_default_nan_low);
 
  /*----------------------------------------------------------------------------

 | Raises the exceptions specified by `flags'.  Floating-point traps can be

fpu/softfloat.h +2 -0
index 07c2929..2ce4110 100644
@@ -129,6 +129,7 @@ typedef struct {
     uint16_t high;
  } floatx80;
  #define make_floatx80(exp, mant) ((floatx80) { mant, exp })
+#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
  typedef struct {
  #ifdef HOST_WORDS_BIGENDIAN
     uint64_t high, low;
@@ -137,6 +138,7 @@ typedef struct {
  #endif
  } float128;
  #define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ })
+#define make_float128_init(high_, low_) { .high = high_, .low = low_ }
 
  /*----------------------------------------------------------------------------

 | Software IEC/IEEE floating-point underflow tininess-detection mode. --
1.7.7.1