bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: fma: Fix compilation error on Linux/sh4
Date: Sun, 29 Aug 2021 02:06:20 +0200	[thread overview]
Message-ID: <2947839.GKX7oQKdZx@omega> (raw)

When compiling a testdir on Linux/sh4, I see this compilation error:

../../gllib/fma.c: In function 'rpl_fma':
../../gllib/fma.c:728:47: error: 'FE_DOWNWARD' undeclared (first use in this function); did you mean 'FP_INT_DOWNWARD'?
  728 |                     else if (rounding_mode == FE_DOWNWARD)
      |                                               ^~~~~~~~~~~
      |                                               FP_INT_DOWNWARD
../../gllib/fma.c:728:47: note: each undeclared identifier is reported only once for each function it appears in
../../gllib/fma.c:730:47: error: 'FE_UPWARD' undeclared (first use in this function)
  730 |                     else if (rounding_mode == FE_UPWARD)
      |                                               ^~~~~~~~~
make[3]: *** [Makefile:9372: fma.o] Error 1

The cause is that sh4 has only two among the four rounding modes. The other
two are simply not defined in glibc's <bits/fenv.h>.


2021-08-28  Bruno Haible  <bruno@clisp.org>

	fma: Fix compilation error on Linux/sh4.
	* lib/fma.c (FUNC): Don't test for FE_DOWNWARD or FE_UPWARD when these
	rounding modes are not defined.

diff --git a/lib/fma.c b/lib/fma.c
index 3bddb30f3..bee05719c 100644
--- a/lib/fma.c
+++ b/lib/fma.c
@@ -725,10 +725,14 @@ FUNC (DOUBLE x, DOUBLE y, DOUBLE z)
                     int rounding_mode = fegetround ();
                     if (rounding_mode == FE_TOWARDZERO)
                       round_up = 0;
+# if defined FE_DOWNWARD /* not defined on sh4 */
                     else if (rounding_mode == FE_DOWNWARD)
                       round_up = sign;
+# endif
+# if defined FE_UPWARD /* not defined on sh4 */
                     else if (rounding_mode == FE_UPWARD)
                       round_up = !sign;
+# endif
 #else
                     /* Cf. <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/float.h.html> */
                     int rounding_mode = FLT_ROUNDS;





                 reply	other threads:[~2021-08-29  0:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=2947839.GKX7oQKdZx@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /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).