Skip to content

Commit 22c3143

Browse files
committed
Fix nits
- Refactor some Zend checks. - Fixed the segments alignment check - it is only for Linux and those matches processors.
1 parent 375c975 commit 22c3143

10 files changed

+119
-161
lines changed

cmake/Zend/cmake/CheckDlsym.cmake

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
#[=============================================================================[
2-
# CheckDlsym
3-
4-
Check if `dlsym()` requires a leading underscore in symbol name.
2+
Check if dlsym() requires a leading underscore in symbol name.
53
64
Some non-ELF platforms, such as OpenBSD, FreeBSD, NetBSD, Mac OSX (~10.3),
7-
needed underscore character (`_`) prefix for symbols, when using `dlsym()`. This
5+
needed to prefix symbols with underscore character (_), when using dlsym(). This
86
module is obsolete on current platforms.
97
10-
## Cache variables
8+
Result variables:
119
12-
* `DLSYM_NEEDS_UNDERSCORE`
10+
* DLSYM_NEEDS_UNDERSCORE
1311
#]=============================================================================]
1412

1513
include_guard(GLOBAL)
1614

15+
set(DLSYM_NEEDS_UNDERSCORE FALSE)
16+
17+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
18+
return()
19+
endif()
20+
1721
# Skip in consecutive configuration phases.
18-
if(DEFINED DLSYM_NEEDS_UNDERSCORE)
22+
if(DEFINED PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE)
23+
if(PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE)
24+
set(DLSYM_NEEDS_UNDERSCORE TRUE)
25+
endif()
26+
1927
return()
2028
endif()
2129

2230
include(CheckIncludeFiles)
2331

2432
message(
2533
CHECK_START
26-
"Checking whether dlsym() requires a leading underscore in symbol names"
34+
"Checking whether dlsym() needs to prefix symbols with underscore"
2735
)
2836

37+
# When cross-compiling without emulator, assume that target platform is recent
38+
# enough so that dlsym doesn't need leading underscores.
2939
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR)
30-
# When cross-compiling without emulator, assume that target platform is recent
31-
# enough so that dlsym doesn't need leading underscores.
32-
set(DLSYM_NEEDS_UNDERSCORE_EXITCODE 0)
40+
set(PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_EXITCODE 0)
3341
endif()
3442

3543
check_include_files(dlfcn.h HAVE_DLFCN_H)
@@ -40,8 +48,8 @@ block()
4048
endif()
4149

