From 414663cc363108cb71a290de1c86a1b04384fb39 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Sun, 3 May 2015 20:46:22 +0300 Subject: [PATCH] Don't use unavailable C99 long double math functions uClibc variants do not provide the C99 long double math functions like ceill, powl, etc.. For future compatibility use check_symbol_exists() to check whether these functions are available, and keep the result in HAVE_MATH_C99_LONG_DOUBLE. Use that instead of the fragile Cygwin version check in triodef.h. Fixes build failures under uClibc(-ng) like: ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `powl' ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `fmodl' ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `ceill' ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `log10l' ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `floorl' collect2: error: ld returned 1 exit status Signed-off-by: Baruch Siach --- CMakeLists.txt | 3 +++ config.h.in | 1 + winpr/libwinpr/utils/trio/triodef.h | 25 ++++++------------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db2170f..1241541 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -456,6 +456,9 @@ if(UNIX OR CYGWIN) endif() check_include_files(sys/timerfd.h HAVE_TIMERFD_H) check_include_files(poll.h HAVE_POLL_H) + list(APPEND CMAKE_REQUIRED_LIBRARIES m) + check_symbol_exists(ceill math.h HAVE_MATH_C99_LONG_DOUBLE) + list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES m) set(X11_FEATURE_TYPE "RECOMMENDED") set(WAYLAND_FEATURE_TYPE "RECOMMENDED") else() diff --git a/config.h.in b/config.h.in index 1a13e54..f73c532 100644 --- a/config.h.in +++ b/config.h.in @@ -46,6 +46,7 @@ #cmakedefine WITH_WIN8 #cmakedefine WITH_RDPSND_DSOUND #cmakedefine WITH_EVENTFD_READ_WRITE +#cmakedefine HAVE_MATH_C99_LONG_DOUBLE #cmakedefine WITH_FFMPEG #cmakedefine WITH_GSTREAMER_1_0 diff --git a/winpr/libwinpr/utils/trio/triodef.h b/winpr/libwinpr/utils/trio/triodef.h index ce2667b..97da67e 100644 --- a/winpr/libwinpr/utils/trio/triodef.h +++ b/winpr/libwinpr/utils/trio/triodef.h @@ -313,25 +313,12 @@ typedef void * trio_pointer_t; # define TRIO_COMPILER_SUPPORTS_LL #endif -#if defined(__CYGWIN__) -/* - * Cygwin defines the macros for hosted C99, but does not support certain - * long double math functions. - */ -# include -# define TRIO_CYGWIN_VERSION_API CYGWIN_VERSION_API_MAJOR * 1000 + \ - CYGWIN_VERSION_API_MINOR -/* - * Please change the version number below when the Cygwin API supports - * long double math functions (powl, fmodl, etc.) - */ -# if TRIO_CYGWIN_VERSION_API < 99999999 -# define TRIO_NO_FLOORL 1 -# define TRIO_NO_CEILL 1 -# define TRIO_NO_POWL 1 -# define TRIO_NO_FMODL 1 -# define TRIO_NO_LOG10L 1 -# endif +#if !defined(HAVE_MATH_C99_LONG_DOUBLE) +# define TRIO_NO_FLOORL 1 +# define TRIO_NO_CEILL 1 +# define TRIO_NO_POWL 1 +# define TRIO_NO_FMODL 1 +# define TRIO_NO_LOG10L 1 #endif #endif /* TRIO_TRIODEF_H */ -- 2.7.4