Hello,

Le 17/01/2022 à 00:11, FX via Fortran a écrit :
This patch is the third in my “signaling NaN” series. For targets with IEEE 
support but without the issignaling macro in libc (i.e., everywhere except 
glibc), this allows us to provide a fallback implementation. In order to keep 
the code in ieee_helper.c relatively readable, I’ve put that new implementation 
in a separate file, issignaling_fallback.h.

The logic is borrowed from different routines in glibc, but gathered into a 
single file and much simpler than the glibc implementation, because we do not 
need to cover all the cases they have (comments with details are available in 
issignaling_fallback.h).

I can’t test this on all the targets I’d like to, obviously. But it was tested 
on x86_64-pc-linux-gnu (where it doesn’t do anything), on x86_64-pc-linux-gnu 
by mimicking the lack of a issignaling macro, and on x86_64-apple-darwin (which 
does not have issignaling).

OK to push?

again, I feel underqualified to review this.
I spotted two unexpected things (to me at least) related to x86 extended type:

diff --git a/libgfortran/ieee/issignaling_fallback.h 
b/libgfortran/ieee/issignaling_fallback.h
new file mode 100644
index 00000000000..e824cf8c59b
--- /dev/null
+++ b/libgfortran/ieee/issignaling_fallback.h

...

+
+#elif (__LDBL_DIG__ == 18) && __LDBL_IS_IEC_60559__
+
+/* Long double is x86 extended type.  */
+
+typedef union
+{
+  long double value;
+  struct
+  {
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+    int sign_exponent:16;
+    unsigned int empty:16;
+    uint32_t msw;
+    uint32_t lsw;
+#elif __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
+    uint32_t lsw;
+    uint32_t msw;
+    int sign_exponent:16;
+    unsigned int empty:16;
+#endif
+  } parts;
+} ieee_long_double_shape_type;
+

- You check for endianness, so the format is not x86-specific?
- Is it expected that the padding bits are in the middle of the data in the big-endian case?

Reply via email to