Skip to content

Commit d028366

Browse files
committed
Sync type size checks between platforms
1 parent 80b00ef commit d028366

File tree

2 files changed

+60
-58
lines changed

2 files changed

+60
-58
lines changed

cmake/cmake/ConfigureChecks.cmake

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -135,31 +135,6 @@ cmake_pop_check_state()
135135
# Check types.
136136
################################################################################
137137

138-
check_type_size("int" SIZEOF_INT)
139-
if(NOT SIZEOF_INT)
140-
message(FATAL_ERROR "Cannot determine size of int.")
141-
endif()
142-
143-
check_type_size("long" SIZEOF_LONG)
144-
if(NOT SIZEOF_LONG)
145-
message(FATAL_ERROR "Cannot determine size of long.")
146-
endif()
147-
148-
check_type_size("long long" SIZEOF_LONG_LONG)
149-
if(NOT SIZEOF_LONG_LONG)
150-
message(FATAL_ERROR "Cannot determine size of long long.")
151-
endif()
152-
153-
check_type_size("size_t" SIZEOF_SIZE_T)
154-
if(NOT HAVE_SIZEOF_SIZE_T)
155-
message(FATAL_ERROR "Cannot determine size of size_t.")
156-
endif()
157-
158-
check_type_size("off_t" SIZEOF_OFF_T)
159-
if(NOT SIZEOF_OFF_T)
160-
message(FATAL_ERROR "Cannot determine size of off_t.")
161-
endif()
162-
163138
check_type_size("gid_t" SIZEOF_GID_T)
164139
if(NOT HAVE_SIZEOF_GID_T)
165140
set(
@@ -168,31 +143,46 @@ if(NOT HAVE_SIZEOF_GID_T)
168143
)
169144
endif()
170145

171-
check_type_size("uid_t" SIZEOF_UID_T)
172-
if(NOT HAVE_SIZEOF_UID_T)
173-
set(
174-
uid_t int
175-
CACHE INTERNAL "Define as 'int' if <sys/types.h> doesn't define."
176-
)
177-
endif()
146+
check_type_size("int" SIZEOF_INT)
178147

179148
check_type_size("intmax_t" SIZEOF_INTMAX_T)
180149
if(NOT SIZEOF_INTMAX_T)
181150
set(SIZEOF_INTMAX_T 0 CACHE INTERNAL "Size of intmax_t")
182151
message(WARNING "Couldn't determine size of intmax_t, setting to 0.")
152+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
153+
# PHP on Windows sets the SIZEOF_INTMAX_T to 0 to skip certain checks,
154+
# otherwise intmax_t and its size is available.
155+
set(SIZEOF_INTMAX_T 0 CACHE INTERNAL "Size of intmax_t")
183156
endif()
184157

185-
check_type_size("ssize_t" SIZEOF_SSIZE_T)
186-
if(NOT SIZEOF_SSIZE_T)
187-
set(SIZEOF_SSIZE_T 8 CACHE INTERNAL "Size of ssize_t")
188-
message(WARNING "Couldn't determine size of ssize_t, setting to 8.")
189-
endif()
158+
check_type_size("long" SIZEOF_LONG)
159+
check_type_size("long long" SIZEOF_LONG_LONG)
160+
check_type_size("off_t" SIZEOF_OFF_T)
190161

191162
check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T)
192163
set(HAVE_PTRDIFF_T 1 CACHE INTERNAL "Whether ptrdiff_t is available")
193164
if(NOT SIZEOF_PTRDIFF_T)
194-
set(SIZEOF_PTRDIFF_T 8 CACHE INTERNAL "Size of ptrdiff_t")
195-
message(WARNING "Couldn't determine size of ptrdiff_t, setting to 8.")
165+
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
166+
set(SIZEOF_PTRDIFF_T 4 CACHE INTERNAL "Size of ptrdiff_t")
167+
else
168+
set(SIZEOF_PTRDIFF_T 8 CACHE INTERNAL "Size of ptrdiff_t")
169+
endif()
170+
171+
message(
172+
WARNING
173+
"Couldn't determine the ptrdiff_t size, setting it to ${SIZEOF_PTRDIFF_T}."
174+
)
175+
endif()
176+
177+
check_type_size("size_t" SIZEOF_SIZE_T)
178+
check_type_size("ssize_t" SIZEOF_SSIZE_T)
179+
180+
check_type_size("uid_t" SIZEOF_UID_T)
181+
if(NOT HAVE_SIZEOF_UID_T)
182+
set(
183+
uid_t int
184+
CACHE INTERNAL "Define as 'int' if <sys/types.h> doesn't define."
185+
)
196186
endif()
197187

