re PR libfortran/16137 (Fortran compiler unable to produce executables as libfortran depends on C99 math functions)

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.

From-SVN: r85473
This commit is contained in:
Roger Sayle 2004-08-03 13:28:26 +00:00 committed by Roger Sayle
parent 2f71a20a3e
commit 453310d80b
5 changed files with 1866 additions and 73 deletions

View File

@ -1,3 +1,17 @@
2004-08-03 Roger Sayle <roger@eyesopen.com>
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.
2004-08-01 Roger Sayle <roger@eyesopen.com>
* io/write.c (write_float): Use the slightly more portable isnan

View File

@ -3,9 +3,42 @@
/* Does gettimeofday take a single argument */
#undef GETTIMEOFDAY_ONE_ARGUMENT
/* libm includes acosf */
#undef HAVE_ACOSF
/* libm includes asinf */
#undef HAVE_ASINF
/* libm includes atan2f */
#undef HAVE_ATAN2F
/* libm includes atanf */
#undef HAVE_ATANF
/* libm includes ceilf */
#undef HAVE_CEILF
/* complex.h exists */
#undef HAVE_COMPLEX_H
/* libm includes copysignf */
#undef HAVE_COPYSIGNF
/* libm includes cosf */
#undef HAVE_COSF
/* libm includes coshf */
#undef HAVE_COSHF
/* libm includes expf */
#undef HAVE_EXPF
/* libm includes floorf */
#undef HAVE_FLOORF
/* libm includes frexpf */
#undef HAVE_FREXPF
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
@ -15,9 +48,18 @@
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* libm includes hypotf */
#undef HAVE_HYPOTF
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* libm includes log10f */
#undef HAVE_LOG10F
/* libm includes logf */
#undef HAVE_LOGF
/* Define to 1 if you have the <math.h> header file. */
#undef HAVE_MATH_H
@ -33,12 +75,24 @@
/* libm includes nextafterf */
#undef HAVE_NEXTAFTERF
/* "c99 function" */
/* libm includes round */
#undef HAVE_ROUND
/* "c99 function" */
/* libm includes roundf */
#undef HAVE_ROUNDF
/* libm includes scalbnf */
#undef HAVE_SCALBNF
/* libm includes sinf */
#undef HAVE_SINF
/* libm includes sinhf */
#undef HAVE_SINHF
/* libm includes sqrtf */
#undef HAVE_SQRTF
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
@ -75,6 +129,12 @@
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* libm includes tanf */
#undef HAVE_TANF
/* libm includes tanhf */
#undef HAVE_TANHF
/* Define to 1 if you have the `times' function. */
#undef HAVE_TIMES
@ -108,5 +168,11 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t

1606
libgfortran/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -160,12 +160,31 @@ AC_CHECK_LIB([m],[csin],[need_math="no"],[need_math="yes"])
# Check for library functions.
AC_CHECK_FUNCS(getrusage times)
# Check for some C99 functions
AC_CHECK_LIB([m],[round],[AC_DEFINE([HAVE_ROUND],[1],["c99 function"])])
AC_CHECK_LIB([m],[roundf],[AC_DEFINE([HAVE_ROUNDF],[1],["c99 function"])])
# And other IEEE math functions
# Check for C99 (and other IEEE) math functions
AC_CHECK_LIB([m],[acosf],[AC_DEFINE([HAVE_ACOSF],[1],[libm includes acosf])])
AC_CHECK_LIB([m],[asinf],[AC_DEFINE([HAVE_ASINF],[1],[libm includes asinf])])
AC_CHECK_LIB([m],[atan2f],[AC_DEFINE([HAVE_ATAN2F],[1],[libm includes atan2f])])
AC_CHECK_LIB([m],[atanf],[AC_DEFINE([HAVE_ATANF],[1],[libm includes atanf])])
AC_CHECK_LIB([m],[ceilf],[AC_DEFINE([HAVE_CEILF],[1],[libm includes ceilf])])
AC_CHECK_LIB([m],[copysignf],[AC_DEFINE([HAVE_COPYSIGNF],[1],[libm includes copysignf])])
AC_CHECK_LIB([m],[cosf],[AC_DEFINE([HAVE_COSF],[1],[libm includes cosf])])
AC_CHECK_LIB([m],[coshf],[AC_DEFINE([HAVE_COSHF],[1],[libm includes coshf])])
AC_CHECK_LIB([m],[expf],[AC_DEFINE([HAVE_EXPF],[1],[libm includes expf])])
AC_CHECK_LIB([m],[floorf],[AC_DEFINE([HAVE_FLOORF],[1],[libm includes floorf])])
AC_CHECK_LIB([m],[frexpf],[AC_DEFINE([HAVE_FREXPF],[1],[libm includes frexpf])])
AC_CHECK_LIB([m],[hypotf],[AC_DEFINE([HAVE_HYPOTF],[1],[libm includes hypotf])])
AC_CHECK_LIB([m],[logf],[AC_DEFINE([HAVE_LOGF],[1],[libm includes logf])])
AC_CHECK_LIB([m],[log10f],[AC_DEFINE([HAVE_LOG10F],[1],[libm includes log10f])])
AC_CHECK_LIB([m],[nextafter],[AC_DEFINE([HAVE_NEXTAFTER],[1],[libm includes nextafter])])
AC_CHECK_LIB([m],[nextafterf],[AC_DEFINE([HAVE_NEXTAFTERF],[1],[libm includes nextafterf])])
AC_CHECK_LIB([m],[round],[AC_DEFINE([HAVE_ROUND],[1],[libm includes round])])
AC_CHECK_LIB([m],[roundf],[AC_DEFINE([HAVE_ROUNDF],[1],[libm includes roundf])])
AC_CHECK_LIB([m],[scalbnf],[AC_DEFINE([HAVE_SCALBNF],[1],[libm includes scalbnf])])
AC_CHECK_LIB([m],[sinf],[AC_DEFINE([HAVE_SINF],[1],[libm includes sinf])])
AC_CHECK_LIB([m],[sinhf],[AC_DEFINE([HAVE_SINHF],[1],[libm includes sinhf])])
AC_CHECK_LIB([m],[sqrtf],[AC_DEFINE([HAVE_SQRTF],[1],[libm includes sqrtf])])
AC_CHECK_LIB([m],[tanf],[AC_DEFINE([HAVE_TANF],[1],[libm includes tanf])])
AC_CHECK_LIB([m],[tanhf],[AC_DEFINE([HAVE_TANHF],[1],[libm includes tanhf])])
# Let the user override this
AC_ARG_ENABLE(cmath,

View File

@ -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. */