Skip to content

Commit c9b25c0

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 6b8eb13 + a0a0057 commit c9b25c0

File tree

7 files changed

+146
-281
lines changed

7 files changed

+146
-281
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ check_symbol_exists(strlcpy string.h HAVE_STRLCPY)
394394
check_symbol_exists(explicit_bzero string.h HAVE_EXPLICIT_BZERO)
395395

396396
# Check reentrant functions.
397-
include(PHP/CheckReentrantFunctions)
397+
include(${CMAKE_CURRENT_LIST_DIR}/checks/CheckReentrantFunctions.cmake)
398398

399399
# Check fopencookie.
400400
include(PHP/CheckFopencookie)
@@ -418,9 +418,6 @@ endif()
418418
# Check copy_file_range().
419419
include(PHP/CheckCopyFileRange)
420420

421-
# Check type of reentrant time-related functions.
422-
include(PHP/CheckTimeR)
423-
424421
# Check whether writing to stdout works.
425422
include(PHP/CheckWrite)
426423

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#[=============================================================================[
2+
Check for reentrant functions and their declarations.
3+
4+
Some systems didn't declare some reentrant functions if '_REENTRANT' or
5+
'_POSIX_C_SOURCE' was not defined (certain versions of mingw etc.). This is
6+
mostly obsolete. The CMake's 'check_symbol_exists()' is sufficient to check for
7+
reentrant functions on current systems and this check might be obsolete in the
8+
future.
9+
10+
Result variables:
11+
12+
* HAVE_ASCTIME_R - Whether asctime_r() is available.
13+
* HAVE_CTIME_R - Whether ctime_r() is available.
14+
* HAVE_GMTIME_R - Whether gmtime_r() is available.
15+
* HAVE_LOCALTIME_R - Whether localtime_r() is available.
16+
* HAVE_STRTOK_R - Whether strtok_r() is available.
17+
* MISSING_ASCTIME_R_DECL - Whether asctime_r() is not declared.
18+
* MISSING_CTIME_R_DECL - Whether ctime_r() is not declared.
19+
* MISSING_GMTIME_R_DECL - Whether gmtime_r() is not declared.
20+
* MISSING_LOCALTIME_R_DECL - Whether localtime_r() is not declared.
21+
* MISSING_STRTOK_R_DECL - Whether `strtok_r()` is not declared.
22+
23+
Also the type of reentrant time-related functions are checked. Type can be irix,
24+
hpux or POSIX. This check is obsolete as it is relevant for obsolete systems.
25+
26+
Cache variables:
27+
28+
* PHP_HPUX_TIME_R - Whether HP-UX 10.x is used.
29+
* PHP_IRIX_TIME_R - Whether IRIX-style functions are used.
30+
#]=============================================================================]
31+
32+
include_guard(GLOBAL)
33+
34+
include(CheckFunctionExists)
35+
include(CheckSourceRuns)
36+
include(CheckSymbolExists)
37+
38+
# Define HAVE_<symbol> if linker sees the function, and MISSING_<symbol>_DECL if
39+
# function is not declared by checking the required header and test body.
40+
function(_php_check_reentrant_function symbol header)
41+
string(TOUPPER "${symbol}" const)
42+
43+
set(HAVE_${const} FALSE)
44+
set(MISSING_${const}_DECL TRUE)
45+
46+
# Reentrant functions checked in this module aren't available on Windows.
47+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
48+
return(PROPAGATE HAVE_${const} MISSING_${const}_DECL)
49+
endif()
50+
51+
check_symbol_exists(${symbol} "${header}" PHP_HAS_${const})
52+
53+
if(PHP_HAS_${const})
54+
set(HAVE_${const} TRUE)
55+
set(MISSING_${const}_DECL FALSE)
56+
57+
return(PROPAGATE HAVE_${const} MISSING_${const}_DECL)
58+
endif()
59+
60+
check_function_exists(${symbol} PHP_HAS_FUNCTION_${const})
61+
62+
if(PHP_HAS_FUNCTION_${const})
63+
set(HAVE_${const} TRUE)
64+
65+
return(PROPAGATE HAVE_${const} MISSING_${const}_DECL)
66+
endif()
67+
68+
return(PROPAGATE HAVE_${const} MISSING_${const}_DECL)
69+
endfunction()
70+
71+
_php_check_reentrant_function(asctime_r time.h)
72+
_php_check_reentrant_function(ctime_r time.h)
73+
_php_check_reentrant_function(gmtime_r time.h)
74+
_php_check_reentrant_function(localtime_r time.h)
75+
_php_check_reentrant_function(strtok_r string.h)
76+
77+
################################################################################
78+
# Check type of reentrant time-related functions.
79+
################################################################################
80+
81+
if(NOT HAVE_ASCTIME_R OR NOT HAVE_GMTIME_R)
82+
return()
83+
endif()
84+
85+
# Skip in consecutive configuration phases.
86+
if(DEFINED PHP_HPUX_TIME_R OR DEFINED PHP_IRIX_TIME_R)
87+
return()
88+
endif()
89+
90+
# When cross-compiling, assume POSIX style.
91+
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR)
92+
set(PHP_HPUX_TIME_R_EXITCODE 1)
93+
set(PHP_IRIX_TIME_R_EXITCODE 1)
94+
endif()
95+
96+
message(CHECK_START "Checking type of reentrant time-related functions")
97+
98+
check_source_runs(C [[
99+
#include <time.h>
100+
101+
int main(void)
102+
{
103+
char buf[27];
104+
struct tm t;
105+
time_t old = 0;
106+
int r, s;
107+
108+
s = gmtime_r(&old, &t);
109+
r = (int) asctime_r(&t, buf, 26);
110+
if (r == s && s == 0) {
111+
return 0;
112+
}
113+
114+
return 1;
115+
}
116+
]] PHP_HPUX_TIME_R)
117+
118+
if(NOT PHP_HPUX_TIME_R)
119+
check_source_runs(C [[
120+
#include <time.h>
121+
122+
int main(void)
123+
{
124+
struct tm t, *s;
125+
time_t old = 0;
126+
char buf[27], *p;
127+
128+
s = gmtime_r(&old, &t);
129+
p = asctime_r(&t, buf, 26);
130+
if (p == buf && s == &t) {
131+
return 0;
132+
}
133+
134+
return 1;
135+
}
136+
]] PHP_IRIX_TIME_R)
137+
endif()
138+
139+
if(PHP_HPUX_TIME_R)
140+
message(CHECK_PASS "HP-UX")
141+
elseif(PHP_IRIX_TIME_R)
142+
message(CHECK_PASS "IRIX")
143+
else()
144+
message(CHECK_PASS "POSIX")
145+
endif()

cmake/cmake/modules/PHP/CheckReentrantFunctions.cmake

Lines changed: 0 additions & 106 deletions
This file was deleted.

cmake/cmake/modules/PHP/CheckTimeR.cmake

Lines changed: 0 additions & 79 deletions
This file was deleted.

cmake/cmake/toolchains/template.cmake

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ set(PHP_HAS_MAX_PAGE_SIZE_CXX_EXITCODE 0)
3333
# needs to be added for the PHP_UNDEFINED_SANITIZER option, otherwise set to 0.
3434
set(PHP_HAS_UBSAN_EXITCODE 0)
3535

36-
# Set the exit code for the check of reentrant time-related functions being
37-
# HP-UX style.
38-
set(PHP_HPUX_TIME_R_EXITCODE 1)
39-
40-
# Set the exit code for the check of reentrant time-related functions being IRIX
41-
# style.
42-
set(PHP_IRIX_TIME_R_EXITCODE 1)
43-
4436
# Set the exit code for the writing to stdout check.
4537
set(PHP_WRITE_STDOUT_EXITCODE 0)
4638

0 commit comments

Comments
 (0)