4250
try_run(
43-
DLSYM_NEEDS_UNDERSCORE_EXITCODE
44-
DLSYM_NEEDS_UNDERSCORE_COMPILED
51+
PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_EXITCODE
52+
PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_COMPILED
4553
SOURCE_FROM_CONTENT src.c [[
4654
#ifdef HAVE_DLFCN_H
4755
# include <dlfcn.h>
@@ -116,16 +124,20 @@ block()
116124
endblock()
117125

118126
set(
119-
DLSYM_NEEDS_UNDERSCORE
127+
PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE
120128
""
121129
CACHE INTERNAL
122130
"Whether 'dlsym()' requires a leading underscore in symbol names."
123131
)
124132

125-
if(DLSYM_NEEDS_UNDERSCORE_COMPILED AND DLSYM_NEEDS_UNDERSCORE_EXITCODE EQUAL 2)
126-
set_property(CACHE DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE TRUE)
127-
message(CHECK_PASS "yes")
133+
if(
134+
PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_COMPILED
135+
AND PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE_EXITCODE EQUAL 2
136+
)
137+
set_property(CACHE PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE TRUE)
138+
set(DLSYM_NEEDS_UNDERSCORE TRUE)
139+
message(CHECK_FAIL "yes")
128140
else()
129-
set_property(CACHE DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE FALSE)
130-
message(CHECK_FAIL "no")
141+
set_property(CACHE PHP_ZEND_HAS_DLSYM_NEEDS_UNDERSCORE PROPERTY VALUE FALSE)
142+
message(CHECK_PASS "no")
131143
endif()

cmake/Zend/cmake/CheckFloatPrecision.cmake

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
11
#[=============================================================================[
2-
# CheckFloatPrecision
3-
42
Check for x87 floating point internal precision control.
53
64
See: https://wiki.php.net/rfc/rounding
75
8-
## Cache variables
9-
10-
* `HAVE__FPU_SETCW`
11-
12-
Whether `_FPU_SETCW` is present and usable.
13-
14-
* `HAVE_FPSETPREC`
15-
16-
Whether `fpsetprec` is present and usable.
17-
18-
* `HAVE__CONTROLFP`
19-
20-
Whether `_controlfp` is present and usable.
21-
22-
* `HAVE__CONTROLFP_S`
23-
24-
Whether `_controlfp_s` is present and usable.
25-
26-
* `HAVE_FPU_INLINE_ASM_X86`
27-
28-
Whether FPU control word can be manipulated by inline assembler.
29-
30-
## Usage
6+
Cache variables:
317
32-
```cmake
33-
# CMakeLists.txt
34-
include(cmake/CheckFloatPrecision.cmake)
35-
```
8+
* HAVE__FPU_SETCW - Whether _FPU_SETCW is present and usable.
9+
* HAVE_FPSETPREC - Whether fpsetprec is present and usable.
10+
* HAVE__CONTROLFP - Whether _controlfp is present and usable.
11+
* HAVE__CONTROLFP_S - Whether _controlfp_s is present and usable.
12+
* HAVE_FPU_INLINE_ASM_X86 - Whether FPU control word can be manipulated by
13+
inline assembler.
3614
#]=============================================================================]
3715

3816
include_guard(GLOBAL)

cmake/Zend/cmake/CheckGlobalRegisterVariables.cmake

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
#[=============================================================================[
2-
# CheckGlobalRegisterVariables
3-
42
Check whether the compiler and target system support global register variables.
5-
63
Global register variables are relevant for the GNU C compatible compilers.
4+
See also https://gcc.gnu.org/onlinedocs/gcc/Global-Register-Variables.html
75
8-
See also: [GCC global register variables](https://gcc.gnu.org/onlinedocs/gcc/Global-Register-Variables.html)
9-
10-
## Cache variables
11-
12-
* `HAVE_GCC_GLOBAL_REGS`
6+
Result variables:
137
14-
Whether global register variables are supported.
15-
16-
## Usage
17-
18-
```cmake
19-
# CMakeLists.txt
20-
include(cmake/CheckGlobalRegisterVariables.cmake)
21-
```
8+
* HAVE_GCC_GLOBAL_REGS - Whether global register variables are supported.
229
#]=============================================================================]
2310

2411
include_guard(GLOBAL)
2512

13+
set(HAVE_GCC_GLOBAL_REGS FALSE)
14+
2615
# Skip in consecutive configuration phases.
27-
if(DEFINED HAVE_GCC_GLOBAL_REGS)
16+
if(DEFINED PHP_ZEND_HAS_GCC_GLOBAL_REGS)
17+
if(PHP_ZEND_HAS_GCC_GLOBAL_REGS)
18+
set(HAVE_GCC_GLOBAL_REGS TRUE)
19+
endif()
2820
return()
2921
endif()
3022

@@ -83,10 +75,11 @@ cmake_push_check_state(RESET)
8375
{
8476
return 0;
8577
}
86-
]] HAVE_GCC_GLOBAL_REGS)
78+
]] PHP_ZEND_HAS_GCC_GLOBAL_REGS)
8779
cmake_pop_check_state()
8880

89-
if(HAVE_GCC_GLOBAL_REGS)
81+
if(PHP_ZEND_HAS_GCC_GLOBAL_REGS)
82+
set(HAVE_GCC_GLOBAL_REGS TRUE)
9083
message(CHECK_PASS "yes")
9184
else()
9285
message(CHECK_FAIL "no")

cmake/Zend/cmake/CheckMMAlignment.cmake

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
#[=============================================================================[
2-
# CheckMMAlignment
3-
42
Test and set the alignment defines for the Zend memory manager (`ZEND_MM`). This
53
also does the logarithmic test.
64
7-
## Result variables
8-
9-
* `ZEND_MM_ALIGNMENT`
10-
* `ZEND_MM_ALIGNMENT_LOG2`
11-
* `ZEND_MM_NEED_EIGHT_BYTE_REALIGNMENT`
12-
13-
## Usage
5+
Result variables:
146
15-
```cmake
16-
# CMakeLists.txt
17-
include(cmake/CheckMMAlignment.cmake)
18-
```
7+
* ZEND_MM_ALIGNMENT
8+
* ZEND_MM_ALIGNMENT_LOG2
9+
* ZEND_MM_NEED_EIGHT_BYTE_REALIGNMENT
1910
#]=============================================================================]
2011

2112
include_guard(GLOBAL)

cmake/Zend/cmake/CheckStackDirection.cmake

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
#[=============================================================================[
2-
# CheckStackDirection
3-
42
Check whether the stack grows downwards. Assumes contiguous stack.
53
6-
## Cache variables
7-
8-
* `ZEND_CHECK_STACK_LIMIT`
9-
10-
Whether checking the stack limit is supported.
11-
12-
## Usage
4+
Result/cache variables:
135
14-
```cmake
15-
# CMakeLists.txt
16-
include(cmake/CheckStackDirection.cmake)
17-
```
6+
* ZEND_CHECK_STACK_LIMIT - Whether checking the stack limit is supported.
187
#]=============================================================================]
198

