@@ -142,38 +142,62 @@ if(NOT HAVE_SIZEOF_GID_T)
142142endif ()
143143
144144check_type_size("int" SIZEOF_INT)
145+ if (SIZEOF_INT STREQUAL "" )
146+ set (SIZEOF_INT_CODE "#define SIZEOF_INT 0" )
147+ endif ()
145148
149+ # TODO: PHP on Windows sets the SIZEOF_INTMAX_T to 0 to skip certain checks,
150+ # otherwise the intmax_t type and its size are available. Windows-related C code
151+ # should probably be rechecked and fixed at some point.
146152check_type_size("intmax_t" SIZEOF_INTMAX_T)
147- if (NOT SIZEOF_INTMAX_T)
148- set (SIZEOF_INTMAX_T 0 CACHE INTERNAL "Size of intmax_t" )
149- message (WARNING "Couldn't determine size of intmax_t, setting to 0." )
150- elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
151- # PHP on Windows sets the SIZEOF_INTMAX_T to 0 to skip certain checks,
152- # otherwise intmax_t and its size is available.
153- set (SIZEOF_INTMAX_T 0 CACHE INTERNAL "Size of intmax_t" )
153+ if (SIZEOF_INTMAX_T STREQUAL "" OR CMAKE_SYSTEM_NAME STREQUAL "Windows" )
154+ set (SIZEOF_INTMAX_T_CODE "#define SIZEOF_INTMAX_T 0" )
154155endif ()
155156
156157check_type_size("long" SIZEOF_LONG)
158+ if (SIZEOF_LONG STREQUAL "" )
159+ set (SIZEOF_LONG_CODE "#define SIZEOF_LONG 0" )
160+ endif ()
161+
157162check_type_size("long long" SIZEOF_LONG_LONG)
163+ if (SIZEOF_LONG_LONG STREQUAL "" )
164+ set (SIZEOF_LONG_LONG_CODE "#define SIZEOF_LONG_LONG 0" )
165+ endif ()
166+
158167check_type_size("off_t" SIZEOF_OFF_T)
168+ if (SIZEOF_OFF_T STREQUAL "" )
169+ set (SIZEOF_OFF_T_CODE "#define SIZEOF_OFF_T 0" )
170+ endif ()
159171
172+ # TODO: The ptrdiff_t is always available by C89 standard and its size varies
173+ # between 32-bit and 64-bit target platforms. Checking whether the ptrdiff_t
174+ # exists is redundant and is left here as PHP still checks it conditionally in
175+ # the intl extension.
160176check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T)
161- set (HAVE_PTRDIFF_T 1 CACHE INTERNAL "Whether ptrdiff_t is available" )
162- if (NOT SIZEOF_PTRDIFF_T)
177+ if (SIZEOF_PTRDIFF_T STREQUAL "" )
163178 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
164- set (SIZEOF_PTRDIFF_T 4 CACHE INTERNAL "Size of ptrdiff_t" )
179+ set (SIZEOF_PTRDIFF_T 4)
165180 else ()
166- set (SIZEOF_PTRDIFF_T 8 CACHE INTERNAL "Size of ptrdiff_t" )
181+ set (SIZEOF_PTRDIFF_T 8)
167182 endif ()
183+ set (SIZEOF_PTRDIFF_T_CODE "#define SIZEOF_PTRDIFF_T ${SIZEOF_PTRDIFF_T} " )
168184
169185 message (
170186 WARNING
171187 "Couldn't determine the ptrdiff_t size, setting it to ${SIZEOF_PTRDIFF_T} ."
172188 )
173189endif ()
190+ set (HAVE_PTRDIFF_T 1)
174191
175192check_type_size("size_t" SIZEOF_SIZE_T)
193+ if (SIZEOF_SIZE_T STREQUAL "" )
194+ set (SIZEOF_SIZE_T_CODE "#define SIZEOF_SIZE_T 0" )
195+ endif ()
196+
176197check_type_size("ssize_t" SIZEOF_SSIZE_T)
198+ if (SIZEOF_SSIZE_T STREQUAL "" )
199+ set (SIZEOF_SSIZE_T_CODE "#define SIZEOF_SSIZE_T 0" )
200+ endif ()
177201
178202check_type_size("uid_t" SIZEOF_UID_T)
179203if (NOT HAVE_SIZEOF_UID_T)
@@ -188,10 +212,7 @@ cmake_push_check_state(RESET)
188212 if (HAVE_SYS_SOCKET_H)
189213 set (CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
190214 endif ()
191- check_type_size("socklen_t" SIZEOF_SOCKLEN_T)
192- if (HAVE_SIZEOF_SOCKLEN_T)
193- set (HAVE_SOCKLEN_T 1 CACHE INTERNAL "Whether the system has the type 'socklen_t'." )
194- endif ()
215+ check_type_size("socklen_t" SOCKLEN_T)
195216cmake_pop_check_state()
196217
197218################################################################################
0 commit comments