bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* fma: Fix compilation error on Linux/sh4
@ 2021-08-29  0:06 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2021-08-29  0:06 UTC (permalink / raw)
  To: bug-gnulib

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;





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-29  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-29  0:06 fma: Fix compilation error on Linux/sh4 Bruno Haible

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).