summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/c99_functions.c
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-21 06:44:50 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-21 06:44:50 +0000
commit50f0ca0a0d7f9b6a4e94b4c42f59f4cee2c1a7f1 (patch)
treee0800c58d9a0cf8ee2e6fb295ce7e5093a94bfd1 /libgfortran/intrinsics/c99_functions.c
parent337acf8732b0617d36c359e2a6efa85911243fd3 (diff)
downloadgcc-50f0ca0a0d7f9b6a4e94b4c42f59f4cee2c1a7f1.tar.gz
* configure.ac: Check for trunc and truncf in libm.
* configure: Regenerate. * config.h.in: Likewise. * intrinsics/c99_functions.c (trunc, truncf): New functions. * c99_protos.h (trunc, truncf): Declare them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100040 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/c99_functions.c')
-rw-r--r--libgfortran/intrinsics/c99_functions.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libgfortran/intrinsics/c99_functions.c b/libgfortran/intrinsics/c99_functions.c
index f7dc9777dd8..6296904b56d 100644
--- a/libgfortran/intrinsics/c99_functions.c
+++ b/libgfortran/intrinsics/c99_functions.c
@@ -202,6 +202,28 @@ tanhf(float x)
}
#endif
+#ifndef HAVE_TRUNC
+double
+trunc(double x)
+{
+ if (!isfinite (x))
+ return x;
+
+ if (x < 0.0)
+ return - floor (-x);
+ else
+ return floor (x);
+}
+#endif
+
+#ifndef HAVE_TRUNCF
+float
+truncf(float x)
+{
+ return (float) trunc (x);
+}
+#endif
+
#ifndef HAVE_NEXTAFTERF
/* This is a portable implementation of nextafterf that is intended to be
independent of the floating point format or its in memory representation.