Skip to contentSkip to conversation

softfloat: Use POSIX integer types - benchmarked

PATCH Applied Andreas Färber 7 participants 40 messages Jan 16, 2012 – Jan 23, 2012

lore
Share & tools
lore
#0 lore raw

cover softfloat: Use POSIX integer types - benchmarked

Hello,

Based on a suggestion from Alex earlier this week, I managed to run a simple benchmark of softfloat performance with qemu-arm, as requested by Peter.

I went for the Whetstone floating point benchmark:
http://en.wikipedia.org/wiki/Whetstone_%28benchmark%29

For a loop count of 100,000 and 5 runs I got the following results:

current: 138.9-204.1 Whetstone-MIPS
[u]int*_t: 185.2-188.7 Whetstone-MIPS
[u]int_fast*_t: 285.7-294.1 Whetstone-MIPS

Toshiba AC100: 833.3-909.1 Whetstone-MIPS

These results seem to indicate that the "fast" POSIX types are indeed somewhat faster, both compared to exact-size POSIX types and to the current state.

As a short summary of previous discussions, softfloat had these typedefs:
[s]bits{8,16,32,64} - exact-size semantics, => [u]int{8,16,32,64}_t [u]int{8,16,32,64} - minimum-width semantics, host-independent
AIX, Mac OS X and BeOS/Haiku have some or all of the latter already, leading to type conflicts.
I had originally suggested the POSIX [u]int_least*_t types but we rather preferred [u]int_fast*_t, worried about performance, to get the fastest least-width types. For either of these the actual width depends on system headers. On the other hand it would be futile to try to performance-optimize integer types for every possible host inside QEMU. If we don't mind performance or dislike host-dependencies, we could just use [u]int*_t, but then with everything [u]int*_t we can't easily change this in case it bites us in the future.

Personally I prefer those 'fast' types, because that way we get to keep the distinction between what was formerly [s]bits* and [u]int* types. The clear name distinction would even allow to do conversions by regex.

However, I noticed that target-mips/cpu.h had typedefs for uint_fast{8,16}_t for Solaris <= 9. So I moved these to osdep.h and added typedefs for the newly needed types.

Coccinelle needed some tweaking for the macros and only did the uint16 conversion fully. For the others I was too impatient, so I hand-converted the remaining occurrences that Coccinelle did not catch.

