public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Andrea Corallo <andrea.corallo@arm.com>
To: Jeff Johnston <jjohnstn@redhat.com>
Cc: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>,
	Torbjorn SVENSSON <torbjorn.svensson@st.com>,
	"newlib@sourceware.org" <newlib@sourceware.org>
Subject: [PATCH V3] Aarch32/64: Support __FLT_EVAL_METHOD__ values other than 0, 1, 2
Date: Mon, 11 Apr 2022 15:52:20 +0200	[thread overview]
Message-ID: <gkrsfqjwwvf.fsf_-_@arm.com> (raw)
In-Reply-To: <CAOox84tYSa=UPw8KCth-79hNnLpUqu6e_sme3o=zqJNd-VTNLQ@mail.gmail.com> (Jeff Johnston's message of "Fri, 8 Apr 2022 17:22:48 -0400")

[-- Attachment #1: Type: text/plain, Size: 618 bytes --]

Jeff Johnston <jjohnstn@redhat.com> writes:

>> On Fri, Apr 8, 2022 at 6:09 AM Richard Earnshaw <mailto:Richard.Earnshaw@foss.arm.com> wrote:
>>
>> I think the hunks in machine/ieeefp.h warrant a comment as to why we 
>> can't rely on __FLT_EVAL_METHOD__.  Other than that it LGTM, but you'll 
>> need Corinna or Jeff to approve.
>
> R.
> Please add the comment as suggested by Richard and it will be pushed.-- Jeff J.

Hi all,

please find attached the updated version of the patch implementing
Richard's suggestion.

Best Regards

  Andrea

PS I've no write access to newlib's repo so feel free to push it if
okay.


[-- Attachment #2: 0001-PATH-Aarch32-64-Support-__FLT_EVAL_METHOD__-values-o.patch --]
[-- Type: text/plain, Size: 2570 bytes --]

From a70d1a11c53d6d6797c5df859dea5b1e584fa9ac Mon Sep 17 00:00:00 2001
From: Andrea Corallo <andrea.corallo@arm.com>
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  <andrea.corallo@arm.com>

	* 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 | 14 ++++++++++++++
 newlib/libc/include/math.h           |  9 +++++++++
 2 files changed, 23 insertions(+)

diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h
index 4dc13828c..1e0680432 100644
--- a/newlib/libc/include/machine/ieeefp.h
+++ b/newlib/libc/include/machine/ieeefp.h
@@ -90,6 +90,13 @@
 #ifndef __SOFTFP__
 # define _SUPPORTS_ERREXCEPT
 #endif
+/* As per ISO/IEC TS 18661 '__FLT_EVAL_METHOD__' will be defined to 16
+   (if compiling with +fp16 support) so it can't be used by math.h to
+   define float_t and double_t.  For values of '__FLT_EVAL_METHOD__'
+   other than 0, 1, 2 the definition of float_t and double_t is
+   implementation-defined.  */
+#define __DOUBLE_TYPE double
+#define __FLOAT_TYPE float
 #endif
 
 #if defined (__aarch64__)
@@ -102,6 +109,13 @@
 #ifdef __ARM_FP
 # define _SUPPORTS_ERREXCEPT
 #endif
+/* As per ISO/IEC TS 18661 '__FLT_EVAL_METHOD__' will be defined to 16
+   (if compiling with +fp16 support) so it can't be used by math.h to
+   define float_t and double_t.  For values of '__FLT_EVAL_METHOD__'
+   other than 0, 1, 2 the definition of float_t and double_t is
+   implementation-defined.  */
+#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


  reply	other threads:[~2022-04-11 13:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04  8:39 [PATCH] " Andrea Corallo
2022-04-04  9:32 ` Torbjorn SVENSSON
2022-04-04 14:53   ` [PATCH V2] " Andrea Corallo
2022-04-04 15:12     ` Torbjorn SVENSSON
2022-04-08 10:09     ` Richard Earnshaw
2022-04-08 21:22       ` Jeff Johnston
2022-04-11 13:52         ` Andrea Corallo [this message]
2022-04-11 16:01           ` [PATCH V3] " Jeff Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gkrsfqjwwvf.fsf_-_@arm.com \
    --to=andrea.corallo@arm.com \
    --cc=Richard.Earnshaw@foss.arm.com \
    --cc=jjohnstn@redhat.com \
    --cc=newlib@sourceware.org \
    --cc=torbjorn.svensson@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).