bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fma: Fix compilation error on Linux/sh4


From: Bruno Haible
Subject: fma: Fix compilation error on Linux/sh4
Date: Sun, 29 Aug 2021 02:06:20 +0200

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 via email to

[Prev in Thread] Current Thread [Next in Thread]