#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_FABSF
float
fabsf(float x)
{
return (float) fabs(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_SCALBN
double
scalbn(double x, int y)
{
return x * pow(FLT_RADIX, y);
}
#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_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
float
nextafterf(float x, float y)
{
volatile float delta;
float absx, denorm_min;
if (isnan(x) || isnan(y))
return x + y;
if (x == y)
return x;
if (!isfinite (x))
return x > 0 ? __FLT_MAX__ : - __FLT_MAX__;
absx = (x < 0.0) ? -x : x;
if (__FLT_DENORM_MIN__ == 0.0f)
denorm_min = __FLT_MIN__;
else
denorm_min = __FLT_DENORM_MIN__;
if (absx < __FLT_MIN__)
delta = denorm_min;
else
{
float frac;
int exp;
frac = frexpf (absx, &exp);
delta = scalbnf (0.5f, exp);
delta *= __FLT_EPSILON__;
if (frac == 0.5f && (y < x) == (x > 0))
delta *= 0.5f;
if (delta == 0.0f)
delta = denorm_min;
}
if (y < x)
delta = -delta;
return x + delta;
}
#endif
#ifndef HAVE_POWF
float
powf(float x, float y)
{
return (float) pow(x, y);
}
#endif
#ifndef HAVE_ROUND
double
round(double x)
{
double t;
#if defined(fpclassify)
int i;
i = fpclassify(x);
if (i == FP_INFINITE || i == FP_NAN)
return (x);
#endif
if (x >= 0.0)
{
t = ceil(x);
if (t - x > 0.5)
t -= 1.0;
return (t);
}
else
{
t = ceil(-x);
if (t + x > 0.5)
t -= 1.0;
return (-t);
}
}
#endif
#ifndef HAVE_ROUNDF
float
roundf(float x)
{
float t;
#if defined(fpclassify)
int i;
i = fpclassify(x);
if (i == FP_INFINITE || i == FP_NAN)
return (x);
#endif
if (x >= 0.0)
{
t = ceilf(x);
if (t - x > 0.5)
t -= 1.0;
return (t);
}
else
{
t = ceilf(-x);
if (t + x > 0.5)
t -= 1.0;
return (-t);
}
}
#endif