public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Minimal support for ISO/IEC TS 18661-3.
@ 2021-07-12  9:17 Kito Cheng
  2021-07-12 15:15 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Kito Cheng @ 2021-07-12  9:17 UTC (permalink / raw)
  To: newlib, kito.cheng; +Cc: Kito Cheng, Howland, Craig D

 - GCC will set __FLT_EVAL_METHOD__ to 16 if __fp16 supported, e.g.
   cortex-a55/aarch64.
   - $ aarch64-unknown-elf-gcc -v 2>&1 |grep version
     gcc version 9.2.0 (GCC)
   - $ aarch64-unknown-elf-gcc  -E -dM -mcpu=cortex-a55 - < /dev/null  |grep FLT_EVAL_METHOD
     #define __FLT_EVAL_METHOD__ 16
     #define __FLT_EVAL_METHOD_TS_18661_3__ 16
     #define __FLT_EVAL_METHOD_C99__ 16
 - The behavior of __FLT_EVAL_METHOD__ == 16 is same as
   __FLT_EVAL_METHOD__ == 0 except for float16_t, but newlib didn't
   support float16_t.

ISO/IEC TS 18661-3:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2405.pdf

V2 Changes:
- List Howland, Craig D as co-author since he provide the draft of comment
  in math.h.

Co-authored-by: "Howland, Craig D" <howland@LGSInnovations.com>
---
 newlib/libc/include/math.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index ba1a8a17e..0b6494e6a 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -146,7 +146,17 @@ extern int isnan (double);
   #define __TMP_FLT_EVAL_METHOD
 #endif /* FLT_EVAL_METHOD */
 #if defined FLT_EVAL_METHOD
-  #if FLT_EVAL_METHOD == 0
+/* FLT_EVAL_METHOD == 16 has meaning as defined in ISO/IEC TS 18661-3,
+ * which provides non-compliant extensions to C and POSIX (by adding
+ * additional positive values for FLT_EVAL_METHOD).  It effectively has
+ * same meaning as the C99 and C11 definitions for value 0, while also
+ * serving as a flag that the _Float16 (float16_t) type exists.
+ *
+ * FLT_EVAL_METHOD could be any number of bits of supported floating point
+ * format (e.g. 32, 64, 128), but currently only AArch64 and few other targets
+ * might define that as 16.  */
+  #if (FLT_EVAL_METHOD == 0) \
+      || (FLT_EVAL_METHOD == 16)
     typedef float  float_t;
     typedef double double_t;
    #elif FLT_EVAL_METHOD == 1
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Minimal support for ISO/IEC TS 18661-3.
  2021-07-12  9:17 [PATCH v2] Minimal support for ISO/IEC TS 18661-3 Kito Cheng
@ 2021-07-12 15:15 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2021-07-12 15:15 UTC (permalink / raw)
  To: newlib

On Jul 12 17:17, Kito Cheng wrote:
>  - GCC will set __FLT_EVAL_METHOD__ to 16 if __fp16 supported, e.g.
>    cortex-a55/aarch64.
>    - $ aarch64-unknown-elf-gcc -v 2>&1 |grep version
>      gcc version 9.2.0 (GCC)
>    - $ aarch64-unknown-elf-gcc  -E -dM -mcpu=cortex-a55 - < /dev/null  |grep FLT_EVAL_METHOD
>      #define __FLT_EVAL_METHOD__ 16
>      #define __FLT_EVAL_METHOD_TS_18661_3__ 16
>      #define __FLT_EVAL_METHOD_C99__ 16
>  - The behavior of __FLT_EVAL_METHOD__ == 16 is same as
>    __FLT_EVAL_METHOD__ == 0 except for float16_t, but newlib didn't
>    support float16_t.
> 
> ISO/IEC TS 18661-3:
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2405.pdf
> 
> V2 Changes:
> - List Howland, Craig D as co-author since he provide the draft of comment
>   in math.h.
> 
> Co-authored-by: "Howland, Craig D" <howland@LGSInnovations.com>
> ---
>  newlib/libc/include/math.h | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)

Pushed.


Thanks,
Corinna


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-12 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12  9:17 [PATCH v2] Minimal support for ISO/IEC TS 18661-3 Kito Cheng
2021-07-12 15:15 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).