From: brarcher Date: Sun, 15 Jun 2014 23:15:07 +0000 (+0000) Subject: autoconf: attempt to find __floor() if floor() is unavailable X-Git-Tag: 0.10.0~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41a9441e1c17386924c0b8c4f5672e816cb48f7e;p=check autoconf: attempt to find __floor() if floor() is unavailable On the AIX platform, floor() is not in libm, but __floor() is an internal function in the compiler. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1142 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/configure.ac b/configure.ac index ed13338..3a1be6c 100644 --- a/configure.ac +++ b/configure.ac @@ -181,7 +181,15 @@ ACX_PTHREAD CC="$PTHREAD_CC" # Check if floor is in the math library, and if so add -lm to LIBS -AC_CHECK_LIB([m], [floor]) +HAVE__FLOOR=0 +AC_SEARCH_LIBS([floor], [m], [HAVE_FLOOR=1], [HAVE_FLOOR=0]) +if test "x$HAVE_FLOOR" = "x0"; then + # floor() is not available in libm (e.g. using AIX platform's compiler). + # Maybe __floor() is defined instead + AC_CHECK_FUNCS(__floor) +fi +AC_DEFINE([HAVE_FLOOR], [$HAVE_FLOOR], [Does the system have floor()?]) +AC_DEFINE([HAVE___FLOOR], [$HAVE___FLOOR], [Does the system have __floor()?]) # Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so, # add -lrt to LIBS diff --git a/lib/libcompat.h b/lib/libcompat.h index 54996ad..6d02422 100644 --- a/lib/libcompat.h +++ b/lib/libcompat.h @@ -117,6 +117,18 @@ CK_DLL_EXP const char *strsignal(int sig); #endif /* !HAVE_DECL_STRSIGNAL */ /* + * On the AIX platform, floor() is not in libm, but + * __floor() is an internal function in the compiler, + * and a header defines floor() to __floor(). + * For whatever reason, the headers included in Check + * do not pull that in. If floor() is missing but __floor() + * is available, make the definition. + */ +#if !HAVE_FLOOR && HAVE___FLOOR +#define floor __floor +#endif /* !HAVE_FLOOR && HAVE___FLOOR */ + +/* * On systems where clock_gettime() is not available, or * on systems where some clocks may not be supported, the * definition for CLOCK_MONOTONIC and CLOCK_REALTIME may not