* [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
@ 2017-09-18 10:46 Laurent Vivier
2017-09-18 12:47 ` Philippe Mathieu-Daudé
2017-09-19 16:30 ` Richard Henderson
0 siblings, 2 replies; 7+ messages in thread
From: Laurent Vivier @ 2017-09-18 10:46 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Aurelien Jarno, Laurent Vivier
We already have const_float16(), const_float32() and const_float64(),
so rename make_floatx80_init() and make_float128_init() as
const_floatx80() and const_float128().
Redefine make_floatx80() and make_float128() as make_float16(),
make_float32() and make_float64() using a variable and not only
a cast.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
include/fpu/softfloat.h | 10 ++++++----
target/m68k/fpu_helper.c | 44 ++++++++++++++++++++++----------------------
2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 0f96a0edd1..2e1a79ebf7 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -146,8 +146,9 @@ typedef struct {
uint64_t low;
uint16_t high;
} floatx80;
-#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
-#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
+#define make_floatx80(exp, mant) __extension__ \
+ ({ floatx80 f80_val = { .low = mant, .high = exp }; f80_val; })
+#define const_floatx80(exp, mant) { .low = mant, .high = exp }
typedef struct {
#ifdef HOST_WORDS_BIGENDIAN
uint64_t high, low;
@@ -155,8 +156,9 @@ typedef struct {
uint64_t low, high;
#endif
} float128;
-#define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ })
-#define make_float128_init(high_, low_) { .high = high_, .low = low_ }
+#define make_float128(high_, low_) __extension__ \
+ ({float128 f128_val = { .high = high_, .low = low_ }; f128_val; })
+#define const_float128(high_, low_) { .high = high_, .low = low_ }
/*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point underflow tininess-detection mode.
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
index 665e7609af..bf62cf8003 100644
--- a/target/m68k/fpu_helper.c
+++ b/target/m68k/fpu_helper.c
@@ -29,28 +29,28 @@
*/
static const floatx80 fpu_rom[128] = {
- [0x00] = make_floatx80_init(0x4000, 0xc90fdaa22168c235ULL), /* Pi */
- [0x0b] = make_floatx80_init(0x3ffd, 0x9a209a84fbcff798ULL), /* Log10(2) */
- [0x0c] = make_floatx80_init(0x4000, 0xadf85458a2bb4a9aULL), /* e */
- [0x0d] = make_floatx80_init(0x3fff, 0xb8aa3b295c17f0bcULL), /* Log2(e) */
- [0x0e] = make_floatx80_init(0x3ffd, 0xde5bd8a937287195ULL), /* Log10(e) */
- [0x0f] = make_floatx80_init(0x0000, 0x0000000000000000ULL), /* Zero */
- [0x30] = make_floatx80_init(0x3ffe, 0xb17217f7d1cf79acULL), /* ln(2) */
- [0x31] = make_floatx80_init(0x4000, 0x935d8dddaaa8ac17ULL), /* ln(10) */
- [0x32] = make_floatx80_init(0x3fff, 0x8000000000000000ULL), /* 10^0 */
- [0x33] = make_floatx80_init(0x4002, 0xa000000000000000ULL), /* 10^1 */
- [0x34] = make_floatx80_init(0x4005, 0xc800000000000000ULL), /* 10^2 */
- [0x35] = make_floatx80_init(0x400c, 0x9c40000000000000ULL), /* 10^4 */
- [0x36] = make_floatx80_init(0x4019, 0xbebc200000000000ULL), /* 10^8 */
- [0x37] = make_floatx80_init(0x4034, 0x8e1bc9bf04000000ULL), /* 10^16 */
- [0x38] = make_floatx80_init(0x4069, 0x9dc5ada82b70b59eULL), /* 10^32 */
- [0x39] = make_floatx80_init(0x40d3, 0xc2781f49ffcfa6d5ULL), /* 10^64 */
- [0x3a] = make_floatx80_init(0x41a8, 0x93ba47c980e98ce0ULL), /* 10^128 */
- [0x3b] = make_floatx80_init(0x4351, 0xaa7eebfb9df9de8eULL), /* 10^256 */
- [0x3c] = make_floatx80_init(0x46a3, 0xe319a0aea60e91c7ULL), /* 10^512 */
- [0x3d] = make_floatx80_init(0x4d48, 0xc976758681750c17ULL), /* 10^1024 */
- [0x3e] = make_floatx80_init(0x5a92, 0x9e8b3b5dc53d5de5ULL), /* 10^2048 */
- [0x3f] = make_floatx80_init(0x7525, 0xc46052028a20979bULL), /* 10^4096 */
+ [0x00] = const_floatx80(0x4000, 0xc90fdaa22168c235ULL), /* Pi */
+ [0x0b] = const_floatx80(0x3ffd, 0x9a209a84fbcff798ULL), /* Log10(2) */
+ [0x0c] = const_floatx80(0x4000, 0xadf85458a2bb4a9aULL), /* e */
+ [0x0d] = const_floatx80(0x3fff, 0xb8aa3b295c17f0bcULL), /* Log2(e) */
+ [0x0e] = const_floatx80(0x3ffd, 0xde5bd8a937287195ULL), /* Log10(e) */
+ [0x0f] = const_floatx80(0x0000, 0x0000000000000000ULL), /* Zero */
+ [0x30] = const_floatx80(0x3ffe, 0xb17217f7d1cf79acULL), /* ln(2) */
+ [0x31] = const_floatx80(0x4000, 0x935d8dddaaa8ac17ULL), /* ln(10) */
+ [0x32] = const_floatx80(0x3fff, 0x8000000000000000ULL), /* 10^0 */
+ [0x33] = const_floatx80(0x4002, 0xa000000000000000ULL), /* 10^1 */
+ [0x34] = const_floatx80(0x4005, 0xc800000000000000ULL), /* 10^2 */
+ [0x35] = const_floatx80(0x400c, 0x9c40000000000000ULL), /* 10^4 */
+ [0x36] = const_floatx80(0x4019, 0xbebc200000000000ULL), /* 10^8 */
+ [0x37] = const_floatx80(0x4034, 0x8e1bc9bf04000000ULL), /* 10^16 */
+ [0x38] = const_floatx80(0x4069, 0x9dc5ada82b70b59eULL), /* 10^32 */
+ [0x39] = const_floatx80(0x40d3, 0xc2781f49ffcfa6d5ULL), /* 10^64 */
+ [0x3a] = const_floatx80(0x41a8, 0x93ba47c980e98ce0ULL), /* 10^128 */
+ [0x3b] = const_floatx80(0x4351, 0xaa7eebfb9df9de8eULL), /* 10^256 */
+ [0x3c] = const_floatx80(0x46a3, 0xe319a0aea60e91c7ULL), /* 10^512 */
+ [0x3d] = const_floatx80(0x4d48, 0xc976758681750c17ULL), /* 10^1024 */
+ [0x3e] = const_floatx80(0x5a92, 0x9e8b3b5dc53d5de5ULL), /* 10^2048 */
+ [0x3f] = const_floatx80(0x7525, 0xc46052028a20979bULL), /* 10^4096 */
};
int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val)
--
2.13.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
2017-09-18 10:46 [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128] Laurent Vivier
@ 2017-09-18 12:47 ` Philippe Mathieu-Daudé
2017-09-19 16:30 ` Richard Henderson
1 sibling, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-18 12:47 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Peter Maydell, Aurelien Jarno
On 09/18/2017 07:46 AM, Laurent Vivier wrote:
> We already have const_float16(), const_float32() and const_float64(),
> so rename make_floatx80_init() and make_float128_init() as
> const_floatx80() and const_float128().
>
> Redefine make_floatx80() and make_float128() as make_float16(),
> make_float32() and make_float64() using a variable and not only
> a cast.
>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
> include/fpu/softfloat.h | 10 ++++++----
> target/m68k/fpu_helper.c | 44 ++++++++++++++++++++++----------------------
> 2 files changed, 28 insertions(+), 26 deletions(-)
>
> diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
> index 0f96a0edd1..2e1a79ebf7 100644
> --- a/include/fpu/softfloat.h
> +++ b/include/fpu/softfloat.h
> @@ -146,8 +146,9 @@ typedef struct {
> uint64_t low;
> uint16_t high;
> } floatx80;
> -#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
> -#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
> +#define make_floatx80(exp, mant) __extension__ \
> + ({ floatx80 f80_val = { .low = mant, .high = exp }; f80_val; })
> +#define const_floatx80(exp, mant) { .low = mant, .high = exp }
cleaner.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> typedef struct {
> #ifdef HOST_WORDS_BIGENDIAN
> uint64_t high, low;
> @@ -155,8 +156,9 @@ typedef struct {
> uint64_t low, high;
> #endif
> } float128;
> -#define make_float128(high_, low_) ((float128) { .high = high_, .low = low_ })
> -#define make_float128_init(high_, low_) { .high = high_, .low = low_ }
> +#define make_float128(high_, low_) __extension__ \
> + ({float128 f128_val = { .high = high_, .low = low_ }; f128_val; })
> +#define const_float128(high_, low_) { .high = high_, .low = low_ }
>
> /*----------------------------------------------------------------------------
> | Software IEC/IEEE floating-point underflow tininess-detection mode.
> diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
> index 665e7609af..bf62cf8003 100644
> --- a/target/m68k/fpu_helper.c
> +++ b/target/m68k/fpu_helper.c
> @@ -29,28 +29,28 @@
> */
>
> static const floatx80 fpu_rom[128] = {
> - [0x00] = make_floatx80_init(0x4000, 0xc90fdaa22168c235ULL), /* Pi */
> - [0x0b] = make_floatx80_init(0x3ffd, 0x9a209a84fbcff798ULL), /* Log10(2) */
> - [0x0c] = make_floatx80_init(0x4000, 0xadf85458a2bb4a9aULL), /* e */
> - [0x0d] = make_floatx80_init(0x3fff, 0xb8aa3b295c17f0bcULL), /* Log2(e) */
> - [0x0e] = make_floatx80_init(0x3ffd, 0xde5bd8a937287195ULL), /* Log10(e) */
> - [0x0f] = make_floatx80_init(0x0000, 0x0000000000000000ULL), /* Zero */
> - [0x30] = make_floatx80_init(0x3ffe, 0xb17217f7d1cf79acULL), /* ln(2) */
> - [0x31] = make_floatx80_init(0x4000, 0x935d8dddaaa8ac17ULL), /* ln(10) */
> - [0x32] = make_floatx80_init(0x3fff, 0x8000000000000000ULL), /* 10^0 */
> - [0x33] = make_floatx80_init(0x4002, 0xa000000000000000ULL), /* 10^1 */
> - [0x34] = make_floatx80_init(0x4005, 0xc800000000000000ULL), /* 10^2 */
> - [0x35] = make_floatx80_init(0x400c, 0x9c40000000000000ULL), /* 10^4 */
> - [0x36] = make_floatx80_init(0x4019, 0xbebc200000000000ULL), /* 10^8 */
> - [0x37] = make_floatx80_init(0x4034, 0x8e1bc9bf04000000ULL), /* 10^16 */
> - [0x38] = make_floatx80_init(0x4069, 0x9dc5ada82b70b59eULL), /* 10^32 */
> - [0x39] = make_floatx80_init(0x40d3, 0xc2781f49ffcfa6d5ULL), /* 10^64 */
> - [0x3a] = make_floatx80_init(0x41a8, 0x93ba47c980e98ce0ULL), /* 10^128 */
> - [0x3b] = make_floatx80_init(0x4351, 0xaa7eebfb9df9de8eULL), /* 10^256 */
> - [0x3c] = make_floatx80_init(0x46a3, 0xe319a0aea60e91c7ULL), /* 10^512 */
> - [0x3d] = make_floatx80_init(0x4d48, 0xc976758681750c17ULL), /* 10^1024 */
> - [0x3e] = make_floatx80_init(0x5a92, 0x9e8b3b5dc53d5de5ULL), /* 10^2048 */
> - [0x3f] = make_floatx80_init(0x7525, 0xc46052028a20979bULL), /* 10^4096 */
> + [0x00] = const_floatx80(0x4000, 0xc90fdaa22168c235ULL), /* Pi */
> + [0x0b] = const_floatx80(0x3ffd, 0x9a209a84fbcff798ULL), /* Log10(2) */
> + [0x0c] = const_floatx80(0x4000, 0xadf85458a2bb4a9aULL), /* e */
> + [0x0d] = const_floatx80(0x3fff, 0xb8aa3b295c17f0bcULL), /* Log2(e) */
> + [0x0e] = const_floatx80(0x3ffd, 0xde5bd8a937287195ULL), /* Log10(e) */
> + [0x0f] = const_floatx80(0x0000, 0x0000000000000000ULL), /* Zero */
> + [0x30] = const_floatx80(0x3ffe, 0xb17217f7d1cf79acULL), /* ln(2) */
> + [0x31] = const_floatx80(0x4000, 0x935d8dddaaa8ac17ULL), /* ln(10) */
> + [0x32] = const_floatx80(0x3fff, 0x8000000000000000ULL), /* 10^0 */
> + [0x33] = const_floatx80(0x4002, 0xa000000000000000ULL), /* 10^1 */
> + [0x34] = const_floatx80(0x4005, 0xc800000000000000ULL), /* 10^2 */
> + [0x35] = const_floatx80(0x400c, 0x9c40000000000000ULL), /* 10^4 */
> + [0x36] = const_floatx80(0x4019, 0xbebc200000000000ULL), /* 10^8 */
> + [0x37] = const_floatx80(0x4034, 0x8e1bc9bf04000000ULL), /* 10^16 */
> + [0x38] = const_floatx80(0x4069, 0x9dc5ada82b70b59eULL), /* 10^32 */
> + [0x39] = const_floatx80(0x40d3, 0xc2781f49ffcfa6d5ULL), /* 10^64 */
> + [0x3a] = const_floatx80(0x41a8, 0x93ba47c980e98ce0ULL), /* 10^128 */
> + [0x3b] = const_floatx80(0x4351, 0xaa7eebfb9df9de8eULL), /* 10^256 */
> + [0x3c] = const_floatx80(0x46a3, 0xe319a0aea60e91c7ULL), /* 10^512 */
> + [0x3d] = const_floatx80(0x4d48, 0xc976758681750c17ULL), /* 10^1024 */
> + [0x3e] = const_floatx80(0x5a92, 0x9e8b3b5dc53d5de5ULL), /* 10^2048 */
> + [0x3f] = const_floatx80(0x7525, 0xc46052028a20979bULL), /* 10^4096 */
> };
>
> int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
2017-09-18 10:46 [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128] Laurent Vivier
2017-09-18 12:47 ` Philippe Mathieu-Daudé
@ 2017-09-19 16:30 ` Richard Henderson
2017-09-19 17:39 ` Eric Blake
1 sibling, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2017-09-19 16:30 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Peter Maydell, Aurelien Jarno
On 09/18/2017 05:46 AM, Laurent Vivier wrote:
> Redefine make_floatx80() and make_float128() as make_float16(),
> make_float32() and make_float64() using a variable and not only
> a cast.
I don't like this part -- (type){ init } is a standard C99 compound literal.
There's no point using a gcc extension instead.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
2017-09-19 16:30 ` Richard Henderson
@ 2017-09-19 17:39 ` Eric Blake
2017-09-19 18:45 ` Laszlo Ersek
2017-09-19 19:06 ` Richard Henderson
0 siblings, 2 replies; 7+ messages in thread
From: Eric Blake @ 2017-09-19 17:39 UTC (permalink / raw)
To: Richard Henderson, Laurent Vivier, qemu-devel
Cc: Peter Maydell, Aurelien Jarno, Laszlo Ersek, Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]
On 09/19/2017 11:30 AM, Richard Henderson wrote:
> On 09/18/2017 05:46 AM, Laurent Vivier wrote:
>> Redefine make_floatx80() and make_float128() as make_float16(),
>> make_float32() and make_float64() using a variable and not only
>> a cast.
>> -#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
>> -#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
>> +#define make_floatx80(exp, mant) __extension__ \
>> + ({ floatx80 f80_val = { .low = mant, .high = exp }; f80_val; })
>> +#define const_floatx80(exp, mant) { .low = mant, .high = exp }
>
> I don't like this part -- (type){ init } is a standard C99 compound literal.
> There's no point using a gcc extension instead.
The C99 compound literal is not a const initializer in all situations,
though :( Here's another thread where we had a similar discussion, but
there, the solution was to just make the macro behave as an initializer
(which is C99 compliant, but loses some type safety) instead of relying
on a gcc extension:
https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg06566.html
I suspect you're running into the same issues that Laszlo already helped
us understand regarding QLit.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
2017-09-19 17:39 ` Eric Blake
@ 2017-09-19 18:45 ` Laszlo Ersek
2017-09-19 19:31 ` Laurent Vivier
2017-09-19 19:06 ` Richard Henderson
1 sibling, 1 reply; 7+ messages in thread
From: Laszlo Ersek @ 2017-09-19 18:45 UTC (permalink / raw)
To: Eric Blake, Richard Henderson, Laurent Vivier, qemu-devel
Cc: Peter Maydell, Aurelien Jarno, Markus Armbruster
On 09/19/17 19:39, Eric Blake wrote:
> On 09/19/2017 11:30 AM, Richard Henderson wrote:
>> On 09/18/2017 05:46 AM, Laurent Vivier wrote:
>>> Redefine make_floatx80() and make_float128() as make_float16(),
>>> make_float32() and make_float64() using a variable and not only
>>> a cast.
>
>>> -#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
>>> -#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
>>> +#define make_floatx80(exp, mant) __extension__ \
>>> + ({ floatx80 f80_val = { .low = mant, .high = exp }; f80_val; })
>>> +#define const_floatx80(exp, mant) { .low = mant, .high = exp }
>
>>
>> I don't like this part -- (type){ init } is a standard C99 compound literal.
>> There's no point using a gcc extension instead.
>
> The C99 compound literal is not a const initializer in all situations,
> though :( Here's another thread where we had a similar discussion, but
> there, the solution was to just make the macro behave as an initializer
> (which is C99 compliant, but loses some type safety) instead of relying
> on a gcc extension:
>
> https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg06566.html
>
> I suspect you're running into the same issues that Laszlo already helped
> us understand regarding QLit.
>
Thanks for the CC! I don't have much context, but the patch looks quite
isolated.
I think I agree with Richard here -- I don't think there's any reason to
change the replacement text of make_floatx80.
The patch names make_float64() as an earlier example (already using
__extension__), but I don't understand why make_float64() was written
that way. ... It seems to go back to ancient commit f090c9d4ad58 ("Add
strict checking mode for softfp code.", 2007-11-18). Was C99 support
(esp. compound literals) spotty in gcc back then?
Not having much background, I'd suggest the opposite change -- replace
the statement-expression in make_float64() with a compound literal.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
2017-09-19 17:39 ` Eric Blake
2017-09-19 18:45 ` Laszlo Ersek
@ 2017-09-19 19:06 ` Richard Henderson
1 sibling, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2017-09-19 19:06 UTC (permalink / raw)
To: Eric Blake, Laurent Vivier, qemu-devel
Cc: Peter Maydell, Aurelien Jarno, Laszlo Ersek, Markus Armbruster
On 09/19/2017 12:39 PM, Eric Blake wrote:
> On 09/19/2017 11:30 AM, Richard Henderson wrote:
>> On 09/18/2017 05:46 AM, Laurent Vivier wrote:
>>> Redefine make_floatx80() and make_float128() as make_float16(),
>>> make_float32() and make_float64() using a variable and not only
>>> a cast.
>
>>> -#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
>>> -#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
>>> +#define make_floatx80(exp, mant) __extension__ \
>>> + ({ floatx80 f80_val = { .low = mant, .high = exp }; f80_val; })
>>> +#define const_floatx80(exp, mant) { .low = mant, .high = exp }
>
>>
>> I don't like this part -- (type){ init } is a standard C99 compound literal.
>> There's no point using a gcc extension instead.
>
> The C99 compound literal is not a const initializer in all situations,
> though :(
A compound literal not officially a const initializer in any situation. That
it is accepted by gcc as a const initializer is an extension.
I don't dispute const_floatx80, but the change to make_floatx80.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128]
2017-09-19 18:45 ` Laszlo Ersek
@ 2017-09-19 19:31 ` Laurent Vivier
0 siblings, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2017-09-19 19:31 UTC (permalink / raw)
To: Laszlo Ersek, Eric Blake, Richard Henderson, qemu-devel
Cc: Peter Maydell, Aurelien Jarno, Markus Armbruster
Le 19/09/2017 à 20:45, Laszlo Ersek a écrit :
> On 09/19/17 19:39, Eric Blake wrote:
>> On 09/19/2017 11:30 AM, Richard Henderson wrote:
>>> On 09/18/2017 05:46 AM, Laurent Vivier wrote:
>>>> Redefine make_floatx80() and make_float128() as make_float16(),
>>>> make_float32() and make_float64() using a variable and not only
>>>> a cast.
>>
>>>> -#define make_floatx80(exp, mant) ((floatx80) { mant, exp })
>>>> -#define make_floatx80_init(exp, mant) { .low = mant, .high = exp }
>>>> +#define make_floatx80(exp, mant) __extension__ \
>>>> + ({ floatx80 f80_val = { .low = mant, .high = exp }; f80_val; })
>>>> +#define const_floatx80(exp, mant) { .low = mant, .high = exp }
>>
>>>
>>> I don't like this part -- (type){ init } is a standard C99 compound literal.
>>> There's no point using a gcc extension instead.
>>
>> The C99 compound literal is not a const initializer in all situations,
>> though :( Here's another thread where we had a similar discussion, but
>> there, the solution was to just make the macro behave as an initializer
>> (which is C99 compliant, but loses some type safety) instead of relying
>> on a gcc extension:
>>
>> https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg06566.html
>>
>> I suspect you're running into the same issues that Laszlo already helped
>> us understand regarding QLit.
>>
>
> Thanks for the CC! I don't have much context, but the patch looks quite
> isolated.
>
> I think I agree with Richard here -- I don't think there's any reason to
> change the replacement text of make_floatx80.
>
> The patch names make_float64() as an earlier example (already using
> __extension__), but I don't understand why make_float64() was written
> that way. ... It seems to go back to ancient commit f090c9d4ad58 ("Add
> strict checking mode for softfp code.", 2007-11-18). Was C99 support
> (esp. compound literals) spotty in gcc back then?
>
> Not having much background, I'd suggest the opposite change -- replace
> the statement-expression in make_float64() with a compound literal.
Okay, I'll do this way.
Thank you all for your comments.
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-09-19 19:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-18 10:46 [Qemu-devel] [PATCH] softfloat: rename make_float[x80|128]_init to const_float[x80|128] Laurent Vivier
2017-09-18 12:47 ` Philippe Mathieu-Daudé
2017-09-19 16:30 ` Richard Henderson
2017-09-19 17:39 ` Eric Blake
2017-09-19 18:45 ` Laszlo Ersek
2017-09-19 19:31 ` Laurent Vivier
2017-09-19 19:06 ` 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 NNTP newsgroup(s).