From 798de454144208ea58a080c13c99f38c1166f0bd Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 29 Aug 2021 02:05:05 +0200
Subject: [PATCH] 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.
---
 ChangeLog | 6 ++++++
 lib/fma.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 12187eaf97..599ce55edd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
 2021-08-28  Bruno Haible  <bruno@clisp.org>
 
 	Skip some tests when running under QEMU user-mode.
diff --git a/lib/fma.c b/lib/fma.c
index 3bddb30f30..bee05719c0 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;
-- 
2.39.5