]> jfr.im git - irc/atheme/atheme.git/commitdiff
m4/atheme-libtest-clock-gettime: do link test with required API & constants
authorAaron Jones <redacted>
Thu, 6 Feb 2020 06:03:02 +0000 (06:03 +0000)
committerAaron Jones <redacted>
Thu, 6 Feb 2020 06:04:28 +0000 (06:04 +0000)
This is what we do in all the other library test files.

[ci skip]

configure
m4/atheme-libtest-clock-gettime.m4

index 228a1ac8c3cdfc7c9fdf7ade494e88f1566c61ef..fc5254a109c238c7b5be3a77d821fac7b91c15e0 100755 (executable)
--- a/configure
+++ b/configure
@@ -10189,16 +10189,56 @@ if test "$ac_res" != no; then :
         if test "x${ac_cv_search_clock_gettime}" != "xnone required"; then :
 
             CLOCK_GETTIME_LIBS="${ac_cv_search_clock_gettime}"
+            LIBS="${CLOCK_GETTIME_LIBS} ${LIBS}"
 
 fi
 
-        HAVE_CLOCK_GETTIME="Yes"
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking if clock_gettime(3) appears to be usable" >&5
+$as_echo_n "checking if clock_gettime(3) appears to be usable... " >&6; }
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                #ifdef HAVE_TIME_H
+                #  include <time.h>
+                #endif
+
+int
+main ()
+{
+
+                struct timespec begin;
+                (void) begin.tv_sec;
+                (void) begin.tv_nsec;
+                (void) clock_gettime(CLOCK_MONOTONIC, &begin);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+            HAVE_CLOCK_GETTIME="Yes"
 
 
     CRYPTO_BENCHMARK_COND_D="crypto-benchmark"
 
 
 
+else
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+            HAVE_CLOCK_GETTIME="No"
+            CLOCK_GETTIME_LIBS=""
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+
 fi
 
 
index 974ca73daa9b899538318416bbb61bc11c08e3c0..2a8599aaf9148151433d61c4e6c0fe3256c1566a 100644 (file)
@@ -16,10 +16,30 @@ AC_DEFUN([ATHEME_LIBTEST_CLOCK_GETTIME], [
     AC_SEARCH_LIBS([clock_gettime], [rt], [
         AS_IF([test "x${ac_cv_search_clock_gettime}" != "xnone required"], [
             CLOCK_GETTIME_LIBS="${ac_cv_search_clock_gettime}"
+            LIBS="${CLOCK_GETTIME_LIBS} ${LIBS}"
         ])
 
-        HAVE_CLOCK_GETTIME="Yes"
-        ATHEME_COND_CRYPTO_BENCHMARK_ENABLE
+        AC_MSG_CHECKING([if clock_gettime(3) appears to be usable])
+        AC_LINK_IFELSE([
+            AC_LANG_PROGRAM([[
+                #ifdef HAVE_TIME_H
+                #  include <time.h>
+                #endif
+            ]], [[
+                struct timespec begin;
+                (void) begin.tv_sec;
+                (void) begin.tv_nsec;
+                (void) clock_gettime(CLOCK_MONOTONIC, &begin);
+            ]])
+        ], [
+            AC_MSG_RESULT([yes])
+            HAVE_CLOCK_GETTIME="Yes"
+            ATHEME_COND_CRYPTO_BENCHMARK_ENABLE
+        ], [
+            AC_MSG_RESULT([no])
+            HAVE_CLOCK_GETTIME="No"
+            CLOCK_GETTIME_LIBS=""
+        ])
     ], [], [])
 
     AC_SUBST([CLOCK_GETTIME_LIBS])