Commit 6bc056d5 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Check for exp10 and exp10f math library functions

parent 544ff121
......@@ -1173,6 +1173,16 @@ if test "$have_armv7apmccntr"x = "yes"x; then
AC_DEFINE(HAVE_ARMV7A_PMCCNTR,1,[Define if you have enabled the PMCCNTR cycle counter on ARMv7a])
fi
# Check if we have native exp10 and exp10f functions. If not failback to our
# implementations. On Apple/CLANG we have __exp10, so also check for that
# if the compiler is clang.
AC_CHECK_LIB([m],[exp10], [AC_DEFINE([HAVE_EXP10],1,[The exp10 function is present.])])
AC_CHECK_LIB([m],[exp10f], [AC_DEFINE([HAVE_EXP10F],1,[The exp10f function is present.])])
if test "$ax_cv_c_compiler_vendor" = "clang"; then
AC_CHECK_LIB([m],[__exp10], [AC_DEFINE([HAVE___EXP10],1,[The __exp10 function is present.])])
AC_CHECK_LIB([m],[__exp10f], [AC_DEFINE([HAVE___EXP10F],1,[The __exp10f function is present.])])
fi
# Add warning flags by default, if these can be used. Option =error adds
# -Werror to GCC, clang and Intel. Note do this last as compiler tests may
# become errors, if that's an issue don't use CFLAGS for these, use an AC_SUBST().
......
......@@ -25,11 +25,11 @@
/* Some standard headers. */
#include <math.h>
#ifndef __GNUC__
/* Local headers. */
#include "inline.h"
#if !defined(HAVE_EXP10) && !defined(HAVE___EXP10))
/**
* @brief Raises 10 to the power of the argument.
*
......@@ -44,6 +44,10 @@ __attribute__((always_inline, const)) INLINE static double exp10(
return exp(x * M_LN10);
}
#endif
#if !defined(HAVE_EXP10F) && !defined(HAVE___EXP10F))
/**
* @brief Raises 10 to the power of the argument.
*
......@@ -58,6 +62,16 @@ __attribute__((always_inline, const)) INLINE static float exp10f(
return expf(x * (float)M_LN10);
}
#endif /* __GNUC__ */
#endif
/* Use the __exp10 and __exp10f versions if needed. */
#if !defined(HAVE_EXP10) && defined(HAVE___EXP10))
#define exp10(x) __exp10(x)
#endif
#if !defined(HAVE_EXP10F) && defined(HAVE___EXP10F))
#define exp10f(x) __exp10f(x)
#endif
#endif /* SWIFT_EXP10_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment