Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for C99 math functions, hypot, atanh, cbrt, etc. #555

Merged
merged 2 commits into from
Aug 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ if (HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN)
add_definitions(-DHAVE_PTHREAD_MUTEX_RECURSIVE=1)
endif()

include (CheckCSourceCompiles)
if (MSVC)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} /WX")
else ()
set (CMAKE_REQUIRED_LIBRARIES m)
set (CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif ()
# Check whether the C99 math function: hypot, atanh, etc. are available.
check_c_source_compiles (
"#include <math.h>
int main() {
int q;
return (int)(hypot(3.0, 4.0) + atanh(0.8) + cbrt(8.0) +
remquo(100.0, 90.0, &q) +
remainder(100.0, 90.0) + copysigna(1.0, -0.0));
}\n" C99_MATH)
if (C99_MATH)
add_definitions (-DHAVE_C99_MATH=1)
else ()
add_definitions (-DHAVE_C99_MATH=0)
endif ()

boost_report_value(PROJ_PLATFORM_NAME)
boost_report_value(PROJ_COMPILER_NAME)

Expand Down
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ CFLAGS="$save_CFLAGS"
dnl We check for headers
AC_HEADER_STDC

dnl Check for C99 math functions
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wall -Werror"
AC_MSG_CHECKING([for C99 math functions])
AC_LINK_IFELSE([AC_LANG_PROGRAM(
[#include <math.h>],
[int q;
return (int)(hypot(3.0, 4.0) + atanh(0.8) + cbrt(8.0) +
remquo(100.0, 90.0, &q) +
remainder(100.0, 90.0) + copysign(1.0, -0.0));])],
[AC_MSG_RESULT([yes]);C99_MATH="-DHAVE_C99_MATH=1"],
[AC_MSG_RESULT([no]);C99_MATH="-DHAVE_C99_MATH=0"])
CFLAGS="$save_CFLAGS $C99_MATH"

AC_CHECK_FUNC(localeconv, [AC_DEFINE(HAVE_LOCALECONV,1,[Define to 1 if you have localeconv])])

dnl ---------------------------------------------------------------------------
Expand Down