diff --git a/js/src/old-configure.in b/js/src/old-configure.in index f0e88431754c..b1a75c8cd3f2 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -1003,35 +1003,31 @@ dnl ======================================================== AC_CHECK_FUNCS([getc_unlocked _getc_nolock gmtime_r localtime_r pthread_getname_np pthread_get_name_np]) dnl check for clock_gettime(), the CLOCK_MONOTONIC clock -dnl avoid this on Darwin, since depending on your system config, we may think -dnl it exists but it really doesn't -case "$OS_TARGET" in -Darwin) - ;; -*) - AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC), - ac_cv_clock_monotonic, - [for libs in "" -lrt; do - _SAVE_LIBS="$LIBS" - LIBS="$LIBS $libs" - AC_TRY_LINK([#include ], - [ struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); ], - ac_cv_clock_monotonic=$libs - LIBS="$_SAVE_LIBS" - break, - ac_cv_clock_monotonic=no) - LIBS="$_SAVE_LIBS" - done]) - if test "$ac_cv_clock_monotonic" != "no"; then - HAVE_CLOCK_MONOTONIC=1 - REALTIME_LIBS=$ac_cv_clock_monotonic - AC_DEFINE(HAVE_CLOCK_MONOTONIC) - AC_SUBST(HAVE_CLOCK_MONOTONIC) - AC_SUBST_LIST(REALTIME_LIBS) - fi - ;; -esac +AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC), + ac_cv_clock_monotonic, + [for libs in "" -lrt; do + _SAVE_LIBS="$LIBS" + LIBS="$LIBS $libs" +dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET, +dnl we should or not be able to use it. To detect if we can, we need to make the +dnl availability attribute strict, so that compilation fails when the target is < 10.12. + AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS) + #include ], + [ struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); ], + ac_cv_clock_monotonic=$libs + LIBS="$_SAVE_LIBS" + break, + ac_cv_clock_monotonic=no) + LIBS="$_SAVE_LIBS" + done]) +if test "$ac_cv_clock_monotonic" != "no"; then + HAVE_CLOCK_MONOTONIC=1 + REALTIME_LIBS=$ac_cv_clock_monotonic + AC_DEFINE(HAVE_CLOCK_MONOTONIC) + AC_SUBST(HAVE_CLOCK_MONOTONIC) + AC_SUBST_LIST(REALTIME_LIBS) +fi dnl Checks for math functions. dnl ======================================================== diff --git a/old-configure.in b/old-configure.in index 1db63f3ef188..e7283611b92e 100644 --- a/old-configure.in +++ b/old-configure.in @@ -1278,35 +1278,31 @@ dnl ======================================================== AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall) dnl check for clock_gettime(), the CLOCK_MONOTONIC clock -dnl avoid this on Darwin, since depending on your system config, we may think -dnl it exists but it really doesn't -case "$OS_TARGET" in -Darwin) - ;; -*) - AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC), - ac_cv_clock_monotonic, - [for libs in "" -lrt; do - _SAVE_LIBS="$LIBS" - LIBS="$LIBS $libs" - AC_TRY_LINK([#include ], - [ struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); ], - ac_cv_clock_monotonic=$libs - LIBS="$_SAVE_LIBS" - break, - ac_cv_clock_monotonic=no) - LIBS="$_SAVE_LIBS" - done]) - if test "$ac_cv_clock_monotonic" != "no"; then - HAVE_CLOCK_MONOTONIC=1 - REALTIME_LIBS=$ac_cv_clock_monotonic - AC_DEFINE(HAVE_CLOCK_MONOTONIC) - AC_SUBST(HAVE_CLOCK_MONOTONIC) - AC_SUBST_LIST(REALTIME_LIBS) - fi - ;; -esac +AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC), + ac_cv_clock_monotonic, + [for libs in "" -lrt; do + _SAVE_LIBS="$LIBS" + LIBS="$LIBS $libs" +dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET, +dnl we should or not be able to use it. To detect if we can, we need to make the +dnl availability attribute strict, so that compilation fails when the target is < 10.12. + AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS) + #include ], + [ struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); ], + ac_cv_clock_monotonic=$libs + LIBS="$_SAVE_LIBS" + break, + ac_cv_clock_monotonic=no) + LIBS="$_SAVE_LIBS" + done]) +if test "$ac_cv_clock_monotonic" != "no"; then + HAVE_CLOCK_MONOTONIC=1 + REALTIME_LIBS=$ac_cv_clock_monotonic + AC_DEFINE(HAVE_CLOCK_MONOTONIC) + AC_SUBST(HAVE_CLOCK_MONOTONIC) + AC_SUBST_LIST(REALTIME_LIBS) +fi dnl Turn on warnings-as-errors to prevent implicit declaration of dnl pthread_cond_timedwait_monotonic_np, which can cause this test to