@@ -61,7 +61,13 @@ else()
6161 message (CHECK_FAIL "no" )
6262endif ()
6363
64- block(PROPAGATE zend_fibers_asm_file zend_fibers_asm_sources)
64+ block()
65+ set (cpu "" )
66+ set (asmFile "" )
67+ set (prefix "" )
68+ set (compileOptions "" )
69+ set (compileDefinitions "" )
70+
6571 # Determine files based on the architecture and platform.
6672 if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$" )
6773 set (prefix "x86_64_sysv" )
@@ -87,121 +93,108 @@ block(PROPAGATE zend_fibers_asm_file zend_fibers_asm_sources)
8793 endif ()
8894
8995 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
90- set (zend_fibers_asm_file "combined_sysv_macho_gas.S" )
96+ set (asmFile "combined_sysv_macho_gas.S" )
9197 elseif (CMAKE_SYSTEM_NAME STREQUAL "AIX" )
9298 # AIX uses a different calling convention (shared with non-_CALL_ELF Linux).
9399 # The AIX assembler isn't GNU, but the file is compatible.
94- set (zend_fibers_asm_file "${prefix} _xcoff_gas.S" )
100+ set (asmFile "${prefix} _xcoff_gas.S" )
95101 elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
96102 if (NOT cpu STREQUAL "i386" )
97- set (zend_fibers_asm_file "${prefix} _elf_gas.S" )
103+ set (asmFile "${prefix} _elf_gas.S" )
98104 endif ()
99105 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
100106 if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$" )
101- set (zend_fibers_asm_file "x86_64_ms_pe_masm.asm" )
107+ set (asmFile "x86_64_ms_pe_masm.asm" )
102108 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86|i.?86.*|pentium)$" )
103- set (zend_fibers_asm_file "i386_ms_pe_masm.asm" )
109+ set (asmFile "i386_ms_pe_masm.asm" )
104110 elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$" )
105- set (zend_fibers_asm_file "arm64_aapcs_pe_armasm.asm" )
111+ set (asmFile "arm64_aapcs_pe_armasm.asm" )
106112
107113 set (
108- compile_options
114+ compileOptions
109115 /nologo
110116 # TODO: Recheck; "-machine" is a linker option.
111117 -machine ARM64
112118 )
113119 endif ()
114120
115- if (
116- zend_fibers_asm_file
117- AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$"
118- )
119- set (
120- compile_options
121- /nologo
122- )
121+ if (asmFile AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$" )
122+ set (compileOptions /nologo)
123123
124- set (
125- compile_definitions
126- "BOOST_CONTEXT_EXPORT=EXPORT"
127- )
124+ set (compileDefinitions "BOOST_CONTEXT_EXPORT=EXPORT" )
128125 endif ()
129126 elseif (prefix )
130- set (zend_fibers_asm_file "${prefix} _elf_gas.S" )
127+ set (asmFile "${prefix} _elf_gas.S" )
131128 endif ()
132129
133- if (zend_fibers_asm_file )
130+ if (asmFile )
134131 set (
135- zend_fibers_asm_sources
136- ${CMAKE_CURRENT_SOURCE_DIR} /asm/jump_${zend_fibers_asm_file }
137- ${CMAKE_CURRENT_SOURCE_DIR} /asm/make_${zend_fibers_asm_file }
132+ asmSources
133+ ${CMAKE_CURRENT_SOURCE_DIR} /asm/jump_${asmFile }
134+ ${CMAKE_CURRENT_SOURCE_DIR} /asm/make_${asmFile }
138135 )
139136
140- if (compile_options )
137+ if (compileOptions )
141138 set_source_files_properties (
142- ${zend_fibers_asm_sources }
139+ ${asmSources }
143140 PROPERTIES
144- COMPILE_OPTIONS ${compile_options }
141+ COMPILE_OPTIONS ${compileOptions }
145142 )
146143 endif ()
147144
148- if (compile_definitions )
145+ if (compileDefinitions )
149146 set_source_files_properties (
150- ${zend_fibers_asm_sources }
147+ ${asmSources }
151148 PROPERTIES
152- COMPILE_DEFINITIONS ${compile_definitions }
149+ COMPILE_DEFINITIONS ${compileDefinitions }
153150 )
154151 endif ()
155152 endif ()
156- endblock()
157153
158- message (CHECK_START "Checking for fibers switching context support" )
154+ message (CHECK_START "Checking for fibers switching context support" )
159155
160- if (ZEND_FIBER_ASM AND zend_fibers_asm_file )
161- message (CHECK_PASS "yes, Zend/asm/*.${zend_fibers_asm_file } " )
156+ if (ZEND_FIBER_ASM AND asmFile )
157+ message (CHECK_PASS "yes, Zend/asm/*.${asmFile } " )
162158
163- target_sources (
164- zend_fibers
165- INTERFACE
166- ${zend_fibers_asm_sources}
167- )
159+ target_sources (zend_fibers INTERFACE ${asmSources} )
168160
169- # Use compile definitions because ASM files can't see macro definitions from
170- # the PHP configuration header (php_config.h/config.w32.h).
171- target_compile_definitions (
172- zend_fibers
173- INTERFACE
174- $<IF:$<BOOL :${SHADOW_STACK_SYSCALL} >,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
175- )
176- else ()
177- cmake_push_check_state(RESET)
178- # To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
179- # value. POSIX marked ucontext functions as obsolete and on macOS the
180- # ucontext.h functions are deprecated. At the time of writing no solution is
181- # on the horizon yet. Here, the _XOPEN_SOURCE is defined to empty value to
182- # enable proper X/Open symbols yet still to not enable some of the Single
183- # Unix specification definitions (values 500 or greater where the PHP
184- # thread-safe build would fail).
185- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
186- set (CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE)
187-
188- set_property (
189- SOURCE ${CMAKE_CURRENT_SOURCE_DIR} /zend_fibers.c
190- APPEND
191- PROPERTY
192- COMPILE_DEFINITIONS _XOPEN_SOURCE
161+ # Use compile definitions because ASM files can't see macro definitions from
162+ # the PHP configuration header (php_config.h/config.w32.h).
163+ target_compile_definitions (
164+ zend_fibers
165+ INTERFACE
166+ $<IF:$<BOOL :${SHADOW_STACK_SYSCALL} >,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
167+ )
168+ else ()
169+ cmake_push_check_state(RESET)
170+ # To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
171+ # value. POSIX marked ucontext functions as obsolete and on macOS the
172+ # ucontext.h functions are deprecated. At the time of writing no solution is
173+ # on the horizon yet. Here, the _XOPEN_SOURCE is defined to empty value to
174+ # enable proper X/Open symbols yet still to not enable some of the Single
175+ # Unix specification definitions (values 500 or greater where the PHP
176+ # thread-safe build would fail).
177+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
178+ set (CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE)
179+
180+ set_property (
181+ SOURCE ${CMAKE_CURRENT_SOURCE_DIR} /zend_fibers.c
182+ APPEND
183+ PROPERTY
184+ COMPILE_DEFINITIONS _XOPEN_SOURCE
185+ )
186+ endif ()
187+
188+ check_include_file(ucontext.h ZEND_FIBER_UCONTEXT)
189+ cmake_pop_check_state()
190+
191+ if (NOT ZEND_FIBER_UCONTEXT)
192+ message (CHECK_FAIL "no" )
193+ message (
194+ FATAL_ERROR
195+ "Fibers are not available on this platform, ucontext.h not found"
193196 )
194197 endif ()
195-
196- check_include_file(ucontext.h ZEND_FIBER_UCONTEXT)
197- cmake_pop_check_state()
198-
199- if (NOT ZEND_FIBER_UCONTEXT)
200- message (CHECK_FAIL "no" )
201- message (
202- FATAL_ERROR
203- "Fibers are not available on this platform, ucontext.h not found"
204- )
198+ message (CHECK_PASS "yes, ucontext" )
205199 endif ()
206- message (CHECK_PASS "yes, ucontext" )
207- endif ()
200+ endblock()
0 commit comments