Skip to content

Commit 028cfda

Browse files
authored
Wrap clock_get_time check in AC_CACHE_CHECK (#14434)
The php_cv_func_clock_get_time cache variable enables cross-compiling edge cases to manually override the AC_RUN_IFELSE check.
1 parent d2a932b commit 028cfda

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

sapi/fpm/config.m4

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ PHP_ARG_ENABLE([fpm],,
66

77
dnl Configure checks.
88
AC_DEFUN([AC_FPM_CLOCK],
9-
[
10-
AC_CHECK_FUNCS([clock_gettime],,
11-
[AC_SEARCH_LIBS([clock_gettime], [rt],
12-
[ac_cv_func_clock_gettime=yes
13-
AC_DEFINE([HAVE_CLOCK_GETTIME], [1])])])
14-
15-
have_clock_get_time=no
16-
17-
if test "$ac_cv_func_clock_gettime" = "no"; then
18-
AC_MSG_CHECKING([for clock_get_time])
19-
20-
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <mach/mach.h>
9+
[AC_CHECK_FUNCS([clock_gettime],,
10+
[AC_SEARCH_LIBS([clock_gettime], [rt],
11+
[ac_cv_func_clock_gettime=yes
12+
AC_DEFINE([HAVE_CLOCK_GETTIME], [1])])])
13+
14+
AS_VAR_IF([ac_cv_func_clock_gettime], [no],
15+
[AC_CACHE_CHECK([for clock_get_time], [php_cv_func_clock_get_time],
16+
[AC_RUN_IFELSE([AC_LANG_SOURCE([
17+
#include <mach/mach.h>
2118
#include <mach/clock.h>
2219
#include <mach/mach_error.h>
2320
@@ -37,18 +34,14 @@ AC_DEFUN([AC_FPM_CLOCK],
3734
3835
return 0;
3936
}
40-
]])], [
41-
have_clock_get_time=yes
42-
AC_MSG_RESULT([yes])
43-
], [
44-
AC_MSG_RESULT([no])
45-
], [AC_MSG_RESULT([no (cross-compiling)])])
46-
fi
47-
48-
if test "$have_clock_get_time" = "yes"; then
49-
AC_DEFINE([HAVE_CLOCK_GET_TIME], 1, [do we have clock_get_time?])
50-
fi
51-
])
37+
])],
38+
[php_cv_func_clock_get_time=yes],
39+
[php_cv_func_clock_get_time=no],
40+
[php_cv_func_clock_get_time=no])])
41+
AS_VAR_IF([php_cv_func_clock_get_time], [yes],
42+
[AC_DEFINE([HAVE_CLOCK_GET_TIME], [1],
43+
[Define to 1 if you have the 'clock_get_time' function.])])
44+
])])
5245

5346
AC_DEFUN([AC_FPM_TRACE],
5447
[

0 commit comments

Comments
 (0)