summaryrefslogtreecommitdiffstats
path: root/libgfortran/intrinsics/c99_functions.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-03 13:28:26 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2004-08-03 13:28:26 +0000
commit8f838781125332a86ac40942fa15a4a2dec05b14 (patch)
treedda277ad0c8041e0203078222bc52f1ddaeb4ff4 /libgfortran/intrinsics/c99_functions.c
parent06469f9e82387f33974e9842da5d169b8321e030 (diff)
downloadppe42-gcc-8f838781125332a86ac40942fa15a4a2dec05b14.tar.gz
ppe42-gcc-8f838781125332a86ac40942fa15a4a2dec05b14.zip
PR libgfortran/16137
* configure.ac: Add tests for acosf, asinf, atan2f, atanf, ceilf, copysignf, cosf, coshf, expf, floorf, frexpf, hypotf, logf, log10f, scalbnf, sinf, sinhf, sqrtf, tanf and tanhf in libm. * config.h.in: Regenerate. * configure: Regenerate. * instrinsics/c99_functions.c (acosf, asinf, atan2f, atanf, ceilf, copysignf, cosf, coshf, expf, floorf, frexpf, hypotf, logf, log10f, nextafterf, scalbnf, sinf, sinhf, sqrtf, tanf, tanhf): New stub implementations for targets that don't support C99 float functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85473 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/c99_functions.c')
-rw-r--r--libgfortran/intrinsics/c99_functions.c222
1 files changed, 222 insertions, 0 deletions
diff --git a/libgfortran/intrinsics/c99_functions.c b/libgfortran/intrinsics/c99_functions.c
index 69b6c3e2e96..9ae84ed9355 100644
--- a/libgfortran/intrinsics/c99_functions.c
+++ b/libgfortran/intrinsics/c99_functions.c
@@ -20,10 +20,232 @@ Boston, MA 02111-1307, USA. */
#include "config.h"
#include <sys/types.h>
+#include <float.h>
#include <math.h>
#include "libgfortran.h"
+#ifndef HAVE_ACOSF
+float
+acosf(float x)
+{
+ return (float) acos(x);
+}
+#endif
+
+#ifndef HAVE_ASINF
+float
+asinf(float x)
+{
+ return (float) asin(x);
+}
+#endif
+
+#ifndef HAVE_ATAN2F
+float
+atan2f(float y, float x)
+{
+ return (float) atan2(y, x);
+}
+#endif
+
+#ifndef HAVE_ATANF
+float
+atanf(float x)
+{
+ return (float) atan(x);
+}
+#endif
+
+#ifndef HAVE_CEILF
+float
+ceilf(float x)
+{
+ return (float) ceil(x);
+}
+#endif
+
+#ifndef HAVE_COPYSIGNF
+float
+copysignf(float x, float y)
+{
+ return (float) copysign(x, y);
+}
+#endif
+
+#ifndef HAVE_COSF
+float
+cosf(float x)
+{
+ return (float) cos(x);
+}
+#endif
+
+#ifndef HAVE_COSHF
+float
+coshf(float x)
+{
+ return (float) cosh(x);
+}
+#endif
+
+#ifndef HAVE_EXPF
+float
+expf(float x)
+{
+ return (float) exp(x);
+}
+#endif
+
+#ifndef HAVE_FLOORF
+float
+floorf(float x)
+{
+ return (float) floor(x);
+}
+#endif
+
+#ifndef HAVE_FREXPF
+float
+frexpf(float x, int *exp)
+{
+ return (float) frexp(x, exp);
+}
+#endif
+
+#ifndef HAVE_HYPOTF
+float
+hypotf(float x, float y)
+{
+ return (float) hypot(x, y);
+}
+#endif
+
+#ifndef HAVE_LOGF
+float
+logf(float x)
+{
+ return (float) log(x);
+}
+#endif
+
+#ifndef HAVE_LOG10F
+float
+log10f(float x)
+{
+ return (float) log10(x);
+}
+#endif
+
+#ifndef HAVE_SCALBNF
+float
+scalbnf(float x, int y)
+{
+ return (float) scalbn(x, y);
+}
+#endif
+
+#ifndef HAVE_SINF
+float
+sinf(float x)
+{
+ return (float) sin(x);
+}
+#endif
+
+#ifndef HAVE_SINHF
+float
+sinhf(float x)
+{
+ return (float) sinh(x);
+}
+#endif
+
+#ifndef HAVE_SQRTF
+float
+sqrtf(float x)
+{
+ return (float) sqrt(x);
+}
+#endif
+
+#ifndef HAVE_TANF
+float
+tanf(float x)
+{
+ return (float) tan(x);
+}
+#endif
+
+#ifndef HAVE_TANHF
+float
+tanhf(float x)
+{
+ return (float) tanh(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.
+ This implementation skips denormalized values, for example returning
+ FLT_MIN as the next value after zero, as many target's frexpf, scalbnf
+ and ldexpf functions don't work as expected with denormalized values. */
+float
+nextafterf(float x, float y)
+{
+ int origexp, newexp;
+
+ if (isnan(x) || isnan(y))
+ return x+y;
+ if (x == y)
+ return x;
+
+ if (x == 0.0f)
+ return y > 0.0f ? FLT_MIN : -FLT_MIN;
+
+ frexpf(x, &origexp);
+ if (x >= 0.0)
+ {
+ if (y > x)
+ {
+ if (x < FLT_MIN)
+ return FLT_MIN;
+ return x + scalbnf(FLT_EPSILON, origexp-1);
+ }
+ else if (x > FLT_MIN)
+ {
+ float temp = x - scalbnf(FLT_EPSILON, origexp-1);
+ frexpf(temp, &newexp);
+ if (newexp == origexp)
+ return temp;
+ return x - scalbnf(FLT_EPSILON, origexp-2);
+ }
+ else
+ return 0.0f;
+ }
+ else
+ {
+ if (y < x)
+ {
+ if (x > -FLT_MIN)
+ return -FLT_MIN;
+ return x - scalbnf(FLT_EPSILON, origexp-1);
+ }
+ else if (x < -FLT_MIN)
+ {
+ float temp = x + scalbnf(FLT_EPSILON, origexp-1);
+ frexpf(temp, &newexp);
+ if (newexp == origexp)
+ return temp;
+ return x + scalbnf(FLT_EPSILON, origexp-2);
+ }
+ else
+ return 0.0f;
+ }
+}
+#endif
+
/* Note that if HAVE_FPCLASSIFY is not defined, then NaN is not handled */
/* Algorithm by Steven G. Kargl. */
OpenPOWER on IntegriCloud