Re: [PATCH V2] Aarch32/64: Support __FLT_EVAL_METHOD__ values other than 0, 1, 2

Andrea Corallo <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Torbjorn SVENSSON <[email protected]> writes:

> Hello,
>
> It would have been easier to review the patch if it was inline, but
> this will have to do anyway.

Hi Torbjorn,

sorry most mail readers easily show inline attacchaments of type
"text/plain" allowing for inline reply, at the same time this way they
can still retain the notion of attached file.  This is how I rutinary
sent my patches to other GNU projects (including GCC) so far.  Has
newlib some specific rule around this?

> I think there is a typo in math.h. Aren't you supposed to do "#ifndef" and not "#ifdef"?

I guess we are talking about this hunk?

 #ifdef __epiphany__
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index ba1a8a17e..da056b5b6 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -158,6 +158,15 @@ extern int isnan (double);
    #else
     /* Implementation-defined.  Assume float_t and double_t have been
      * defined previously for this configuration (e.g. config.h). */
+
+   /* If __DOUBLE_TYPE is defined (__FLOAT_TYPE is then supposed to be
+      defined as well) float_t and double_t definition is suggested by
+      an arch specific header.  */
+   #ifdef __DOUBLE_TYPE
+    typedef __DOUBLE_TYPE double_t;
+    typedef __FLOAT_TYPE float_t;
+   #endif
+   /* Assume config.h has provided these types.  */
   #endif
 #else
     /* Assume basic definitions.  */

I believe the #ifdef is correct.  As the comment suggests if
__DOUBLE_TYPE is defined we'll use it to define double_t otherwise we
assume is config.h has provided the type definition.

I'm reattaching the latest version of this patch with a typo fixed.

Thanks!

  Andrea
0001-PATH-Aarch32-64-Support-__FLT_EVAL_METHOD__-values-o.patch (text/plain, 1.9 KB)
From d4c7eab60765bc51b97915744a5fec17b9499400 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <[email protected]>
Date: Wed, 30 Mar 2022 15:40:59 +0200
Subject: [PATCH] [PATH] Aarch32/64: Support __FLT_EVAL_METHOD__ values other
 than 0, 1, 2

2022-03-30  Andrea Corallo  <[email protected]>

	* libc/include/machine/ieeefp.h (__FLOAT_TYPE, __DOUBLE_TYPE): New
	macros.
	* libc/include/math.h: Uses __DOUBLE_TYPE __FLOAT_TYPE to define
	double_t float_t if possible.
---
 newlib/libc/include/machine/ieeefp.h | 4 ++++
 newlib/libc/include/math.h           | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h
index 4dc13828c..c65c67769 100644
--- a/newlib/libc/include/machine/ieeefp.h
+++ b/newlib/libc/include/machine/ieeefp.h
@@ -90,6 +90,8 @@
 #ifndef __SOFTFP__
 # define _SUPPORTS_ERREXCEPT
 #endif
+#define __DOUBLE_TYPE double
+#define __FLOAT_TYPE float
 #endif
 
 #if defined (__aarch64__)
@@ -102,6 +104,8 @@
 #ifdef __ARM_FP
 # define _SUPPORTS_ERREXCEPT
 #endif
+#define __DOUBLE_TYPE double
+#define __FLOAT_TYPE float
 #endif
 
 #ifdef __epiphany__
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index ba1a8a17e..af5b5e653 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -158,6 +158,15 @@ extern int isnan (double);
    #else
     /* Implementation-defined.  Assume float_t and double_t have been
      * defined previously for this configuration (e.g. config.h). */
+
+   /* If __DOUBLE_TYPE is defined (__FLOAT_TYPE is then supposed to be
+      defined as well) float_t and double_t definition is suggested by
+      an arch specific header.  */
+   #ifdef __DOUBLE_TYPE
+    typedef __DOUBLE_TYPE double_t;
+    typedef __FLOAT_TYPE float_t;
+   #endif
+   /* Assume config.h has provided these types.  */
   #endif
 #else
     /* Assume basic definitions.  */
-- 
2.25.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.