209
include_guard(GLOBAL)
@@ -24,6 +13,11 @@ if(DEFINED ZEND_CHECK_STACK_LIMIT)
2413
return()
2514
endif()
2615

16+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
17+
set(ZEND_CHECK_STACK_LIMIT TRUE)
18+
return()
19+
endif()
20+
2721
include(CheckSourceRuns)
2822
include(CMakePushCheckState)
2923

cmake/Zend/cmake/CheckStrerrorR.cmake

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
#[=============================================================================[
2-
# CheckStrerrorR
3-
4-
Check whether `strerror_r()` is the POSIX-compatible version or the GNU-specific
2+
Check whether strerror_r() is the POSIX-compatible version or the GNU-specific
53
version.
64
7-
## Cache variables
8-
9-
* `HAVE_STRERROR_R`
10-
11-
Whether `strerror_r()` is available.
12-
13-
* `STRERROR_R_CHAR_P`
14-
15-
Whether `strerror_r()` returns a `char *` message, otherwise it returns an
16-
`int` error number.
5+
Result variables:
176
18-
## Usage
19-
20-
```cmake
21-
# CMakeLists.txt
22-
include(cmake/CheckStrerrorR.cmake)
23-
```
7+
* HAVE_STRERROR_R - Whether strerror_r() is available.
8+
* STRERROR_R_CHAR_P - Whether strerror_r() returns a 'char *' message, otherwise
9+
it returns an 'int' error number.
2410
#]=============================================================================]
2511

2612
include_guard(GLOBAL)
@@ -29,14 +15,35 @@ include(CheckSourceCompiles)
2915
include(CheckSymbolExists)
3016
include(CMakePushCheckState)
3117

32-
check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)
18+
set(HAVE_STRERROR_R FALSE)
19+
set(STRERROR_R_CHAR_P FALSE)
3320

34-
if(NOT HAVE_STRERROR_R)
21+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
3522
return()
3623
endif()
3724

25+
check_symbol_exists(strerror_r string.h PHP_ZEND_HAS_STRERROR_R)
26+
27+
if(NOT PHP_ZEND_HAS_STRERROR_R)
28+
return()
29+
endif()
30+
31+
set(HAVE_STRERROR_R TRUE)
32+
33+
# Skip in consecutive configuration phases.
34+
if(DEFINED PHP_ZEND_HAS_STRERROR_R_CHAR_P)
35+
if(PHP_ZEND_HAS_STRERROR_R_CHAR_P)
36+
set(STRERROR_R_CHAR_P TRUE)
37+
return()
38+
endif()
39+
endif()
40+
41+
message(CHECK_START "Checking strerror_r() return type")
42+
3843
cmake_push_check_state(RESET)
3944
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
45+
set(CMAKE_REQUIRED_QUIET TRUE)
46+
4047
check_source_compiles(C [[
4148
#include <string.h>
4249
@@ -47,5 +54,12 @@ cmake_push_check_state(RESET)
4754
char *p = strerror_r (0, buf, sizeof buf);
4855
return !p || x;
4956
}
50-
]] STRERROR_R_CHAR_P)
57+
]] PHP_ZEND_HAS_STRERROR_R_CHAR_P)
5158
cmake_pop_check_state()
59+
60+
if(PHP_ZEND_HAS_STRERROR_R_CHAR_P)
61+
set(STRERROR_R_CHAR_P TRUE)
62+
message(CHECK_PASS "char *")
63+
else()
64+
message(CHECK_PASS "int")
65+
endif()

cmake/Zend/cmake/Fibers.cmake

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
11
#[=============================================================================[
2-
# Fibers
3-
42
Check if Fibers can be used.
53
64
This module adds Boost fiber assembly files support if available for the
75
platform, otherwise it checks if ucontext can be used.
86
9-
## Control variables
10-
11-
* `ZEND_FIBER_ASM`
12-
13-
Whether to use Boost fiber assembly files.
7+
Control variables:
148
15-
## Cache variables
9+
* ZEND_FIBER_ASM - Whether to use Boost fiber assembly files.
1610
17-
* `ZEND_FIBER_UCONTEXT`
11+
Cache variables:
1812
19-
Whether `<ucontext.h>` header file is available and should be used.
13+
* ZEND_FIBER_UCONTEXT - Whether <ucontext.h> header file is available and should
14+
be used.
2015
21-
## Interface library
16+
Interface library:
2217
23-
* `Zend::Fibers`
18+
* Zend::Fibers
2419
2520
Interface library using Boost fiber assembly files and compile options if
2621
available.
27-
28-
## Usage
29-
30-
```cmake
31-
# CMakeLists.txt
32-
include(cmake/Fibers.cmake)
33-
```
3422
#]=============================================================================]
3523

3624
include_guard(GLOBAL)

0 commit comments

Comments
 (0)