Since Coccinelle stripped leading whitespace before types replaced anyway, I hand-edited (and git-am'ed) the patches to make lines touched adhere to Coding Style.

Patches 1-3 fix misuses of softfloat types that were introduced since the last series of fixes. These could be cherry-picked.

Patch 4 fixes a misuse of int inside softfloat. This could be cherry-picked.

Patch 5 moves the Solaris typedefs to a central header, resolving an XXX present since their introduction in r1979.

Patches 6-13 convert the softfloat integer types.

Patch 14 converts the 'flag' type to bool, removing the last softfloat type.

Please test that this doesn't break / unbreaks Your Favorite Host:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/softfloat

Regards,
Andreas

Cc Alexander Graf <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Aurélien Jarno <[email protected]>
Cc Ben Taylor <[email protected]>
Cc Rui Carmo <[email protected]>
Cc Eric Sunshine <[email protected]>
Cc Pavel Borzenkov <[email protected]>
Cc Juan Pineda <[email protected]>

Host: HP Envy w/ Intel Core i7-2630QM 2.0 GHz (openSUSE 12.1)
QEMU: 2be276242135eac6e86be2a8259545e620c94107 plus + 2 patches
Configuration: --prefix=/usr/local
Command: arm-linux-user/qemu-arm path/to/whetstone -c 100000

Source: http://www.netlib.org/benchmark/whetstone.c
Compiler: gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
Compilation: gcc -O -s whetstone.c -o whetstone -lm -static

[u]int*_t:
---

fpu/softfloat.h +4 -4
index 07c2929..6fe19d7 100644
@@ -57,11 +57,11 @@ typedef uint8_t flag;
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX
-typedef int uint16;
-typedef int int16;
+typedef uint16_t uint16;
+typedef int16_t int16;
 #endif
-typedef unsigned int uint32;
-typedef signed int int32;
+typedef uint32_t uint32;
+typedef int32_t int32;
 typedef uint64_t uint64;
 typedef int64_t int64;
 

---

[u]int_fast*_t:
---

fpu/softfloat.h +0 -0
index 07c2929..43486aa 100644
@@ -54,16 +54,16 @@ these four paragraphs for those parts of this code

that are retained.
| to the same as `int'. *----------------------------------------------------------------------------*/ typedef uint8_t flag;
-typedef uint8_t uint8;
-typedef int8_t int8;
+typedef uint_fast8_t uint8;
+typedef int_fast8_t int8;
#ifndef _AIX
-typedef int uint16;
-typedef int int16;
+typedef uint_fast16_t uint16;
+typedef int_fast16_t int16;
#endif
-typedef unsigned int uint32;
-typedef signed int int32;
-typedef uint64_t uint64;
-typedef int64_t int64;
+typedef uint_fast32_t uint32;
+typedef int_fast32_t int32;
+typedef uint_fast64_t uint64;
+typedef int_fast64_t int64;

#define LIT64( a ) a##LL
#define INLINE static inline
---

spatch(1) -macro_file_builtins:
---
#define STATUS_PARAM
#define STATUS_VAR

#define INLINE static inline

#define MINMAX
---

Andreas Färber (13):
lm32: Fix mixup of uint32 and uint32_t
target-sparc: Fix mixup of uint64 and uint64_t
qemu-tool: Fix mixup of int64 and int64_t
softfloat: Fix mixups of int and int16
softfloat: Replace uint16 type with uint_fast16_t
softfloat: Replace int16 type with int_fast16_t
softfloat: Remove unused uint8 type
softfloat: Replace int8 type with int_fast8_t
softfloat: Replace uint32 type with uint_fast32_t
softfloat: Replace int32 type with int_fast32_t
softfloat: Replace uint64 type with uint_fast64_t
softfloat: Replace int64 type with int_fast64_t
softfloat: Replace flag type with bool

 fpu/softfloat-macros.h        |   52 ++--
 fpu/softfloat-specialize.h    |   56 ++--
 fpu/softfloat.c               |  626 ++++++++++++++++++++--------------------
 fpu/softfloat.h               |  115 ++++-----
 hw/milkymist-vgafb_template.h |    2 +-
 qemu-tool.c                   |    4 +-
 target-sparc/vis_helper.c     |    2 +-
 7 files changed, 419 insertions(+), 438 deletions(-)
Signature · 1 line
1.7.7
#1 lore raw

PATCH 1/14 lm32: Fix mixup of uint32 and uint32_t

Commit d23948b15a9920fb7f6374b55a6db1ecff81f3ee (lm32: add Milkymist VGAFB support) introduced a stray usage of the softfloat uint32 type.

Use uint32_t instead.

---
 hw/milkymist-vgafb_template.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/milkymist-vgafb_template.h +1 -1
index 69af9ef..544b55e 100644
@@ -39,7 +39,7 @@
 #elif BITS == 24
 #define COPY_PIXEL(to, r, g, b)                    \
     do {                                           \
-        uint32 tmp = rgb_to_pixel24(r, g, b);      \
+        uint32_t tmp = rgb_to_pixel24(r, g, b);      \
         *(to++) =         tmp & 0xff;              \
         *(to++) =  (tmp >> 8) & 0xff;              \
         *(to++) = (tmp >> 16) & 0xff;              \
Signature · 1 line
1.7.7
#2 lore raw

Re: [Qemu-devel] [PATCH 01/14] lm32: Fix mixup of uint32 and uint32_t

hw/milkymist-vgafb_template.h line 45

Quoted 13 lines · Andreas Färber
hw/milkymist-vgafb_template.h +1 -1
index 69af9ef..544b55e 100644
@@ -39,7 +39,7 @@
  #elif BITS == 24
  #define COPY_PIXEL(to, r, g, b)                    \
     do {                                           \
-        uint32 tmp = rgb_to_pixel24(r, g, b);      \
+        uint32_t tmp = rgb_to_pixel24(r, g, b);      \
         *(to++) =         tmp & 0xff;              \
         *(to++) =  (tmp >> 8) & 0xff;              \
         *(to++) = (tmp >> 16) & 0xff;              \

This change breaks the otherwise consistent alignment of the '\' characters in column 51...

-- PMM

#3 lore raw

Re: [Qemu-devel] [PATCH 01/14] lm32: Fix mixup of uint32 and uint32_t

Am 16.01.2012 12:27, schrieb Peter Maydell:

Quoted 9 lines · Andreas Färber
Quoted 8 lines
hw/milkymist-vgafb_template.h +0 -0
index 69af9ef..544b55e 100644
@@ -39,7 +39,7 @@
 #elif BITS == 24
 #define COPY_PIXEL(to, r, g, b)                    \
    do {                                           \
Quoted 8 lines

hw/milkymist-vgafb_template.h line 45

Quoted 5 lines
hw/milkymist-vgafb_template.h +1 -1
-        uint32 tmp = rgb_to_pixel24(r, g, b);      \
+        uint32_t tmp = rgb_to_pixel24(r, g, b);      \
        *(to++) =         tmp & 0xff;              \
        *(to++) =  (tmp >> 8) & 0xff;              \
        *(to++) = (tmp >> 16) & 0xff;              \

This change breaks the otherwise consistent alignment of the '\' characters in column 51...

Thanks, will fix!

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
Acked-by
#4 lore raw

Re: [Qemu-devel] [PATCH 01/14] lm32: Fix mixup of uint32 and uint32_t

In reply to Peter Maydell

Am Montag 16 Januar 2012, 12:27:01 schrieb Peter Maydell:

Quoted 9 lines · Andreas Färber
Quoted 8 lines
(quoted diff) +0 -0

b/hw/milkymist-vgafb_template.h index 69af9ef..544b55e 100644

hw/milkymist-vgafb_template.h +0 -0
@@ -39,7 +39,7 @@
 #elif BITS == 24
 #define COPY_PIXEL(to, r, g, b)                    \
    do {                                           \
Quoted 8 lines

hw/milkymist-vgafb_template.h line 45

Quoted 5 lines
hw/milkymist-vgafb_template.h +1 -1
-        uint32 tmp = rgb_to_pixel24(r, g, b);      \
+        uint32_t tmp = rgb_to_pixel24(r, g, b);      \
        *(to++) =         tmp & 0xff;              \
        *(to++) =  (tmp >> 8) & 0xff;              \
        *(to++) = (tmp >> 16) & 0xff;              \

This change breaks the otherwise consistent alignment of the '\' characters in column 51...

apart from that,

Signature · 1 line
michael
#5 lore raw

PATCH v2 1/1 lm32: Fix mixup of uint32 and uint32_t

In reply to Andreas Färber

Commit d23948b15a9920fb7f6374b55a6db1ecff81f3ee (lm32: add Milkymist VGAFB support) introduced a stray usage of the softfloat uint32 type.

Use uint32_t instead.

---
 hw/milkymist-vgafb_template.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/milkymist-vgafb_template.h +1 -1
index 69af9ef..1d33ee8 100644
@@ -39,7 +39,7 @@
 #elif BITS == 24
 #define COPY_PIXEL(to, r, g, b)                    \
     do {                                           \
-        uint32 tmp = rgb_to_pixel24(r, g, b);      \
+        uint32_t tmp = rgb_to_pixel24(r, g, b);    \
         *(to++) =         tmp & 0xff;              \
         *(to++) =  (tmp >> 8) & 0xff;              \
         *(to++) = (tmp >> 16) & 0xff;              \
Signature · 1 line
1.7.7
#6 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH v2] lm32: Fix mixup of uint32 and uint32_t

Quoted 11 lines · Andreas Färber

Commit d23948b15a9920fb7f6374b55a6db1ecff81f3ee (lm32: add Milkymist VGAFB support) introduced a stray usage of the softfloat uint32 type.

Use uint32_t instead.

---
 hw/milkymist-vgafb_template.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

#7 lore raw

PATCH 2/14 target-sparc: Fix mixup of uint64 and uint64_t

In reply to Andreas Färber

Commit 793a137a41ad4125011c7022cf16a1baa40a5ab6 (target-sparc:
Implement BMASK/BSHUFFLE.) introduced a stray usage of softfloat uint64 type.

Use uint64_t instead.

Cc Richard Henderson <[email protected]>
Cc Blue Swirl <[email protected]>
---
 target-sparc/vis_helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-sparc/vis_helper.c +1 -1
index a992c29..9d2edb0 100644
@@ -459,7 +459,7 @@ uint32_t helper_fpackfix(uint64_t gsr, uint64_t rs2)
     return ret;
 }
 
-uint64 helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
+uint64_t helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
 {
     union {
         uint64_t ll[2];
Signature · 1 line
1.7.7
Reviewed-by on v1 2/14
#8 lore raw

Re: [Qemu-devel] [PATCH 02/14] target-sparc: Fix mixup of uint64 and uint64_t

Quoted 9 lines · Andreas Färber

Commit 793a137a41ad4125011c7022cf16a1baa40a5ab6 (target-sparc:
Implement BMASK/BSHUFFLE.) introduced a stray usage of softfloat uint64 type.

Use uint64_t instead.

Cc Richard Henderson <[email protected]>
Cc Blue Swirl <[email protected]>

Good catch,

Quoted 20 lines

---
 target-sparc/vis_helper.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
target-sparc/vis_helper.c +1 -2
index a992c29..9d2edb0 100644
@@ -459,7 +459,7 @@ uint32_t helper_fpackfix(uint64_t gsr, uint64_t rs2)
     return ret;
  }
 
-uint64 helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
+uint64_t helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
  {
     union {
         uint64_t ll[2];
--

1.7.7

#9 lore raw

Re: [Qemu-devel] [PATCH 02/14] target-sparc: Fix mixup of uint64 and uint64_t

Am 21.01.2012 19:51, schrieb Blue Swirl:

Quoted 5 lines · Andreas Färber
Quoted 4 lines

Commit 793a137a41ad4125011c7022cf16a1baa40a5ab6 (target-sparc:
Implement BMASK/BSHUFFLE.) introduced a stray usage of softfloat uint64 type.

Quoted 8 lines
Quoted 5 lines

Use uint64_t instead.

Cc Richard Henderson <[email protected]>
Cc Blue Swirl <[email protected]>

Good catch,

Feel free to apply this patch if Richard doesn't comment. The rest of the series needs some more review and benchmarking.

Is there maybe a way to poison these types outside fpu/ meanwhile?

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
#10 lore raw

Re: [Qemu-devel] [PATCH 02/14] target-sparc: Fix mixup of uint64 and uint64_t

Quoted 12 lines · Andreas Färber

Am 21.01.2012 19:51, schrieb Blue Swirl:

Quoted 11 lines · Andreas Färber
Quoted 9 lines

Commit 793a137a41ad4125011c7022cf16a1baa40a5ab6 (target-sparc:
Implement BMASK/BSHUFFLE.) introduced a stray usage of softfloat uint64 type.

Use uint64_t instead.

Cc Richard Henderson <[email protected]>
Cc Blue Swirl <[email protected]>
Quoted 7 lines
Quoted 2 lines

Good catch,

Feel free to apply this patch if Richard doesn't comment. The rest of the series needs some more review and benchmarking.

Is there maybe a way to poison these types outside fpu/ meanwhile?

Maybe there could be, but wasn't one part of the problem that OSX uses the same type names?

Applied
#11 lore raw

Re: [Qemu-devel] [PATCH 02/14] target-sparc: Fix mixup of uint64 and uint64_t

In reply to Andreas Färber
Quoted 9 lines · Andreas Färber

Commit 793a137a41ad4125011c7022cf16a1baa40a5ab6 (target-sparc:
Implement BMASK/BSHUFFLE.) introduced a stray usage of softfloat uint64 type.

Use uint64_t instead.

Cc Richard Henderson <[email protected]>
Cc Blue Swirl <[email protected]>

Thanks, applied.

Quoted 20 lines

---
 target-sparc/vis_helper.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
target-sparc/vis_helper.c +1 -2
index a992c29..9d2edb0 100644
@@ -459,7 +459,7 @@ uint32_t helper_fpackfix(uint64_t gsr, uint64_t rs2)
     return ret;
  }
 
-uint64 helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
+uint64_t helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)
  {
     union {
         uint64_t ll[2];
--

1.7.7

#12 lore raw

PATCH 3/14 qemu-tool: Fix mixup of int64 and int64_t

In reply to Andreas Färber

Commit cbcfa0418f0c196afa765f5c9837b9344d1adcf3 (link the main loop and its dependencies into the tools) introduced stray usages of int64.

Use int64_t instead.

---
 qemu-tool.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
qemu-tool.c +2 -2
index c73bf71..6b69668 100644
@@ -59,12 +59,12 @@ void monitor_protocol_event(MonitorEvent event, QObject *data)
 {
 }
 
-int64 cpu_get_clock(void)
+int64_t cpu_get_clock(void)
 {
     abort();
 }
 
-int64 cpu_get_icount(void)
+int64_t cpu_get_icount(void)
 {
     abort();
 }
Signature · 1 line
1.7.7
Reviewed-by on v1 3/14
#13 lore raw

Re: [Qemu-devel] [PATCH 03/14] qemu-tool: Fix mixup of int64 and int64_t

Quoted 10 lines · Andreas Färber

Commit cbcfa0418f0c196afa765f5c9837b9344d1adcf3 (link the main loop and its dependencies into the tools) introduced stray usages of int64.

Use int64_t instead.

---
 qemu-tool.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
#14 lore raw

PATCH 4/14 softfloat: Fix mixups of int and int16

In reply to Andreas Färber

normalizeFloat{32,64}Subnormal() expect the exponent as int16, not int. This went unnoticed since int16 and uint16 were both typedef'ed to int.

---
 fpu/softfloat.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fpu/softfloat.c +2 -2
index 81a7d1a..6dbcb1b 100644
@@ -2131,7 +2131,7 @@ float32 float32_rem( float32 a, float32 b STATUS_PARAM )
 float32 float32_muladd(float32 a, float32 b, float32 c, int flags STATUS_PARAM)
 {
     flag aSign, bSign, cSign, zSign;
-    int aExp, bExp, cExp, pExp, zExp, expDiff;
+    int16 aExp, bExp, cExp, pExp, zExp, expDiff;
     uint32_t aSig, bSig, cSig;
     flag pInf, pZero, pSign;
     uint64_t pSig64, cSig64, zSig64;
@@ -3685,7 +3685,7 @@ float64 float64_rem( float64 a, float64 b STATUS_PARAM )
 float64 float64_muladd(float64 a, float64 b, float64 c, int flags STATUS_PARAM)
 {
     flag aSign, bSign, cSign, zSign;
-    int aExp, bExp, cExp, pExp, zExp, expDiff;
+    int16 aExp, bExp, cExp, pExp, zExp, expDiff;
     uint64_t aSig, bSig, cSig;
     flag pInf, pZero, pSign;
     uint64_t pSig0, pSig1, cSig0, cSig1, zSig0, zSig1;
Signature · 1 line
1.7.7
Reviewed-by on v1 4/14
#15 lore raw

Re: [Qemu-devel] [PATCH 04/14] softfloat: Fix mixups of int and int16

Quoted 2 lines · Andreas Färber

normalizeFloat{32,64}Subnormal() expect the exponent as int16, not int. This went unnoticed since int16 and uint16 were both typedef'ed to int.

I think at the time I wrote that I was being slightly conservative because I didn't feel like confirming that we wouldn't overflow a 16 bit type.

Anyway, I have tested this patch:
* in combination with your others
* with typedefs set up so all int16 &co are the minimum width they could be
* with typedefs so int16 &co are all 64 bits wide

and this all still gives the right results for ARM vfm, so

-- PMM

#16 lore raw

PATCH 5/14 target-mips: Move definition of uint_fast{8, 16}_t to osdep.h

In reply to Andreas Färber

osdep.h is included via qemu-common.h.

Prepares for use of [u]int_fast*_t types in softfloat code.

Cc Ben Taylor <[email protected]>
Cc Aurélien Jarno <[email protected]>
---
 osdep.h           |    6 ++++++
 target-mips/cpu.h |    7 -------
 2 files changed, 6 insertions(+), 7 deletions(-)
osdep.h +6 -0
index 432b91e..8f45a96 100644
@@ -10,6 +10,12 @@
 
 #include <sys/time.h>
 
+#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
+/* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
+typedef unsigned char           uint_fast8_t;
+typedef unsigned int            uint_fast16_t;
+#endif
+
 #ifndef glue
 #define xglue(x, y) x ## y
 #define glue(x, y) xglue(x, y)
target-mips/cpu.h +0 -7
index 71cb4e8..23564a7 100644
@@ -15,13 +15,6 @@
 #include "cpu-defs.h"
 #include "softfloat.h"
 
-// uint_fast8_t and uint_fast16_t not in <sys/int_types.h>
-// XXX: move that elsewhere
-#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
-typedef unsigned char           uint_fast8_t;
-typedef unsigned int            uint_fast16_t;
-#endif
-
 struct CPUMIPSState;
 
 typedef struct r4k_tlb_t r4k_tlb_t;
Signature · 1 line
1.7.7
#17 lore raw

Re: [Qemu-devel] [PATCH 05/14] target-mips: Move definition of uint_fast{8, 16}_t to osdep.h

osdep.h line 17

Quoted 5 lines · Andreas Färber
osdep.h +5 -0
+#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
+/* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
+typedef unsigned char           uint_fast8_t;
+typedef unsigned int            uint_fast16_t;
+#endif

If you make the comment say
/* uint_fast*_t and int_fast*_t not in <sys/int_types.h> */

then it won't become out of date when your later patches add the other types to this section.

-- PMM

#18 lore raw

Re: [Qemu-devel] [PATCH 05/14] target-mips: Move definition of uint_fast{8, 16}_t to osdep.h

Am 16.01.2012 12:38, schrieb Peter Maydell:

Quoted 10 lines · Andreas Färber

osdep.h line 17

Quoted 5 lines
osdep.h +5 -0
+#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
+/* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
+typedef unsigned char           uint_fast8_t;
+typedef unsigned int            uint_fast16_t;
+#endif

If you make the comment say
/* uint_fast*_t and int_fast*_t not in <sys/int_types.h> */

Quoted 2 lines

then it won't become out of date when your later patches add the other types to this section.

I have no clue if that is the case, I just moved it and fixed the comment style. But sure, I can change the comment itself as well.

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
#19 lore raw

Re: [Qemu-devel] [PATCH 05/14] target-mips: Move definition of uint_fast{8, 16}_t to osdep.h

Quoted 11 lines · Andreas Färber

Am 16.01.2012 12:38, schrieb Peter Maydell:

Quoted 10 lines · Andreas Färber

osdep.h line 17

Quoted 5 lines
osdep.h +5 -0
+#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
+/* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
+typedef unsigned char           uint_fast8_t;
+typedef unsigned int            uint_fast16_t;
+#endif

If you make the comment say
/* uint_fast*_t and int_fast*_t not in <sys/int_types.h> */

Quoted 5 lines
Quoted 2 lines

then it won't become out of date when your later patches add the other types to this section.

I have no clue if that is the case, I just moved it and fixed the comment style. But sure, I can change the comment itself as well.

Well, your later patches add more typedefs here, right? So we need to know: either old Solaris doesn't have any of these types and we must typedef them all (and the comment should match that), or it is only missing the two currently noted here, in which case we don't need to and should not add further typedefs. What we don't want is to have a comment and code which disagree...

-- PMM

#20 lore raw

Re: [Qemu-devel] [PATCH 05/14] target-mips: Move definition of uint_fast{8, 16}_t to osdep.h

Am 16.01.2012 13:21, schrieb Peter Maydell:

Quoted 18 lines · Andreas Färber
Quoted 11 lines

Am 16.01.2012 12:38, schrieb Peter Maydell:

Quoted 10 lines · Andreas Färber

osdep.h line 17

Quoted 5 lines
osdep.h +5 -0
+#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10
+/* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
+typedef unsigned char           uint_fast8_t;
+typedef unsigned int            uint_fast16_t;
+#endif

If you make the comment say
/* uint_fast*_t and int_fast*_t not in <sys/int_types.h> */

Quoted 5 lines
Quoted 2 lines

then it won't become out of date when your later patches add the other types to this section.

I have no clue if that is the case, I just moved it and fixed the comment style. But sure, I can change the comment itself as well.

Quoted 6 lines

Well, your later patches add more typedefs here, right? So we need to know: either old Solaris doesn't have any of these types and we must typedef them all (and the comment should match that), or it is only missing the two currently noted here, in which case we don't need to and should not add further typedefs. What we don't want is to have a comment and code which disagree...

I'm hoping Ben can clarify. Fabrice attributed the Solaris/sparc support to him.

/-F

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
#21 lore raw

PATCH 6/14 softfloat: Replace uint16 type with uint_fast16_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef uint16, uint_fast16_t;
@@
-uint16
+uint_fast16_t

Fixes the build of the Cocoa frontend on Mac OS X and avoids a workaround for AIX.

For pre-10 Solaris include osdep.h.

---
 fpu/softfloat.c |    8 ++++----
 fpu/softfloat.h |    6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
fpu/softfloat.c +4 -4
index 6dbcb1b..18b184b 100644
@@ -6443,10 +6443,10 @@ uint32 float32_to_uint32_round_to_zero( float32 a STATUS_PARAM )
     return res;
 }
 
-uint16 float32_to_uint16_round_to_zero( float32 a STATUS_PARAM )
+uint_fast16_t float32_to_uint16_round_to_zero(float32 a STATUS_PARAM)
 {
     int64_t v;
-    uint16 res;
+    uint_fast16_t res;
 
     v = float32_to_int64_round_to_zero(a STATUS_VAR);
     if (v < 0) {
@@ -6497,10 +6497,10 @@ uint32 float64_to_uint32_round_to_zero( float64 a STATUS_PARAM )
     return res;
 }
 
-uint16 float64_to_uint16_round_to_zero( float64 a STATUS_PARAM )
+uint_fast16_t float64_to_uint16_round_to_zero(float64 a STATUS_PARAM)
 {
     int64_t v;
-    uint16 res;
+    uint_fast16_t res;
 
     v = float64_to_int64_round_to_zero(a STATUS_VAR);
     if (v < 0) {
fpu/softfloat.h +3 -3
index 07c2929..4eab04c 100644
@@ -44,6 +44,7 @@ these four paragraphs for those parts of this code that are retained.
 
 #include <inttypes.h>
 #include "config-host.h"
+#include "osdep.h"
 
 /*----------------------------------------------------------------------------
 | Each of the following `typedef's defines the most convenient type that holds
@@ -57,7 +58,6 @@ typedef uint8_t flag;
 typedef uint8_t uint8;
 typedef int8_t int8;
 #ifndef _AIX
-typedef int uint16;
 typedef int int16;
 #endif
 typedef unsigned int uint32;
@@ -261,7 +261,7 @@ extern const float16 float16_default_nan;
 | Software IEC/IEEE single-precision conversion routines.
 *----------------------------------------------------------------------------*/
 int16 float32_to_int16_round_to_zero( float32 STATUS_PARAM );
-uint16 float32_to_uint16_round_to_zero( float32 STATUS_PARAM );
+uint_fast16_t float32_to_uint16_round_to_zero(float32 STATUS_PARAM);
 int32 float32_to_int32( float32 STATUS_PARAM );
 int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM );
 uint32 float32_to_uint32( float32 STATUS_PARAM );
