Skip to content

Simplify clock_gettime Autoconf check #13537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 5 additions & 30 deletions sapi/fpm/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,14 @@ PHP_ARG_ENABLE([fpm],,
dnl Configure checks.
AC_DEFUN([AC_FPM_CLOCK],
[
have_clock_gettime=no

AC_MSG_CHECKING([for clock_gettime])

AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);]])], [
have_clock_gettime=yes
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])

if test "$have_clock_gettime" = "no"; then
AC_MSG_CHECKING([for clock_gettime in -lrt])

SAVED_LIBS="$LIBS"
LIBS="$LIBS -lrt"

AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);]])], [
have_clock_gettime=yes
AC_MSG_RESULT([yes])
], [
LIBS="$SAVED_LIBS"
AC_MSG_RESULT([no])
])
fi

if test "$have_clock_gettime" = "yes"; then
AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [do we have clock_gettime?])
fi
AC_CHECK_FUNCS([clock_gettime],,
[AC_SEARCH_LIBS([clock_gettime], [rt],
[ac_cv_func_clock_gettime=yes
AC_DEFINE([HAVE_CLOCK_GETTIME], [1])])])

have_clock_get_time=no

if test "$have_clock_gettime" = "no"; then
if test "$ac_cv_func_clock_gettime" = "no"; then
AC_MSG_CHECKING([for clock_get_time])

AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <mach/mach.h>
Expand Down