]> granicus.if.org Git - check/commitdiff
autoconf: attempt to find __floor() if floor() is unavailable
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sun, 15 Jun 2014 23:15:07 +0000 (23:15 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sun, 15 Jun 2014 23:15:07 +0000 (23:15 +0000)
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

configure.ac
lib/libcompat.h

index ed1333891090ae5cffb2fe15f7d28d1f0695020c..3a1be6cbf82782cea40cfc9a1a6e40521aafdacf 100644 (file)
@@ -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
index 54996adb0a1bb9702c16fd19eaa4a8a549b6bac2..6d02422452abf475faac3fdb0c868b5b6811c9f9 100644 (file)
@@ -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