@@ -365,7 +365,7 @@ extern const float32 float32_default_nan;
 | Software IEC/IEEE double-precision conversion routines.
 *----------------------------------------------------------------------------*/
 int16 float64_to_int16_round_to_zero( float64 STATUS_PARAM );
-uint16 float64_to_uint16_round_to_zero( float64 STATUS_PARAM );
+uint_fast16_t float64_to_uint16_round_to_zero(float64 STATUS_PARAM);
 int32 float64_to_int32( float64 STATUS_PARAM );
 int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM );
 uint32 float64_to_uint32( float64 STATUS_PARAM );
Signature · 1 line
1.7.7
#22 lore raw

Re: [Qemu-devel] [PATCH 06/14] softfloat: Replace uint16 type with uint_fast16_t

2012/1/16 Andreas Färber <[email protected]>:

Quoted 1 line

-typedef int uint16;

...I see we've been using a signed type for uint16 all this time. I'm surprised that hasn't caused any problems :-)

-- PMM

#23 lore raw

PATCH 7/14 softfloat: Replace int16 type with int_fast16_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef int16, int_fast16_t;
@@
-int16
+int_fast16_t

Avoids a workaround for AIX.

Add typedef for pre-10 Solaris.

---
 fpu/softfloat-macros.h |   18 ++++----
 fpu/softfloat.c        |  114 ++++++++++++++++++++++++------------------------
 fpu/softfloat.h        |    7 +--
 osdep.h                |    1 +
 4 files changed, 69 insertions(+), 71 deletions(-)
fpu/softfloat-macros.h +9 -9
index e82ce23..b5164af 100644
@@ -55,7 +55,7 @@ these four paragraphs for those parts of this code that are retained.
 | The result is stored in the location pointed to by `zPtr'.
 *----------------------------------------------------------------------------*/
 
-INLINE void shift32RightJamming( uint32_t a, int16 count, uint32_t *zPtr )
+INLINE void shift32RightJamming(uint32_t a, int_fast16_t count, uint32_t *zPtr)
 {
     uint32_t z;
 
@@ -81,7 +81,7 @@ INLINE void shift32RightJamming( uint32_t a, int16 count, uint32_t *zPtr )
 | The result is stored in the location pointed to by `zPtr'.
 *----------------------------------------------------------------------------*/
 
