Skip to content

Commit 81fe2e0

Browse files
committed
Simplify ptrdiff_t and intmax_t checks
1 parent 54785a5 commit 81fe2e0

File tree

2 files changed

+11
-24
lines changed

2 files changed

+11
-24
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,13 @@ if(SIZEOF_INT STREQUAL "")
172172
set(SIZEOF_INT_CODE "#define SIZEOF_INT 0")
173173
endif()
174174

175-
# TODO: PHP on Windows sets the SIZEOF_INTMAX_T to 0 to skip certain checks,
176-
# otherwise the intmax_t type and its size are available. Windows-related C code
177-
# should probably be rechecked and fixed at some point.
178-
check_type_size("intmax_t" SIZEOF_INTMAX_T)
179-
if(SIZEOF_INTMAX_T STREQUAL "" OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
175+
# The intmax_t is always available by C99 standard and its size varies between
176+
# 32-bit and 64-bit target platforms. PHP on Windows sets SIZEOF_INTMAX_T to 0,
177+
# otherwise the type and its size are available on Windows.
178+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
180179
set(SIZEOF_INTMAX_T_CODE "#define SIZEOF_INTMAX_T 0")
180+
else()
181+
check_type_size("intmax_t" SIZEOF_INTMAX_T)
181182
endif()
182183

183184
check_type_size("long" SIZEOF_LONG)
@@ -195,25 +196,11 @@ if(SIZEOF_OFF_T STREQUAL "")
195196
set(SIZEOF_OFF_T_CODE "#define SIZEOF_OFF_T 0")
196197
endif()
197198

198-
# TODO: The ptrdiff_t is always available by C89 standard and its size varies
199-
# between 32-bit and 64-bit target platforms. Checking whether the ptrdiff_t
200-
# exists is redundant and is left here as PHP still checks it conditionally in
201-
# the intl extension.
199+
# The ptrdiff_t is always available by C89 standard and its size varies between
200+
# 32-bit and 64-bit target platforms. Checking whether the ptrdiff_t exists is
201+
# redundant and is left here as PHP still checks it conditionally in the intl
202+
# extension and main/s{n,p}printf.{c,h}.
202203
check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T)
203-
if(SIZEOF_PTRDIFF_T STREQUAL "")
204-
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
205-
set(SIZEOF_PTRDIFF_T 4)
206-
else()
207-
set(SIZEOF_PTRDIFF_T 8)
208-
endif()
209-
set(SIZEOF_PTRDIFF_T_CODE "#define SIZEOF_PTRDIFF_T ${SIZEOF_PTRDIFF_T}")
210-
211-
message(
212-
WARNING
213-
"Couldn't determine the ptrdiff_t size, setting it to ${SIZEOF_PTRDIFF_T}."
214-
)
215-
endif()
216-
set(HAVE_PTRDIFF_T TRUE)
217204

218205
check_type_size("size_t" SIZEOF_SIZE_T)
219206
if(SIZEOF_SIZE_T STREQUAL "")

cmake/main/cmake/php_config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
#cmakedefine HAVE_PTHREAD_JIT_WRITE_PROTECT_NP 1
321321

322322
/* Define to 1 if the system has the type 'ptrdiff_t'. */
323-
#cmakedefine HAVE_PTRDIFF_T 1
323+
#define HAVE_PTRDIFF_T 1
324324

325325
/* Define to 1 if you have the <pty.h> header file. */
326326
#cmakedefine HAVE_PTY_H 1

0 commit comments

Comments
 (0)