198188
# Check for socklen_t type.

cmake/main/config.w32.cmake.h.in

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
# define _USE_32BIT_TIME_T 1
1818
#endif
1919

20+
/* On Windows the ssize_t is not available, but there is SSIZE_T defined in
21+
<BaseTsd.h>. */
22+
#define ssize_t SSIZE_T
23+
24+
#define STDIN_FILENO 0
25+
#define STDOUT_FILENO 1
26+
#define STDERR_FILENO 2
27+
2028
/* Define to 1 if the system has the type 'struct cmsgcred'. */
2129
#cmakedefine ANC_CREDS_CMSGCRED 1
2230

@@ -1983,32 +1991,36 @@
19831991
/* The QDBM handler header file. */
19841992
#cmakedefine QDBM_INCLUDE_FILE "@QDBM_INCLUDE_FILE@"
19851993

1986-
/* int and long are still 32bit in 64bit compiles */
1987-
#define SIZEOF_INT 4
1988-
#define SIZEOF_LONG 4
1989-
/* MSVC.6/NET don't allow 'long long' or know 'intmax_t' */
1990-
#define SIZEOF_LONG_LONG 8 /* defined as __int64 */
1991-
#define SIZEOF_INTMAX_T 0
1992-
#define ssize_t SSIZE_T
1993-
#ifdef _WIN64
1994-
# define SIZEOF_SIZE_T 8
1995-
# define SIZEOF_PTRDIFF_T 8
1996-
#else
1997-
# define SIZEOF_SIZE_T 4
1998-
# define SIZEOF_PTRDIFF_T 4
1999-
#endif
2000-
#define SIZEOF_OFF_T 4
1994+
/* The size of 'int', as computed by sizeof. */
1995+
#cmakedefine SIZEOF_INT @SIZEOF_INT@
1996+
1997+
/* The size of 'intmax_t', as computed by sizeof. */
1998+
#cmakedefine SIZEOF_INTMAX_T @SIZEOF_INTMAX_T@
1999+
2000+
/* The size of 'long', as computed by sizeof. */
2001+
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
2002+
2003+
/* The size of 'long long', as computed by sizeof. */
2004+
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
2005+
2006+
/* The size of 'off_t', as computed by sizeof. */
2007+
#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
2008+
2009+
/* The size of 'ptrdiff_t', as computed by sizeof. */
2010+
#cmakedefine SIZEOF_PTRDIFF_T @SIZEOF_PTRDIFF_T@
2011+
2012+
/* The size of 'size_t', as computed by sizeof. */
2013+
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
2014+
2015+
/* The size of 'ssize_t', as computed by sizeof. */
2016+
#cmakedefine SIZEOF_SSIZE_T @SIZEOF_SSIZE_T@
20012017

20022018
/* Define to 1 if SQLite library was compiled with the
20032019
SQLITE_OMIT_LOAD_EXTENSION and does not have the extension support with the
20042020
'sqlite3_load_extension' function. For usage in the sqlite3 PHP extension.
20052021
See https://www.sqlite.org/compile.html. */
20062022
#cmakedefine SQLITE_OMIT_LOAD_EXTENSION 1
20072023

2008-
#define STDIN_FILENO 0
2009-
#define STDOUT_FILENO 1
2010-
#define STDERR_FILENO 2
2011-
20122024
/* Define to 1 to be able to use the wchar defs in the obsolete <sqlunix.h>
20132025
header file on some FreeBSD systems. */
20142026
#cmakedefine SS_FBX 1

0 commit comments

Comments
 (0)