-INLINE void shift64RightJamming( uint64_t a, int16 count, uint64_t *zPtr )
+INLINE void shift64RightJamming(uint64_t a, int_fast16_t count, uint64_t *zPtr)
 {
     uint64_t z;
 
@@ -117,7 +117,7 @@ INLINE void shift64RightJamming( uint64_t a, int16 count, uint64_t *zPtr )
 
 INLINE void
  shift64ExtraRightJamming(
-     uint64_t a0, uint64_t a1, int16 count, uint64_t *z0Ptr, uint64_t *z1Ptr )
+     uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
     uint64_t z0, z1;
     int8 negCount = ( - count ) & 63;
@@ -154,7 +154,7 @@ INLINE void
 
 INLINE void
  shift128Right(
-     uint64_t a0, uint64_t a1, int16 count, uint64_t *z0Ptr, uint64_t *z1Ptr )
+     uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
     uint64_t z0, z1;
     int8 negCount = ( - count ) & 63;
@@ -189,7 +189,7 @@ INLINE void
 
 INLINE void
  shift128RightJamming(
-     uint64_t a0, uint64_t a1, int16 count, uint64_t *z0Ptr, uint64_t *z1Ptr )
+     uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
     uint64_t z0, z1;
     int8 negCount = ( - count ) & 63;
@@ -243,7 +243,7 @@ INLINE void
      uint64_t a0,
      uint64_t a1,
      uint64_t a2,
-     int16 count,
+     int_fast16_t count,
      uint64_t *z0Ptr,
      uint64_t *z1Ptr,
      uint64_t *z2Ptr
@@ -298,7 +298,7 @@ INLINE void
 
 INLINE void
  shortShift128Left(
-     uint64_t a0, uint64_t a1, int16 count, uint64_t *z0Ptr, uint64_t *z1Ptr )
+     uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
 
     *z1Ptr = a1<<count;
@@ -320,7 +320,7 @@ INLINE void
      uint64_t a0,
      uint64_t a1,
      uint64_t a2,
-     int16 count,
+     int_fast16_t count,
      uint64_t *z0Ptr,
      uint64_t *z1Ptr,
      uint64_t *z2Ptr
@@ -591,7 +591,7 @@ static uint64_t estimateDiv128To64( uint64_t a0, uint64_t a1, uint64_t b )
 | value.
 *----------------------------------------------------------------------------*/
 
-static uint32_t estimateSqrt32( int16 aExp, uint32_t a )
+static uint32_t estimateSqrt32(int_fast16_t aExp, uint32_t a)
 {
     static const uint16_t sqrtOddAdjustments[] = {
         0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0,
fpu/softfloat.c +57 -57

425 lines not on this page · raw message

fpu/softfloat.h +2 -5
index 4eab04c..dbdd390 100644
@@ -57,9 +57,6 @@ these four paragraphs for those parts of this code that are retained.
 typedef uint8_t flag;
 typedef uint8_t uint8;
 typedef int8_t int8;
-#ifndef _AIX
-typedef int int16;
-#endif
 typedef unsigned int uint32;
 typedef signed int int32;
 typedef uint64_t uint64;
@@ -260,7 +257,7 @@ extern const float16 float16_default_nan;
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE single-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int16 float32_to_int16_round_to_zero( float32 STATUS_PARAM );
+int_fast16_t float32_to_int16_round_to_zero(float32 STATUS_PARAM);
 uint_fast16_t float32_to_uint16_round_to_zero(float32 STATUS_PARAM);
 int32 float32_to_int32( float32 STATUS_PARAM );
 int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM );
@@ -364,7 +361,7 @@ extern const float32 float32_default_nan;
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE double-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int16 float64_to_int16_round_to_zero( float64 STATUS_PARAM );
+int_fast16_t float64_to_int16_round_to_zero(float64 STATUS_PARAM);
 uint_fast16_t float64_to_uint16_round_to_zero(float64 STATUS_PARAM);
 int32 float64_to_int32( float64 STATUS_PARAM );
 int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM );
osdep.h +1 -0
index 8f45a96..0e560aa 100644
@@ -14,6 +14,7 @@
 /* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
 typedef unsigned char           uint_fast8_t;
 typedef unsigned int            uint_fast16_t;
+typedef signed int              int_fast16_t;
 #endif
 
 #ifndef glue
Signature · 1 line
1.7.7
#24 lore raw

PATCH 8/14 softfloat: Remove unused uint8 type

In reply to Andreas Färber
---
 fpu/softfloat.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
fpu/softfloat.h +0 -1
index dbdd390..99ff44e 100644
@@ -55,7 +55,6 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef uint8_t uint8;
 typedef int8_t int8;
 typedef unsigned int uint32;
 typedef signed int int32;
Signature · 1 line
1.7.7
#25 lore raw

PATCH 9/14 softfloat: Replace int8 type with int_fast8_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef int8, int_fast8_t;
@@
-int8
+int_fast8_t

Add typedef for pre-10 Solaris.

---
 fpu/softfloat-macros.h     |   26 +++++++++---------
 fpu/softfloat-specialize.h |    2 +-
 fpu/softfloat.c            |   62 ++++++++++++++++++++++----------------------
 fpu/softfloat.h            |    3 +-
 osdep.h                    |    1 +
 5 files changed, 47 insertions(+), 47 deletions(-)
fpu/softfloat-macros.h +13 -13
index b5164af..b82871a 100644
@@ -120,7 +120,7 @@ INLINE void
      uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
     uint64_t z0, z1;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = (-count) & 63;
 
     if ( count == 0 ) {
         z1 = a1;
@@ -157,7 +157,7 @@ INLINE void
      uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
     uint64_t z0, z1;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = (-count) & 63;
 
     if ( count == 0 ) {
         z1 = a1;
@@ -192,7 +192,7 @@ INLINE void
      uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr)
 {
     uint64_t z0, z1;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = (-count) & 63;
 
     if ( count == 0 ) {
         z1 = a1;
@@ -250,7 +250,7 @@ INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = (-count) & 63;
 
     if ( count == 0 ) {
         z2 = a2;
@@ -327,7 +327,7 @@ INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 negCount;
+    int_fast8_t negCount;
 
     z2 = a2<<count;
     z1 = a1<<count;
@@ -384,7 +384,7 @@ INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 carry0, carry1;
+    int_fast8_t carry0, carry1;
 
     z2 = a2 + b2;
     carry1 = ( z2 < a2 );
@@ -440,7 +440,7 @@ INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 borrow0, borrow1;
+    int_fast8_t borrow0, borrow1;
 
     z2 = a2 - b2;
     borrow1 = ( a2 < b2 );
@@ -601,7 +601,7 @@ static uint32_t estimateSqrt32(int_fast16_t aExp, uint32_t a)
         0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E,
         0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002
     };
-    int8 index;
+    int_fast8_t index;
     uint32_t z;
 
     index = ( a>>27 ) & 15;
@@ -625,7 +625,7 @@ static uint32_t estimateSqrt32(int_fast16_t aExp, uint32_t a)
 | `a'.  If `a' is zero, 32 is returned.
 *----------------------------------------------------------------------------*/
 
-static int8 countLeadingZeros32( uint32_t a )
+static int_fast8_t countLeadingZeros32(uint32_t a)
 {
 #if SOFTFLOAT_GNUC_PREREQ(3, 4)
     if (a) {
@@ -634,7 +634,7 @@ static int8 countLeadingZeros32( uint32_t a )
         return 32;
     }
 #else
-    static const int8 countLeadingZerosHigh[] = {
+    static const int_fast8_t countLeadingZerosHigh[] = {
         8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
         3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
         2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -652,7 +652,7 @@ static int8 countLeadingZeros32( uint32_t a )
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     };
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = 0;
     if ( a < 0x10000 ) {
@@ -673,7 +673,7 @@ static int8 countLeadingZeros32( uint32_t a )
 | `a'.  If `a' is zero, 64 is returned.
 *----------------------------------------------------------------------------*/
 
-static int8 countLeadingZeros64( uint64_t a )
+static int_fast8_t countLeadingZeros64(uint64_t a)
 {
 #if SOFTFLOAT_GNUC_PREREQ(3, 4)
     if (a) {
@@ -682,7 +682,7 @@ static int8 countLeadingZeros64( uint64_t a )
         return 64;
     }
 #else
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = 0;
     if ( a < ( (uint64_t) 1 )<<32 ) {
fpu/softfloat-specialize.h +1 -1
index c5e2dab..d57af1a 100644
@@ -114,7 +114,7 @@ const float128 float128_default_nan = make_float128(float128_default_nan_high,
 | should be simply `float_exception_flags |= flags;'.
 *----------------------------------------------------------------------------*/
 
-void float_raise( int8 flags STATUS_PARAM )
+void float_raise(int_fast8_t flags STATUS_PARAM)
 {
     STATUS(float_exception_flags) |= flags;
 }
fpu/softfloat.c +31 -31

230 lines not on this page · raw message

fpu/softfloat.h +1 -2
index 99ff44e..ea18a66 100644
@@ -55,7 +55,6 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef int8_t int8;
 typedef unsigned int uint32;
 typedef signed int int32;
 typedef uint64_t uint64;
@@ -205,7 +204,7 @@ void set_floatx80_rounding_precision(int val STATUS_PARAM);
 | Routine to raise any or all of the software IEC/IEEE floating-point
 | exception flags.
 *----------------------------------------------------------------------------*/
-void float_raise( int8 flags STATUS_PARAM);
+void float_raise(int_fast8_t flags STATUS_PARAM);
 
 /*----------------------------------------------------------------------------
 | Options to indicate which negations to perform in float*_muladd()
osdep.h +1 -0
index 0e560aa..b87b450 100644
@@ -14,6 +14,7 @@
 /* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
 typedef unsigned char           uint_fast8_t;
 typedef unsigned int            uint_fast16_t;
+typedef signed char             int_fast8_t;
 typedef signed int              int_fast16_t;
 #endif
 
Signature · 1 line
1.7.7
#26 lore raw

Re: [Qemu-devel] [PATCH 09/14] softfloat: Replace int8 type with int_fast8_t

Quoted 16 lines · Andreas Färber
fpu/softfloat-macros.h +1 -1
-static int8 countLeadingZeros32( uint32_t a )
+static int_fast8_t countLeadingZeros32(uint32_t a)

 {
 #if SOFTFLOAT_GNUC_PREREQ(3, 4)
    if (a) {

fpu/softfloat-macros.h +1 -1
@@ -634,7 +634,7 @@ static int8 countLeadingZeros32( uint32_t a )
         return 32;
     }
  #else
-    static const int8 countLeadingZerosHigh[] = {
+    static const int_fast8_t countLeadingZerosHigh[] = {
         8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
         3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
         2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -652,7 +652,7 @@ static int8 countLeadingZeros32( uint32_t a )
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Quoted 2 lines

        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

It seems unlikely that anybody will actually try to compile qemu with gcc 3 any more, but this table should probably be an int8_t[], not int_fast8_t[]. (Both will work, but the fast types make sense for register values rather than in-memory lookup tables IMHO.)

-- PMM

#27 lore raw

PATCH 10/14 softfloat: Replace uint32 type with uint_fast32_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef uint32, uint_fast32_t;
@@
-uint32
+uint_fast32_t

Add typedef for pre-10 Solaris.

---
 fpu/softfloat.c |   26 +++++++++++++-------------
 fpu/softfloat.h |   13 ++++++-------
 osdep.h         |    1 +
 3 files changed, 20 insertions(+), 20 deletions(-)
fpu/softfloat.c +13 -13
index b5fa3ef..b71e47a 100644
@@ -1141,7 +1141,7 @@ float32 int32_to_float32( int32 a STATUS_PARAM )
 float64 int32_to_float64( int32 a STATUS_PARAM )
 {
     flag zSign;
-    uint32 absA;
+    uint_fast32_t absA;
     int_fast8_t shiftCount;
     uint64_t zSig;
 
@@ -1164,7 +1164,7 @@ float64 int32_to_float64( int32 a STATUS_PARAM )
 floatx80 int32_to_floatx80( int32 a STATUS_PARAM )
 {
     flag zSign;
-    uint32 absA;
+    uint_fast32_t absA;
     int_fast8_t shiftCount;
     uint64_t zSig;
 
@@ -1186,7 +1186,7 @@ floatx80 int32_to_floatx80( int32 a STATUS_PARAM )
 float128 int32_to_float128( int32 a STATUS_PARAM )
 {
     flag zSign;
-    uint32 absA;
+    uint_fast32_t absA;
     int_fast8_t shiftCount;
     uint64_t zSig0;
 
@@ -6397,20 +6397,20 @@ int float128_unordered_quiet( float128 a, float128 b STATUS_PARAM )
 }
 
 /* misc functions */
-float32 uint32_to_float32( uint32 a STATUS_PARAM )
+float32 uint32_to_float32(uint_fast32_t a STATUS_PARAM)
 {
     return int64_to_float32(a STATUS_VAR);
 }
 
-float64 uint32_to_float64( uint32 a STATUS_PARAM )
+float64 uint32_to_float64(uint_fast32_t a STATUS_PARAM)
 {
     return int64_to_float64(a STATUS_VAR);
 }
 
-uint32 float32_to_uint32( float32 a STATUS_PARAM )
+uint_fast32_t float32_to_uint32(float32 a STATUS_PARAM)
 {
     int64_t v;
-    uint32 res;
+    uint_fast32_t res;
 
     v = float32_to_int64(a STATUS_VAR);
     if (v < 0) {
@@ -6425,10 +6425,10 @@ uint32 float32_to_uint32( float32 a STATUS_PARAM )
     return res;
 }
 
-uint32 float32_to_uint32_round_to_zero( float32 a STATUS_PARAM )
+uint_fast32_t float32_to_uint32_round_to_zero(float32 a STATUS_PARAM)
 {
     int64_t v;
-    uint32 res;
+    uint_fast32_t res;
 
     v = float32_to_int64_round_to_zero(a STATUS_VAR);
     if (v < 0) {
@@ -6461,10 +6461,10 @@ uint_fast16_t float32_to_uint16_round_to_zero(float32 a STATUS_PARAM)
     return res;
 }
 
-uint32 float64_to_uint32( float64 a STATUS_PARAM )
+uint_fast32_t float64_to_uint32(float64 a STATUS_PARAM)
 {
     int64_t v;
-    uint32 res;
+    uint_fast32_t res;
 
     v = float64_to_int64(a STATUS_VAR);
     if (v < 0) {
@@ -6479,10 +6479,10 @@ uint32 float64_to_uint32( float64 a STATUS_PARAM )
     return res;
 }
 
-uint32 float64_to_uint32_round_to_zero( float64 a STATUS_PARAM )
+uint_fast32_t float64_to_uint32_round_to_zero(float64 a STATUS_PARAM)
 {
     int64_t v;
-    uint32 res;
+    uint_fast32_t res;
 
     v = float64_to_int64_round_to_zero(a STATUS_VAR);
     if (v < 0) {
fpu/softfloat.h +6 -7
index ea18a66..b29fd24 100644
@@ -55,7 +55,6 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef unsigned int uint32;
 typedef signed int int32;
 typedef uint64_t uint64;
 typedef int64_t int64;
@@ -223,8 +222,8 @@ enum {
 *----------------------------------------------------------------------------*/
 float32 int32_to_float32( int32 STATUS_PARAM );
 float64 int32_to_float64( int32 STATUS_PARAM );
-float32 uint32_to_float32( uint32 STATUS_PARAM );
-float64 uint32_to_float64( uint32 STATUS_PARAM );
+float32 uint32_to_float32(uint_fast32_t STATUS_PARAM);
+float64 uint32_to_float64(uint_fast32_t STATUS_PARAM);
 floatx80 int32_to_floatx80( int32 STATUS_PARAM );
 float128 int32_to_float128( int32 STATUS_PARAM );
 float32 int64_to_float32( int64 STATUS_PARAM );
@@ -259,8 +258,8 @@ int_fast16_t float32_to_int16_round_to_zero(float32 STATUS_PARAM);
 uint_fast16_t float32_to_uint16_round_to_zero(float32 STATUS_PARAM);
 int32 float32_to_int32( float32 STATUS_PARAM );
 int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM );
-uint32 float32_to_uint32( float32 STATUS_PARAM );
-uint32 float32_to_uint32_round_to_zero( float32 STATUS_PARAM );
+uint_fast32_t float32_to_uint32(float32 STATUS_PARAM);
+uint_fast32_t float32_to_uint32_round_to_zero(float32 STATUS_PARAM);
 int64 float32_to_int64( float32 STATUS_PARAM );
 int64 float32_to_int64_round_to_zero( float32 STATUS_PARAM );
 float64 float32_to_float64( float32 STATUS_PARAM );
@@ -363,8 +362,8 @@ int_fast16_t float64_to_int16_round_to_zero(float64 STATUS_PARAM);
 uint_fast16_t float64_to_uint16_round_to_zero(float64 STATUS_PARAM);
 int32 float64_to_int32( float64 STATUS_PARAM );
 int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM );
-uint32 float64_to_uint32( float64 STATUS_PARAM );
-uint32 float64_to_uint32_round_to_zero( float64 STATUS_PARAM );
+uint_fast32_t float64_to_uint32(float64 STATUS_PARAM);
+uint_fast32_t float64_to_uint32_round_to_zero(float64 STATUS_PARAM);
 int64 float64_to_int64( float64 STATUS_PARAM );
 int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM );
 uint64 float64_to_uint64 (float64 a STATUS_PARAM);
osdep.h +1 -0
index b87b450..c7f3a4e 100644
@@ -14,6 +14,7 @@
 /* uint_fast8_t and uint_fast16_t not in <sys/int_types.h> */
 typedef unsigned char           uint_fast8_t;
 typedef unsigned int            uint_fast16_t;
+typedef unsigned int            uint_fast32_t;
 typedef signed char             int_fast8_t;
 typedef signed int              int_fast16_t;
 #endif
Signature · 1 line
1.7.7
#28 lore raw

PATCH 11/14 softfloat: Replace int32 type with int_fast32_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef int32, int_fast32_t;
@@
-int32
+int_fast32_t

Add typedef for pre-10 Solaris.

---
 fpu/softfloat.c |  124 +++++++++++++++++++++++++++---------------------------
 fpu/softfloat.h |   25 +++++------
 osdep.h         |    1 +
 3 files changed, 75 insertions(+), 75 deletions(-)
fpu/softfloat.c +62 -62
index b71e47a..b7cd589 100644
@@ -112,12 +112,12 @@ INLINE flag extractFloat16Sign(float16 a)
 | positive or negative integer is returned.
 *----------------------------------------------------------------------------*/
 
-static int32 roundAndPackInt32( flag zSign, uint64_t absZ STATUS_PARAM)
+static int_fast32_t roundAndPackInt32(flag zSign, uint64_t absZ STATUS_PARAM)
 {
     int_fast8_t roundingMode;
     flag roundNearestEven;
     int_fast8_t roundIncrement, roundBits;
-    int32 z;
+    int_fast32_t z;
 
     roundingMode = STATUS(float_rounding_mode);
     roundNearestEven = ( roundingMode == float_round_nearest_even );
@@ -584,7 +584,7 @@ INLINE uint64_t extractFloatx80Frac( floatx80 a )
 | value `a'.
 *----------------------------------------------------------------------------*/
 
-INLINE int32 extractFloatx80Exp( floatx80 a )
+INLINE int_fast32_t extractFloatx80Exp(floatx80 a)
 {
 
     return a.high & 0x7FFF;
@@ -611,7 +611,7 @@ INLINE flag extractFloatx80Sign( floatx80 a )
 *----------------------------------------------------------------------------*/
 
 static void
- normalizeFloatx80Subnormal( uint64_t aSig, int32 *zExpPtr, uint64_t *zSigPtr )
+ normalizeFloatx80Subnormal(uint64_t aSig, int_fast32_t *zExpPtr, uint64_t *zSigPtr)
 {
     int_fast8_t shiftCount;
 
@@ -626,7 +626,7 @@ static void
 | extended double-precision floating-point value, returning the result.
 *----------------------------------------------------------------------------*/
 
-INLINE floatx80 packFloatx80( flag zSign, int32 zExp, uint64_t zSig )
+INLINE floatx80 packFloatx80(flag zSign, int_fast32_t zExp, uint64_t zSig)
 {
     floatx80 z;
 
@@ -662,7 +662,7 @@ INLINE floatx80 packFloatx80( flag zSign, int32 zExp, uint64_t zSig )
 
 static floatx80
  roundAndPackFloatx80(
-     int_fast8_t roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
+     int_fast8_t roundingPrecision, flag zSign, int_fast32_t zExp, uint64_t zSig0, uint64_t zSig1
  STATUS_PARAM)
 {
     int_fast8_t roundingMode;
@@ -834,7 +834,7 @@ static floatx80
 
 static floatx80
  normalizeRoundAndPackFloatx80(
-     int_fast8_t roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
+     int_fast8_t roundingPrecision, flag zSign, int_fast32_t zExp, uint64_t zSig0, uint64_t zSig1
  STATUS_PARAM)
 {
     int_fast8_t shiftCount;
@@ -881,7 +881,7 @@ INLINE uint64_t extractFloat128Frac0( float128 a )
 | `a'.
 *----------------------------------------------------------------------------*/
 
-INLINE int32 extractFloat128Exp( float128 a )
+INLINE int_fast32_t extractFloat128Exp(float128 a)
 {
 
     return ( a.high>>48 ) & 0x7FFF;
@@ -913,7 +913,7 @@ static void
  normalizeFloat128Subnormal(
      uint64_t aSig0,
      uint64_t aSig1,
-     int32 *zExpPtr,
+     int_fast32_t *zExpPtr,
      uint64_t *zSig0Ptr,
      uint64_t *zSig1Ptr
  )
@@ -954,7 +954,7 @@ static void
 *----------------------------------------------------------------------------*/
 
 INLINE float128
- packFloat128( flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1 )
+ packFloat128(flag zSign, int_fast32_t zExp, uint64_t zSig0, uint64_t zSig1)
 {
     float128 z;
 
@@ -987,7 +987,7 @@ INLINE float128
 
 static float128
  roundAndPackFloat128(
-     flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1, uint64_t zSig2 STATUS_PARAM)
+     flag zSign, int_fast32_t zExp, uint64_t zSig0, uint64_t zSig1, uint64_t zSig2 STATUS_PARAM)
 {
     int_fast8_t roundingMode;
     flag roundNearestEven, increment, isTiny;
@@ -1091,7 +1091,7 @@ static float128
 
 static float128
  normalizeRoundAndPackFloat128(
-     flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1 STATUS_PARAM)
+     flag zSign, int_fast32_t zExp, uint64_t zSig0, uint64_t zSig1 STATUS_PARAM)
 {
     int_fast8_t shiftCount;
     uint64_t zSig2;
@@ -1121,7 +1121,7 @@ static float128
 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
 *----------------------------------------------------------------------------*/
 
-float32 int32_to_float32( int32 a STATUS_PARAM )
+float32 int32_to_float32(int_fast32_t a STATUS_PARAM)
 {
     flag zSign;
 
@@ -1138,7 +1138,7 @@ float32 int32_to_float32( int32 a STATUS_PARAM )
 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
 *----------------------------------------------------------------------------*/
 
-float64 int32_to_float64( int32 a STATUS_PARAM )
+float64 int32_to_float64(int_fast32_t a STATUS_PARAM)
 {
     flag zSign;
     uint_fast32_t absA;
@@ -1161,7 +1161,7 @@ float64 int32_to_float64( int32 a STATUS_PARAM )
 | Arithmetic.
 *----------------------------------------------------------------------------*/
 
-floatx80 int32_to_floatx80( int32 a STATUS_PARAM )
+floatx80 int32_to_floatx80(int_fast32_t a STATUS_PARAM)
 {
     flag zSign;
     uint_fast32_t absA;
@@ -1183,7 +1183,7 @@ floatx80 int32_to_floatx80( int32 a STATUS_PARAM )
 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
 *----------------------------------------------------------------------------*/
 
-float128 int32_to_float128( int32 a STATUS_PARAM )
+float128 int32_to_float128(int_fast32_t a STATUS_PARAM)
 {
     flag zSign;
     uint_fast32_t absA;
@@ -1310,7 +1310,7 @@ float128 int64_to_float128( int64 a STATUS_PARAM )
     flag zSign;
     uint64 absA;
     int_fast8_t shiftCount;
-    int32 zExp;
+    int_fast32_t zExp;
     uint64_t zSig0, zSig1;
 
     if ( a == 0 ) return packFloat128( 0, 0, 0, 0 );
@@ -1342,7 +1342,7 @@ float128 int64_to_float128( int64 a STATUS_PARAM )
 | largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int32 float32_to_int32( float32 a STATUS_PARAM )
+int_fast32_t float32_to_int32(float32 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
@@ -1373,12 +1373,12 @@ int32 float32_to_int32( float32 a STATUS_PARAM )
 | returned.
 *----------------------------------------------------------------------------*/
 
-int32 float32_to_int32_round_to_zero( float32 a STATUS_PARAM )
+int_fast32_t float32_to_int32_round_to_zero(float32 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
     uint32_t aSig;
-    int32 z;
+    int_fast32_t z;
     a = float32_squash_input_denormal(a STATUS_VAR);
 
     aSig = extractFloat32Frac( a );
@@ -1421,7 +1421,7 @@ int_fast16_t float32_to_int16_round_to_zero(float32 a STATUS_PARAM)
     flag aSign;
     int_fast16_t aExp, shiftCount;
     uint32_t aSig;
-    int32 z;
+    int_fast32_t z;
 
     aSig = extractFloat32Frac( a );
     aExp = extractFloat32Exp( a );
@@ -2729,7 +2729,7 @@ int float32_unordered_quiet( float32 a, float32 b STATUS_PARAM )
 | largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int32 float64_to_int32( float64 a STATUS_PARAM )
+int_fast32_t float64_to_int32(float64 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
@@ -2757,12 +2757,12 @@ int32 float64_to_int32( float64 a STATUS_PARAM )
 | returned.
 *----------------------------------------------------------------------------*/
 
-int32 float64_to_int32_round_to_zero( float64 a STATUS_PARAM )
+int_fast32_t float64_to_int32_round_to_zero(float64 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
     uint64_t aSig, savedASig;
-    int32 z;
+    int_fast32_t z;
     a = float64_squash_input_denormal(a STATUS_VAR);
 
     aSig = extractFloat64Frac( a );
@@ -2809,7 +2809,7 @@ int_fast16_t float64_to_int16_round_to_zero(float64 a STATUS_PARAM)
     flag aSign;
     int_fast16_t aExp, shiftCount;
     uint64_t aSig, savedASig;
-    int32 z;
+    int_fast32_t z;
 
     aSig = extractFloat64Frac( a );
     aExp = extractFloat64Exp( a );
@@ -4216,10 +4216,10 @@ int float64_unordered_quiet( float64 a, float64 b STATUS_PARAM )
 | overflows, the largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int32 floatx80_to_int32( floatx80 a STATUS_PARAM )
+int_fast32_t floatx80_to_int32(floatx80 a STATUS_PARAM)
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig;
 
     aSig = extractFloatx80Frac( a );
@@ -4243,12 +4243,12 @@ int32 floatx80_to_int32( floatx80 a STATUS_PARAM )
 | sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int32 floatx80_to_int32_round_to_zero( floatx80 a STATUS_PARAM )
+int_fast32_t floatx80_to_int32_round_to_zero(floatx80 a STATUS_PARAM)
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig, savedASig;
-    int32 z;
+    int_fast32_t z;
 
     aSig = extractFloatx80Frac( a );
     aExp = extractFloatx80Exp( a );
@@ -4291,7 +4291,7 @@ int32 floatx80_to_int32_round_to_zero( floatx80 a STATUS_PARAM )
 int64 floatx80_to_int64( floatx80 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig, aSigExtra;
 
     aSig = extractFloatx80Frac( a );
@@ -4331,7 +4331,7 @@ int64 floatx80_to_int64( floatx80 a STATUS_PARAM )
 int64 floatx80_to_int64_round_to_zero( floatx80 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig;
     int64 z;
 
@@ -4372,7 +4372,7 @@ int64 floatx80_to_int64_round_to_zero( floatx80 a STATUS_PARAM )
 float32 floatx80_to_float32( floatx80 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t aSig;
 
     aSig = extractFloatx80Frac( a );
@@ -4400,7 +4400,7 @@ float32 floatx80_to_float32( floatx80 a STATUS_PARAM )
 float64 floatx80_to_float64( floatx80 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t aSig, zSig;
 
     aSig = extractFloatx80Frac( a );
@@ -4452,7 +4452,7 @@ float128 floatx80_to_float128( floatx80 a STATUS_PARAM )
 floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t lastBitMask, roundBitsMask;
     int_fast8_t roundingMode;
     floatx80 z;
@@ -4525,9 +4525,9 @@ floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM )
 
 static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign STATUS_PARAM)
 {
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig, bSig, zSig0, zSig1;
-    int32 expDiff;
+    int_fast32_t expDiff;
 
     aSig = extractFloatx80Frac( a );
     aExp = extractFloatx80Exp( a );
@@ -4591,9 +4591,9 @@ static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign STATUS_PARAM
 
 static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign STATUS_PARAM )
 {
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig, bSig, zSig0, zSig1;
-    int32 expDiff;
+    int_fast32_t expDiff;
     floatx80 z;
 
     aSig = extractFloatx80Frac( a );
@@ -4700,7 +4700,7 @@ floatx80 floatx80_sub( floatx80 a, floatx80 b STATUS_PARAM )
 floatx80 floatx80_mul( floatx80 a, floatx80 b STATUS_PARAM )
 {
     flag aSign, bSign, zSign;
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig, bSig, zSig0, zSig1;
     floatx80 z;
 
@@ -4759,7 +4759,7 @@ floatx80 floatx80_mul( floatx80 a, floatx80 b STATUS_PARAM )
 floatx80 floatx80_div( floatx80 a, floatx80 b STATUS_PARAM )
 {
     flag aSign, bSign, zSign;
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig, bSig, zSig0, zSig1;
     uint64_t rem0, rem1, rem2, term0, term1, term2;
     floatx80 z;
@@ -4839,7 +4839,7 @@ floatx80 floatx80_div( floatx80 a, floatx80 b STATUS_PARAM )
 floatx80 floatx80_rem( floatx80 a, floatx80 b STATUS_PARAM )
 {
     flag aSign, zSign;
-    int32 aExp, bExp, expDiff;
+    int_fast32_t aExp, bExp, expDiff;
     uint64_t aSig0, aSig1, bSig;
     uint64_t q, term0, term1, alternateASig0, alternateASig1;
     floatx80 z;
@@ -4935,7 +4935,7 @@ floatx80 floatx80_rem( floatx80 a, floatx80 b STATUS_PARAM )
 floatx80 floatx80_sqrt( floatx80 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp, zExp;
+    int_fast32_t aExp, zExp;
     uint64_t aSig0, aSig1, zSig0, zSig1, doubleZSig0;
     uint64_t rem0, rem1, rem2, rem3, term0, term1, term2, term3;
     floatx80 z;
@@ -5243,10 +5243,10 @@ int floatx80_unordered_quiet( floatx80 a, floatx80 b STATUS_PARAM )
 | largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int32 float128_to_int32( float128 a STATUS_PARAM )
+int_fast32_t float128_to_int32(float128 a STATUS_PARAM)
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig0, aSig1;
 
     aSig1 = extractFloat128Frac1( a );
@@ -5272,12 +5272,12 @@ int32 float128_to_int32( float128 a STATUS_PARAM )
 | returned.
 *----------------------------------------------------------------------------*/
 
-int32 float128_to_int32_round_to_zero( float128 a STATUS_PARAM )
+int_fast32_t float128_to_int32_round_to_zero(float128 a STATUS_PARAM)
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig0, aSig1, savedASig;
-    int32 z;
+    int_fast32_t z;
 
     aSig1 = extractFloat128Frac1( a );
     aSig0 = extractFloat128Frac0( a );
@@ -5323,7 +5323,7 @@ int32 float128_to_int32_round_to_zero( float128 a STATUS_PARAM )
 int64 float128_to_int64( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig0, aSig1;
 
     aSig1 = extractFloat128Frac1( a );
@@ -5366,7 +5366,7 @@ int64 float128_to_int64( float128 a STATUS_PARAM )
 int64 float128_to_int64_round_to_zero( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp, shiftCount;
+    int_fast32_t aExp, shiftCount;
     uint64_t aSig0, aSig1;
     int64 z;
 
@@ -5424,7 +5424,7 @@ int64 float128_to_int64_round_to_zero( float128 a STATUS_PARAM )
 float32 float128_to_float32( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t aSig0, aSig1;
     uint32_t zSig;
 
@@ -5459,7 +5459,7 @@ float32 float128_to_float32( float128 a STATUS_PARAM )
 float64 float128_to_float64( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t aSig0, aSig1;
 
     aSig1 = extractFloat128Frac1( a );
@@ -5492,7 +5492,7 @@ float64 float128_to_float64( float128 a STATUS_PARAM )
 floatx80 float128_to_floatx80( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t aSig0, aSig1;
 
     aSig1 = extractFloat128Frac1( a );
@@ -5527,7 +5527,7 @@ floatx80 float128_to_floatx80( float128 a STATUS_PARAM )
 float128 float128_round_to_int( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp;
+    int_fast32_t aExp;
     uint64_t lastBitMask, roundBitsMask;
     int_fast8_t roundingMode;
     float128 z;
@@ -5630,9 +5630,9 @@ float128 float128_round_to_int( float128 a STATUS_PARAM )
 
 static float128 addFloat128Sigs( float128 a, float128 b, flag zSign STATUS_PARAM)
 {
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2;
-    int32 expDiff;
+    int_fast32_t expDiff;
 
     aSig1 = extractFloat128Frac1( a );
     aSig0 = extractFloat128Frac0( a );
@@ -5716,9 +5716,9 @@ static float128 addFloat128Sigs( float128 a, float128 b, flag zSign STATUS_PARAM
 
 static float128 subFloat128Sigs( float128 a, float128 b, flag zSign STATUS_PARAM)
 {
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig0, aSig1, bSig0, bSig1, zSig0, zSig1;
-    int32 expDiff;
+    int_fast32_t expDiff;
     float128 z;
 
     aSig1 = extractFloat128Frac1( a );
@@ -5841,7 +5841,7 @@ float128 float128_sub( float128 a, float128 b STATUS_PARAM )
 float128 float128_mul( float128 a, float128 b STATUS_PARAM )
 {
     flag aSign, bSign, zSign;
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2, zSig3;
     float128 z;
 
@@ -5905,7 +5905,7 @@ float128 float128_mul( float128 a, float128 b STATUS_PARAM )
 float128 float128_div( float128 a, float128 b STATUS_PARAM )
 {
     flag aSign, bSign, zSign;
-    int32 aExp, bExp, zExp;
+    int_fast32_t aExp, bExp, zExp;
     uint64_t aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2;
     uint64_t rem0, rem1, rem2, rem3, term0, term1, term2, term3;
     float128 z;
@@ -5989,7 +5989,7 @@ float128 float128_div( float128 a, float128 b STATUS_PARAM )
 float128 float128_rem( float128 a, float128 b STATUS_PARAM )
 {
     flag aSign, zSign;
-    int32 aExp, bExp, expDiff;
+    int_fast32_t aExp, bExp, expDiff;
     uint64_t aSig0, aSig1, bSig0, bSig1, q, term0, term1, term2;
     uint64_t allZero, alternateASig0, alternateASig1, sigMean1;
     int64_t sigMean0;
@@ -6098,7 +6098,7 @@ float128 float128_rem( float128 a, float128 b STATUS_PARAM )
 float128 float128_sqrt( float128 a STATUS_PARAM )
 {
     flag aSign;
-    int32 aExp, zExp;
+    int_fast32_t aExp, zExp;
     uint64_t aSig0, aSig1, zSig0, zSig1, zSig2, doubleZSig0;
     uint64_t rem0, rem1, rem2, rem3, term0, term1, term2, term3;
     float128 z;
fpu/softfloat.h +12 -13
index b29fd24..9987443 100644
@@ -55,7 +55,6 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef signed int int32;
 typedef uint64_t uint64;
 typedef int64_t int64;
 
@@ -220,12 +219,12 @@ enum {
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE integer-to-floating-point conversion routines.
 *----------------------------------------------------------------------------*/
-float32 int32_to_float32( int32 STATUS_PARAM );
-float64 int32_to_float64( int32 STATUS_PARAM );
+float32 int32_to_float32(int_fast32_t STATUS_PARAM);
+float64 int32_to_float64(int_fast32_t STATUS_PARAM);
 float32 uint32_to_float32(uint_fast32_t STATUS_PARAM);
 float64 uint32_to_float64(uint_fast32_t STATUS_PARAM);
-floatx80 int32_to_floatx80( int32 STATUS_PARAM );
-float128 int32_to_float128( int32 STATUS_PARAM );
+floatx80 int32_to_floatx80(int_fast32_t STATUS_PARAM);
+float128 int32_to_float128(int_fast32_t STATUS_PARAM);
 float32 int64_to_float32( int64 STATUS_PARAM );
 float32 uint64_to_float32( uint64 STATUS_PARAM );
 float64 int64_to_float64( int64 STATUS_PARAM );
@@ -256,8 +255,8 @@ extern const float16 float16_default_nan;
 *----------------------------------------------------------------------------*/
 int_fast16_t float32_to_int16_round_to_zero(float32 STATUS_PARAM);
 uint_fast16_t float32_to_uint16_round_to_zero(float32 STATUS_PARAM);
-int32 float32_to_int32( float32 STATUS_PARAM );
-int32 float32_to_int32_round_to_zero( float32 STATUS_PARAM );
+int_fast32_t float32_to_int32(float32 STATUS_PARAM);
+int_fast32_t float32_to_int32_round_to_zero(float32 STATUS_PARAM);
 uint_fast32_t float32_to_uint32(float32 STATUS_PARAM);
 uint_fast32_t float32_to_uint32_round_to_zero(float32 STATUS_PARAM);
 int64 float32_to_int64( float32 STATUS_PARAM );
@@ -360,8 +359,8 @@ extern const float32 float32_default_nan;
 *----------------------------------------------------------------------------*/
 int_fast16_t float64_to_int16_round_to_zero(float64 STATUS_PARAM);
 uint_fast16_t float64_to_uint16_round_to_zero(float64 STATUS_PARAM);
-int32 float64_to_int32( float64 STATUS_PARAM );
-int32 float64_to_int32_round_to_zero( float64 STATUS_PARAM );
+int_fast32_t float64_to_int32(float64 STATUS_PARAM);
+int_fast32_t float64_to_int32_round_to_zero(float64 STATUS_PARAM);
 uint_fast32_t float64_to_uint32(float64 STATUS_PARAM);
 uint_fast32_t float64_to_uint32_round_to_zero(float64 STATUS_PARAM);
 int64 float64_to_int64( float64 STATUS_PARAM );
@@ -464,8 +463,8 @@ extern const float64 float64_default_nan;
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE extended double-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int32 floatx80_to_int32( floatx80 STATUS_PARAM );
-int32 floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
+int_fast32_t floatx80_to_int32(floatx80 STATUS_PARAM);
+int_fast32_t floatx80_to_int32_round_to_zero(floatx80 STATUS_PARAM);
 int64 floatx80_to_int64( floatx80 STATUS_PARAM );
 int64 floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM );
 float32 floatx80_to_float32( floatx80 STATUS_PARAM );
@@ -549,8 +548,8 @@ extern const floatx80 floatx80_default_nan;
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE quadruple-precision conversion routines.
 *----------------------------------------------------------------------------*/
-int32 float128_to_int32( float128 STATUS_PARAM );
-int32 float128_to_int32_round_to_zero( float128 STATUS_PARAM );
+int_fast32_t float128_to_int32(float128 STATUS_PARAM);
+int_fast32_t float128_to_int32_round_to_zero(float128 STATUS_PARAM);
 int64 float128_to_int64( float128 STATUS_PARAM );
 int64 float128_to_int64_round_to_zero( float128 STATUS_PARAM );
 float32 float128_to_float32( float128 STATUS_PARAM );
osdep.h +1 -0
index c7f3a4e..935810f 100644
@@ -17,6 +17,7 @@ typedef unsigned int            uint_fast16_t;
 typedef unsigned int            uint_fast32_t;
 typedef signed char             int_fast8_t;
 typedef signed int              int_fast16_t;
+typedef signed int              int_fast32_t;
 #endif
 
 #ifndef glue
Signature · 1 line
1.7.7
#29 lore raw

PATCH 12/14 softfloat: Replace uint64 type with uint_fast64_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef uint64, uint_fast64_t;
@@
-uint64
+uint_fast_64_t

Add a typedef for pre-10 Solaris.

---
 fpu/softfloat.c |   10 +++++-----
 fpu/softfloat.h |    9 ++++-----
 osdep.h         |    1 +
 3 files changed, 10 insertions(+), 10 deletions(-)
fpu/softfloat.c +5 -5
index b7cd589..ace2ca2 100644
@@ -1208,7 +1208,7 @@ float128 int32_to_float128(int_fast32_t a STATUS_PARAM)
 float32 int64_to_float32( int64 a STATUS_PARAM )
 {
     flag zSign;
-    uint64 absA;
+    uint_fast64_t absA;
     int_fast8_t shiftCount;
 
     if ( a == 0 ) return float32_zero;
@@ -1231,7 +1231,7 @@ float32 int64_to_float32( int64 a STATUS_PARAM )
 
 }
 
-float32 uint64_to_float32( uint64 a STATUS_PARAM )
+float32 uint64_to_float32(uint_fast64_t a STATUS_PARAM)
 {
     int_fast8_t shiftCount;
 
@@ -1271,7 +1271,7 @@ float64 int64_to_float64( int64 a STATUS_PARAM )
 
 }
 
-float64 uint64_to_float64( uint64 a STATUS_PARAM )
+float64 uint64_to_float64(uint_fast64_t a STATUS_PARAM)
 {
     if ( a == 0 ) return float64_zero;
     return normalizeRoundAndPackFloat64( 0, 0x43C, a STATUS_VAR );
@@ -1288,7 +1288,7 @@ float64 uint64_to_float64( uint64 a STATUS_PARAM )
 floatx80 int64_to_floatx80( int64 a STATUS_PARAM )
 {
     flag zSign;
-    uint64 absA;
+    uint_fast64_t absA;
     int_fast8_t shiftCount;
 
     if ( a == 0 ) return packFloatx80( 0, 0, 0 );
@@ -1308,7 +1308,7 @@ floatx80 int64_to_floatx80( int64 a STATUS_PARAM )
 float128 int64_to_float128( int64 a STATUS_PARAM )
 {
     flag zSign;
-    uint64 absA;
+    uint_fast64_t absA;
     int_fast8_t shiftCount;
     int_fast32_t zExp;
     uint64_t zSig0, zSig1;
fpu/softfloat.h +4 -5
index 9987443..ce28906 100644
@@ -55,7 +55,6 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef uint64_t uint64;
 typedef int64_t int64;
 
 #define LIT64( a ) a##LL
@@ -226,9 +225,9 @@ float64 uint32_to_float64(uint_fast32_t STATUS_PARAM);
 floatx80 int32_to_floatx80(int_fast32_t STATUS_PARAM);
 float128 int32_to_float128(int_fast32_t STATUS_PARAM);
 float32 int64_to_float32( int64 STATUS_PARAM );
-float32 uint64_to_float32( uint64 STATUS_PARAM );
+float32 uint64_to_float32(uint_fast64_t STATUS_PARAM);
 float64 int64_to_float64( int64 STATUS_PARAM );
-float64 uint64_to_float64( uint64 STATUS_PARAM );
+float64 uint64_to_float64(uint_fast64_t STATUS_PARAM);
 floatx80 int64_to_floatx80( int64 STATUS_PARAM );
 float128 int64_to_float128( int64 STATUS_PARAM );
 
@@ -365,8 +364,8 @@ uint_fast32_t float64_to_uint32(float64 STATUS_PARAM);
 uint_fast32_t float64_to_uint32_round_to_zero(float64 STATUS_PARAM);
 int64 float64_to_int64( float64 STATUS_PARAM );
 int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM );
-uint64 float64_to_uint64 (float64 a STATUS_PARAM);
-uint64 float64_to_uint64_round_to_zero (float64 a STATUS_PARAM);
+uint_fast64_t float64_to_uint64(float64 a STATUS_PARAM);
+uint_fast64_t float64_to_uint64_round_to_zero(float64 a STATUS_PARAM);
 float32 float64_to_float32( float64 STATUS_PARAM );
 floatx80 float64_to_floatx80( float64 STATUS_PARAM );
 float128 float64_to_float128( float64 STATUS_PARAM );
osdep.h +1 -0
index 935810f..a30bd6a 100644
@@ -15,6 +15,7 @@
 typedef unsigned char           uint_fast8_t;
 typedef unsigned int            uint_fast16_t;
 typedef unsigned int            uint_fast32_t;
+typedef uint64_t                uint_fast64_t;
 typedef signed char             int_fast8_t;
 typedef signed int              int_fast16_t;
 typedef signed int              int_fast32_t;
Signature · 1 line
1.7.7
#30 lore raw

PATCH 13/14 softfloat: Replace int64 type with int_fast64_t

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef int64, int_fast64_t;
@@
-int64
+int_fast64_t

Add a typedef for pre-10 Solaris.

---
 fpu/softfloat.c |   38 +++++++++++++++++++-------------------
 fpu/softfloat.h |   25 ++++++++++++-------------
 osdep.h         |    1 +
 3 files changed, 32 insertions(+), 32 deletions(-)
fpu/softfloat.c +19 -19
index ace2ca2..e71a3c2 100644
@@ -162,11 +162,11 @@ static int_fast32_t roundAndPackInt32(flag zSign, uint64_t absZ STATUS_PARAM)
 | returned.
 *----------------------------------------------------------------------------*/
 
-static int64 roundAndPackInt64( flag zSign, uint64_t absZ0, uint64_t absZ1 STATUS_PARAM)
+static int_fast64_t roundAndPackInt64(flag zSign, uint64_t absZ0, uint64_t absZ1 STATUS_PARAM)
 {
     int_fast8_t roundingMode;
     flag roundNearestEven, increment;
-    int64 z;
+    int_fast64_t z;
 
     roundingMode = STATUS(float_rounding_mode);
     roundNearestEven = ( roundingMode == float_round_nearest_even );
@@ -667,7 +667,7 @@ static floatx80
 {
     int_fast8_t roundingMode;
     flag roundNearestEven, increment, isTiny;
-    int64 roundIncrement, roundMask, roundBits;
+    int_fast64_t roundIncrement, roundMask, roundBits;
 
     roundingMode = STATUS(float_rounding_mode);
     roundNearestEven = ( roundingMode == float_round_nearest_even );
@@ -1205,7 +1205,7 @@ float128 int32_to_float128(int_fast32_t a STATUS_PARAM)
 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
 *----------------------------------------------------------------------------*/
 
-float32 int64_to_float32( int64 a STATUS_PARAM )
+float32 int64_to_float32(int_fast64_t a STATUS_PARAM)
 {
     flag zSign;
     uint_fast64_t absA;
@@ -1258,7 +1258,7 @@ float32 uint64_to_float32(uint_fast64_t a STATUS_PARAM)
 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
 *----------------------------------------------------------------------------*/
 
-float64 int64_to_float64( int64 a STATUS_PARAM )
+float64 int64_to_float64(int_fast64_t a STATUS_PARAM)
 {
     flag zSign;
 
@@ -1285,7 +1285,7 @@ float64 uint64_to_float64(uint_fast64_t a STATUS_PARAM)
 | Arithmetic.
 *----------------------------------------------------------------------------*/
 
-floatx80 int64_to_floatx80( int64 a STATUS_PARAM )
+floatx80 int64_to_floatx80(int_fast64_t a STATUS_PARAM)
 {
     flag zSign;
     uint_fast64_t absA;
@@ -1305,7 +1305,7 @@ floatx80 int64_to_floatx80( int64 a STATUS_PARAM )
 | according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
 *----------------------------------------------------------------------------*/
 
-float128 int64_to_float128( int64 a STATUS_PARAM )
+float128 int64_to_float128(int_fast64_t a STATUS_PARAM)
 {
     flag zSign;
     uint_fast64_t absA;
@@ -1465,7 +1465,7 @@ int_fast16_t float32_to_int16_round_to_zero(float32 a STATUS_PARAM)
 | largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int64 float32_to_int64( float32 a STATUS_PARAM )
+int_fast64_t float32_to_int64(float32 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
@@ -1502,13 +1502,13 @@ int64 float32_to_int64( float32 a STATUS_PARAM )
 | returned.
 *----------------------------------------------------------------------------*/
 
-int64 float32_to_int64_round_to_zero( float32 a STATUS_PARAM )
+int_fast64_t float32_to_int64_round_to_zero(float32 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
     uint32_t aSig;
     uint64_t aSig64;
-    int64 z;
+    int_fast64_t z;
     a = float32_squash_input_denormal(a STATUS_VAR);
 
     aSig = extractFloat32Frac( a );
@@ -2855,7 +2855,7 @@ int_fast16_t float64_to_int16_round_to_zero(float64 a STATUS_PARAM)
 | largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int64 float64_to_int64( float64 a STATUS_PARAM )
+int_fast64_t float64_to_int64(float64 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
@@ -2898,12 +2898,12 @@ int64 float64_to_int64( float64 a STATUS_PARAM )
 | returned.
 *----------------------------------------------------------------------------*/
 
-int64 float64_to_int64_round_to_zero( float64 a STATUS_PARAM )
+int_fast64_t float64_to_int64_round_to_zero(float64 a STATUS_PARAM)
 {
     flag aSign;
     int_fast16_t aExp, shiftCount;
     uint64_t aSig;
-    int64 z;
+    int_fast64_t z;
     a = float64_squash_input_denormal(a STATUS_VAR);
 
     aSig = extractFloat64Frac( a );
@@ -4288,7 +4288,7 @@ int_fast32_t floatx80_to_int32_round_to_zero(floatx80 a STATUS_PARAM)
 | overflows, the largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int64 floatx80_to_int64( floatx80 a STATUS_PARAM )
+int_fast64_t floatx80_to_int64(floatx80 a STATUS_PARAM)
 {
     flag aSign;
     int_fast32_t aExp, shiftCount;
@@ -4328,12 +4328,12 @@ int64 floatx80_to_int64( floatx80 a STATUS_PARAM )
 | sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int64 floatx80_to_int64_round_to_zero( floatx80 a STATUS_PARAM )
+int_fast64_t floatx80_to_int64_round_to_zero(floatx80 a STATUS_PARAM)
 {
     flag aSign;
     int_fast32_t aExp, shiftCount;
     uint64_t aSig;
-    int64 z;
+    int_fast64_t z;
 
     aSig = extractFloatx80Frac( a );
     aExp = extractFloatx80Exp( a );
@@ -5320,7 +5320,7 @@ int_fast32_t float128_to_int32_round_to_zero(float128 a STATUS_PARAM)
 | largest integer with the same sign as `a' is returned.
 *----------------------------------------------------------------------------*/
 
-int64 float128_to_int64( float128 a STATUS_PARAM )
+int_fast64_t float128_to_int64(float128 a STATUS_PARAM)
 {
     flag aSign;
     int_fast32_t aExp, shiftCount;
@@ -5363,12 +5363,12 @@ int64 float128_to_int64( float128 a STATUS_PARAM )
 | returned.
 *----------------------------------------------------------------------------*/
 
-int64 float128_to_int64_round_to_zero( float128 a STATUS_PARAM )
+int_fast64_t float128_to_int64_round_to_zero(float128 a STATUS_PARAM)
 {
     flag aSign;
     int_fast32_t aExp, shiftCount;
     uint64_t aSig0, aSig1;
-    int64 z;
+    int_fast64_t z;
 
     aSig1 = extractFloat128Frac1( a );
     aSig0 = extractFloat128Frac0( a );
fpu/softfloat.h +12 -13
index ce28906..0c43436 100644
@@ -55,7 +55,6 @@ these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef int64_t int64;
 
 #define LIT64( a ) a##LL
 #define INLINE static inline
@@ -224,12 +223,12 @@ float32 uint32_to_float32(uint_fast32_t STATUS_PARAM);
 float64 uint32_to_float64(uint_fast32_t STATUS_PARAM);
 floatx80 int32_to_floatx80(int_fast32_t STATUS_PARAM);
 float128 int32_to_float128(int_fast32_t STATUS_PARAM);
-float32 int64_to_float32( int64 STATUS_PARAM );
+float32 int64_to_float32(int_fast64_t STATUS_PARAM);
 float32 uint64_to_float32(uint_fast64_t STATUS_PARAM);
-float64 int64_to_float64( int64 STATUS_PARAM );
+float64 int64_to_float64(int_fast64_t STATUS_PARAM);
 float64 uint64_to_float64(uint_fast64_t STATUS_PARAM);
-floatx80 int64_to_floatx80( int64 STATUS_PARAM );
-float128 int64_to_float128( int64 STATUS_PARAM );
+floatx80 int64_to_floatx80(int_fast64_t STATUS_PARAM);
+float128 int64_to_float128(int_fast64_t STATUS_PARAM);
 
 /*----------------------------------------------------------------------------
 | Software half-precision conversion routines.
@@ -258,8 +257,8 @@ int_fast32_t float32_to_int32(float32 STATUS_PARAM);
 int_fast32_t float32_to_int32_round_to_zero(float32 STATUS_PARAM);
 uint_fast32_t float32_to_uint32(float32 STATUS_PARAM);
 uint_fast32_t float32_to_uint32_round_to_zero(float32 STATUS_PARAM);
-int64 float32_to_int64( float32 STATUS_PARAM );
-int64 float32_to_int64_round_to_zero( float32 STATUS_PARAM );
+int_fast64_t float32_to_int64(float32 STATUS_PARAM);
+int_fast64_t float32_to_int64_round_to_zero(float32 STATUS_PARAM);
 float64 float32_to_float64( float32 STATUS_PARAM );
 floatx80 float32_to_floatx80( float32 STATUS_PARAM );
 float128 float32_to_float128( float32 STATUS_PARAM );
@@ -362,8 +361,8 @@ int_fast32_t float64_to_int32(float64 STATUS_PARAM);
 int_fast32_t float64_to_int32_round_to_zero(float64 STATUS_PARAM);
 uint_fast32_t float64_to_uint32(float64 STATUS_PARAM);
 uint_fast32_t float64_to_uint32_round_to_zero(float64 STATUS_PARAM);
-int64 float64_to_int64( float64 STATUS_PARAM );
-int64 float64_to_int64_round_to_zero( float64 STATUS_PARAM );
+int_fast64_t float64_to_int64(float64 STATUS_PARAM);
+int_fast64_t float64_to_int64_round_to_zero(float64 STATUS_PARAM);
 uint_fast64_t float64_to_uint64(float64 a STATUS_PARAM);
 uint_fast64_t float64_to_uint64_round_to_zero(float64 a STATUS_PARAM);
 float32 float64_to_float32( float64 STATUS_PARAM );
@@ -464,8 +463,8 @@ extern const float64 float64_default_nan;
 *----------------------------------------------------------------------------*/
 int_fast32_t floatx80_to_int32(floatx80 STATUS_PARAM);
 int_fast32_t floatx80_to_int32_round_to_zero(floatx80 STATUS_PARAM);
-int64 floatx80_to_int64( floatx80 STATUS_PARAM );
-int64 floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM );
+int_fast64_t floatx80_to_int64(floatx80 STATUS_PARAM);
+int_fast64_t floatx80_to_int64_round_to_zero(floatx80 STATUS_PARAM);
 float32 floatx80_to_float32( floatx80 STATUS_PARAM );
 float64 floatx80_to_float64( floatx80 STATUS_PARAM );
 float128 floatx80_to_float128( floatx80 STATUS_PARAM );
@@ -549,8 +548,8 @@ extern const floatx80 floatx80_default_nan;
 *----------------------------------------------------------------------------*/
 int_fast32_t float128_to_int32(float128 STATUS_PARAM);
 int_fast32_t float128_to_int32_round_to_zero(float128 STATUS_PARAM);
-int64 float128_to_int64( float128 STATUS_PARAM );
-int64 float128_to_int64_round_to_zero( float128 STATUS_PARAM );
+int_fast64_t float128_to_int64(float128 STATUS_PARAM);
+int_fast64_t float128_to_int64_round_to_zero(float128 STATUS_PARAM);
 float32 float128_to_float32( float128 STATUS_PARAM );
 float64 float128_to_float64( float128 STATUS_PARAM );
 floatx80 float128_to_floatx80( float128 STATUS_PARAM );
osdep.h +1 -0
index a30bd6a..6ee9f8b 100644
@@ -19,6 +19,7 @@ typedef uint64_t                uint_fast64_t;
 typedef signed char             int_fast8_t;
 typedef signed int              int_fast16_t;
 typedef signed int              int_fast32_t;
+typedef int64_t                 int_fast64_t;
 #endif
 
 #ifndef glue
Signature · 1 line
1.7.7
#31 lore raw

PATCH 14/14 softfloat: Replace flag type with bool

In reply to Andreas Färber

Based on the following Coccinelle patch:

@@
typedef flag, bool;
@@
-flag
+bool

Also drop the comment block now that the last typedef is removed.

---
 fpu/softfloat-macros.h     |    8 +-
 fpu/softfloat-specialize.h |   54 +++++-----
 fpu/softfloat.c            |  278 ++++++++++++++++++++++----------------------
 fpu/softfloat.h            |   27 ++---
 4 files changed, 179 insertions(+), 188 deletions(-)
fpu/softfloat-macros.h +4 -4
index b82871a..fe68176 100644
@@ -702,7 +702,7 @@ static int_fast8_t countLeadingZeros64(uint64_t a)
 | Otherwise, returns 0.
 *----------------------------------------------------------------------------*/
 
-INLINE flag eq128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
+INLINE bool eq128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 {
 
     return ( a0 == b0 ) && ( a1 == b1 );
@@ -715,7 +715,7 @@ INLINE flag eq128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 | Otherwise, returns 0.
 *----------------------------------------------------------------------------*/
 
-INLINE flag le128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
+INLINE bool le128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 {
 
     return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) );
@@ -728,7 +728,7 @@ INLINE flag le128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 | returns 0.
 *----------------------------------------------------------------------------*/
 
-INLINE flag lt128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
+INLINE bool lt128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 {
 
     return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) );
@@ -741,7 +741,7 @@ INLINE flag lt128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 | Otherwise, returns 0.
 *----------------------------------------------------------------------------*/
 
-INLINE flag ne128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
+INLINE bool ne128( uint64_t a0, uint64_t a1, uint64_t b0, uint64_t b1 )
 {
 
     return ( a0 != b0 ) || ( a1 != b1 );
fpu/softfloat-specialize.h +27 -27

140 lines not on this page · raw message

fpu/softfloat.c +139 -139

1,054 lines not on this page · raw message

fpu/softfloat.h +9 -18
index 0c43436..257733d 100644
@@ -43,19 +43,10 @@ these four paragraphs for those parts of this code that are retained.
 #endif
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include "config-host.h"
 #include "osdep.h"
 
-/*----------------------------------------------------------------------------
-| Each of the following `typedef's defines the most convenient type that holds
-| integers of at least as many bits as specified.  For example, `uint8' should
-| be the most convenient type that can hold unsigned integers of as many as
-| 8 bits.  The `flag' type must be able to hold either a 0 or 1.  For most
-| implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
-| to the same as `int'.
-*----------------------------------------------------------------------------*/
-typedef uint8_t flag;
-
 #define LIT64( a ) a##LL
 #define INLINE static inline
 
@@ -166,10 +157,10 @@ typedef struct float_status {
     signed char float_exception_flags;
     signed char floatx80_rounding_precision;
     /* should denormalised results go to zero and set the inexact flag? */
-    flag flush_to_zero;
+    bool flush_to_zero;
     /* should denormalised inputs go to zero and set the input_denormal flag? */
-    flag flush_inputs_to_zero;
-    flag default_nan_mode;
+    bool flush_inputs_to_zero;
+    bool default_nan_mode;
 } float_status;
 
 void set_float_rounding_mode(int val STATUS_PARAM);
@@ -178,15 +169,15 @@ INLINE void set_float_detect_tininess(int val STATUS_PARAM)
 {
     STATUS(float_detect_tininess) = val;
 }
-INLINE void set_flush_to_zero(flag val STATUS_PARAM)
+INLINE void set_flush_to_zero(bool val STATUS_PARAM)
 {
     STATUS(flush_to_zero) = val;
 }
-INLINE void set_flush_inputs_to_zero(flag val STATUS_PARAM)
+INLINE void set_flush_inputs_to_zero(bool val STATUS_PARAM)
 {
     STATUS(flush_inputs_to_zero) = val;
 }
-INLINE void set_default_nan_mode(flag val STATUS_PARAM)
+INLINE void set_default_nan_mode(bool val STATUS_PARAM)
 {
     STATUS(default_nan_mode) = val;
 }
@@ -233,8 +224,8 @@ float128 int64_to_float128(int_fast64_t STATUS_PARAM);
 /*----------------------------------------------------------------------------
 | Software half-precision conversion routines.
 *----------------------------------------------------------------------------*/
-float16 float32_to_float16( float32, flag STATUS_PARAM );
-float32 float16_to_float32( float16, flag STATUS_PARAM );
+float16 float32_to_float16(float32, bool STATUS_PARAM);
+float32 float16_to_float32(float16, bool STATUS_PARAM);
 
 /*----------------------------------------------------------------------------
 | Software half-precision operations.
Signature · 1 line
1.7.7
Reviewed-by on the v1 series
#32 lore raw
In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

Based on a suggestion from Alex earlier this week, I managed to run a simple benchmark of softfloat performance with qemu-arm, as requested by Peter.

I went for the Whetstone floating point benchmark:
http://en.wikipedia.org/wiki/Whetstone_%28benchmark%29

Quoted 7 lines

For a loop count of 100,000 and 5 runs I got the following results:

 current:        138.9-204.1 Whetstone-MIPS
 [u]int*_t:      185.2-188.7 Whetstone-MIPS
 [u]int_fast*_t: 285.7-294.1 Whetstone-MIPS

 Toshiba AC100:  833.3-909.1 Whetstone-MIPS

This is much better than I was expecting when I suggested running a benchmark :-) and indicates that it's worth a bit of pain to switch to the fast* types.

I've tested this series with the ARM VFP/Neon tests I have (random instruction sequence testing). I found a few extra bugs which I've sent a separate patch series for: those patches need to be incorporated into this series or otherwise applied before it.

I've commented on patches 01, 05, 09; the rest are

with the following caveat.

The changes from int32/uint32 to int_fast32_t/uint_fast32_t are the potentially dangerous ones in this set, since they change a type that was easily mistaken for "exactly 32 bits" and happened to be 32 bits to one that is now 64 bits (on 64 bit hosts). The other type changes are either "not a width change in practice" (int64) or "change from something that was already wider than the number in it" (int16) or "wasn't being used for things where we really cared about the type width" (int8, flag).

Specifically, it's this change that revealed the latent bugs I sent a three-patch set for, and so it doesn't seem too unlikely that other platforms may have some similar bugs in their int-to-float/float-to-int code that will now be revealed on 64 bit hosts.

I don't think that means we shouldn't apply this patch set but I would recommend some testing of other architectures :-)

-- PMM

#33 lore raw
Quoted 39 lines · Peter Maydell
Quoted 7 lines · Andreas Färber

Based on a suggestion from Alex earlier this week, I managed to run a simple benchmark of softfloat performance with qemu-arm, as requested by Peter.

I went for the Whetstone floating point benchmark:
http://en.wikipedia.org/wiki/Whetstone_%28benchmark%29

Quoted 7 lines

For a loop count of 100,000 and 5 runs I got the following results:

current: 138.9-204.1 Whetstone-MIPS
[u]int*_t: 185.2-188.7 Whetstone-MIPS
[u]int_fast*_t: 285.7-294.1 Whetstone-MIPS

Toshiba AC100: 833.3-909.1 Whetstone-MIPS

This is much better than I was expecting when I suggested running a benchmark :-) and indicates that it's worth a bit of pain to switch to the fast* types.

I've tested this series with the ARM VFP/Neon tests I have (random instruction sequence testing). I found a few extra bugs which I've sent a separate patch series for: those patches need to be incorporated into this series or otherwise applied before it.

I've commented on patches 01, 05, 09; the rest are

with the following caveat.

The changes from int32/uint32 to int_fast32_t/uint_fast32_t are the potentially dangerous ones in this set, since they change a type that was easily mistaken for "exactly 32 bits" and happened to be 32 bits to one that is now 64 bits (on 64 bit hosts). The other type changes are either "not a width change in practice" (int64) or "change from something that was already wider than the number in it" (int16) or "wasn't being used for things where we really cared about the type width" (int8, flag).

Quoted 8 lines

Specifically, it's this change that revealed the latent bugs I sent a three-patch set for, and so it doesn't seem too unlikely that other platforms may have some similar bugs in their int-to-float/float-to-int code that will now be revealed on 64 bit hosts.

I don't think that means we shouldn't apply this patch set but I would recommend some testing of other architectures :-)

So what if we leave uint32_t be uint32_t and make the other ones _fast_?

Alex

#34 lore raw
Quoted 17 lines · Alexander Graf
Quoted 15 lines · Peter Maydell

The changes from int32/uint32 to int_fast32_t/uint_fast32_t are the potentially dangerous ones in this set, since they change a type that was easily mistaken for "exactly 32 bits" and happened to be 32 bits to one that is now 64 bits (on 64 bit hosts). The other type changes are either "not a width change in practice" (int64) or "change from something that was already wider than the number in it" (int16) or "wasn't being used for things where we really cared about the type width" (int8, flag).

Specifically, it's this change that revealed the latent bugs I sent a three-patch set for, and so it doesn't seem too unlikely that other platforms may have some similar bugs in their int-to-float/float-to-int code that will now be revealed on 64 bit hosts.

Quoted 4 lines
Quoted 2 lines

I don't think that means we shouldn't apply this patch set but I would recommend some testing of other architectures :-)

So what if we leave uint32_t be uint32_t and make the other ones _fast_?

We'd need to get Andreas to do another benchmark run to check that this didn't lose the perf gain. Also it's kind of aesthetically not very pleasing...

-- PMM

#35 lore raw
Quoted 18 lines · Peter Maydell
Quoted 17 lines · Alexander Graf
Quoted 15 lines · Peter Maydell

The changes from int32/uint32 to int_fast32_t/uint_fast32_t are the potentially dangerous ones in this set, since they change a type that was easily mistaken for "exactly 32 bits" and happened to be 32 bits to one that is now 64 bits (on 64 bit hosts). The other type changes are either "not a width change in practice" (int64) or "change from something that was already wider than the number in it" (int16) or "wasn't being used for things where we really cared about the type width" (int8, flag).

Specifically, it's this change that revealed the latent bugs I sent a three-patch set for, and so it doesn't seem too unlikely that other platforms may have some similar bugs in their int-to-float/float-to-int code that will now be revealed on 64 bit hosts.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I don't think that means we shouldn't apply this patch set but I would recommend some testing of other architectures :-)

So what if we leave uint32_t be uint32_t and make the other ones _fast_?

We'd need to get Andreas to do another benchmark run to check that this didn't lose the perf gain. Also it's kind of aesthetically not very pleasing...

Yeah, but it's safe. And I would assume that 32bit integers are better optimized for than smaller ones in today's CPUs.

Alex

#36 lore raw
Quoted 9 lines · Alexander Graf
Quoted 6 lines · Peter Maydell
Quoted 1 line · Alexander Graf

So what if we leave uint32_t be uint32_t and make the other ones _fast_?

We'd need to get Andreas to do another benchmark run to check that this didn't lose the perf gain. Also it's kind of aesthetically not very pleasing...

Yeah, but it's safe.

Safety is for people with insufficiently comprehensive test suites :-)

-- PMM

#37 lore raw
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Alexander Graf
Quoted 3 lines · Peter Maydell
Quoted 1 line · Alexander Graf

So what if we leave uint32_t be uint32_t and make the other ones _fast_?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

We'd need to get Andreas to do another benchmark run to check that this didn't lose the perf gain. Also it's kind of aesthetically not very pleasing...

Yeah, but it's safe.

Safety is for people with insufficiently comprehensive test suites :-)

You mean all the non-arm targets? :)

Alex

#38 lore raw
In reply to Andreas Färber
Quoted 11 lines · Andreas Färber

For a loop count of 100,000 and 5 runs I got the following results:

 current:        138.9-204.1 Whetstone-MIPS
 [u]int*_t:      185.2-188.7 Whetstone-MIPS
 [u]int_fast*_t: 285.7-294.1 Whetstone-MIPS

 Toshiba AC100:  833.3-909.1 Whetstone-MIPS

These results seem to indicate that the "fast" POSIX types are indeed somewhat faster, both compared to exact-size POSIX types and to the current state.

OTOH I did a run of scimark2 and got:
current tree:
** **
** SciMark2 Numeric Benchmark, see http://math.nist.gov/scimark **
** for details. (Results can be submitted to [email protected]) **
** **
Using 2.00 seconds min time per kenel.

Composite Score:           12.98
FFT             Mflops:     7.66    (N=1024)
SOR             Mflops:    19.49    (100 x 100)
MonteCarlo:     Mflops:     6.12
Sparse matmult  Mflops:    15.34    (N=1000, nz=5000)
LU              Mflops:    16.28    (M=100, N=100)

with patches (yours and mine):
** **
** SciMark2 Numeric Benchmark, see http://math.nist.gov/scimark **
** for details. (Results can be submitted to [email protected]) **
** **
Using 2.00 seconds min time per kenel.

Composite Score:           11.87
FFT             Mflops:     7.12    (N=1024)
SOR             Mflops:    17.66    (100 x 100)
MonteCarlo:     Mflops:     5.75
Sparse matmult  Mflops:    14.03    (N=1000, nz=5000)
LU              Mflops:    14.81    (M=100, N=100)

Hmmm...

-- PMM

#39 lore raw

Am 20.01.2012 14:05, schrieb Peter Maydell:

Quoted 33 lines · Andreas Färber
Quoted 11 lines

For a loop count of 100,000 and 5 runs I got the following results:

current: 138.9-204.1 Whetstone-MIPS
[u]int*_t: 185.2-188.7 Whetstone-MIPS
[u]int_fast*_t: 285.7-294.1 Whetstone-MIPS

Toshiba AC100: 833.3-909.1 Whetstone-MIPS

These results seem to indicate that the "fast" POSIX types are indeed somewhat faster, both compared to exact-size POSIX types and to the current state.

OTOH I did a run of scimark2 and got:
current tree:
** **
** SciMark2 Numeric Benchmark, see http://math.nist.gov/scimark **
** for details. (Results can be submitted to [email protected]) **
** **
Using 2.00 seconds min time per kenel.

Composite Score:           12.98
FFT             Mflops:     7.66    (N=1024)
SOR             Mflops:    19.49    (100 x 100)
MonteCarlo:     Mflops:     6.12
Sparse matmult  Mflops:    15.34    (N=1000, nz=5000)
LU              Mflops:    16.28    (M=100, N=100)

with patches (yours and mine):
** **
** SciMark2 Numeric Benchmark, see http://math.nist.gov/scimark **
** for details. (Results can be submitted to [email protected]) **
** **
Using 2.00 seconds min time per kenel.

Quoted 6 lines
Composite Score:           11.87
FFT             Mflops:     7.12    (N=1024)
SOR             Mflops:    17.66    (100 x 100)
MonteCarlo:     Mflops:     5.75
Sparse matmult  Mflops:    14.03    (N=1000, nz=5000)
LU              Mflops:    14.81    (M=100, N=100)

One difference between our test environments comes to mind: I had tested only typedefs for the int types, whereas my series also converts flag. The fixes for lm32, sparc and qemu-tool shouldn't matter here. Your patches "degrade" some variables from fast types to exact types of course.

Anyway, here's my Whetstone and CoreMark results for 520c0d8d2772ccc9f9275bd934e13ec9b15774e4 (target-sparc: Fix mixup of uint64 and uint64_t) plus our patches. The margin has shrunk for Whetstone, and for CoreMark I see a slight degradation of the max. (I also note a slight Whetstone degradation between Natty and Oneiric.)

Have you tried benchmarking after our preceding patches but before the actual fast conversion for comparison?

Andreas

master:

C Converted Double Precision Whetstones: 200.0 MIPS C Converted Double Precision Whetstones: 204.1 MIPS

CoreMark 1.0 : 1287.747086 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1336.094595 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1339.943722 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap

master + PMM + fast:

C Converted Double Precision Whetstones: 204.1 MIPS C Converted Double Precision Whetstones: 208.3 MIPS

CoreMark 1.0 : 1297.690112 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1299.629606 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1309.071868 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1315.270288 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1318.913216 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1319.870653 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 1321.527686 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap

AC100 (Ubuntu Oneiric):

C Converted Double Precision Whetstones: 769.2 MIPS C Converted Double Precision Whetstones: 833.3 MIPS

CoreMark 1.0 : 2257.506208 / GCC4.6.1 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2303.086135 / GCC4.6.1 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2326.122354 / GCC4.6.1 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2349.624060 / GCC4.6.1 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2350.360389 / GCC4.6.1 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap

Pandaboard (openSUSE Factory):

C Converted Double Precision Whetstones: 833.3 MIPS

CoreMark 1.0 : 2304.855562 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2305.209774 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2306.273063 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap
CoreMark 1.0 : 2306.627710 / GCC4.6.2 -O2 -static -DPERFORMANCE_RUN=1 -lrt / Heap

Results are sorted, duplicates removed.

whetstone.c was compiled with -mfloat-abi=hard this time, using GCC (SUSE Linux) 4.6.2, and so was CoreMark except on the AC100 with GCC (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1.

coremark.exe was run with parameters 0x0 0x0 0x66 0.

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