about summary refs log tree commit diff
path: root/sysdeps/powerpc/fpu
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/powerpc/fpu')
-rw-r--r--sysdeps/powerpc/fpu/round_to_integer.h4
-rw-r--r--sysdeps/powerpc/fpu/s_floor.c35
-rw-r--r--sysdeps/powerpc/fpu/s_floorf.c35
3 files changed, 73 insertions, 1 deletions
diff --git a/sysdeps/powerpc/fpu/round_to_integer.h b/sysdeps/powerpc/fpu/round_to_integer.h
index c70afbb10f..ff77dde394 100644
--- a/sysdeps/powerpc/fpu/round_to_integer.h
+++ b/sysdeps/powerpc/fpu/round_to_integer.h
@@ -23,7 +23,8 @@
 
 enum round_mode
 {
-  CEIL
+  CEIL,
+  FLOOR
 };
 
 static inline void
@@ -33,6 +34,7 @@ set_fenv_mode (enum round_mode mode)
   switch (mode)
   {
   case CEIL:  rmode = FE_UPWARD; break;
+  case FLOOR: rmode = FE_DOWNWARD; break;
   default:    rmode = FE_TONEAREST; break;
   }
   __fesetround_inline_nocheck (rmode);
diff --git a/sysdeps/powerpc/fpu/s_floor.c b/sysdeps/powerpc/fpu/s_floor.c
new file mode 100644
index 0000000000..fb8df97cca
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_floor.c
@@ -0,0 +1,35 @@
+/* Largest integral value not greater than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-double.h>
+#include <round_to_integer.h>
+
+double
+__floor (double x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_floor (x);
+#else
+  return round_to_integer_double (FLOOR, x);
+#endif
+}
+#ifndef __floor
+libm_alias_double (__floor, floor)
+#endif
diff --git a/sysdeps/powerpc/fpu/s_floorf.c b/sysdeps/powerpc/fpu/s_floorf.c
new file mode 100644
index 0000000000..ea4723bb69
--- /dev/null
+++ b/sysdeps/powerpc/fpu/s_floorf.c
@@ -0,0 +1,35 @@
+/* Smallest integral value not less than argument.  PowerPC version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If
+   not, see <http://www.gnu.org/licenses/>.  */
+
+#define NO_MATH_REDIRECT
+#include <math.h>
+#include <libm-alias-float.h>
+#include <round_to_integer.h>
+
+float
+__floorf (float x)
+{
+#ifdef _ARCH_PWR5X
+  return __builtin_floorf (x);
+#else
+  return round_to_integer_float (FLOOR, x);
+#endif
+}
+#ifndef __floorf
+libm_alias_float (__floor, floor)
+#endif