]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Autoconf, CMake: Get the size of a void * and a time_t
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 13 Mar 2024 12:11:06 +0000 (13:11 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Thu, 14 Mar 2024 15:19:01 +0000 (16:19 +0100)
With this change we know:
whether this is a 32-bit or 64-bit build ;
whether the time_t size is 32-bit or 64-bit.

At least with CMake, the SIZEOF values could be 0, if somebody's
doing a fat build on macOS and that includes both 32-bit and 64-bit
instruction sets.

CMakeLists.txt
cmakeconfig.h.in
configure.ac

index b0e4d8f57a9fc2ec3c717bcd14ab0c2ec4b32c42..18636ba60b6e87f7fc3d7e8a5d338e713f359bf8 100644 (file)
@@ -124,6 +124,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
 #
 project(tcpdump C)
 
+#
+# Export the size of void * as SIZEOF_VOID_P so that it can be
+# tested with #if.
+#
+set(SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
+
 #
 # For checking if a compiler flag works and adding it if it does.
 #
@@ -328,6 +334,14 @@ include(CheckStructHasMember)
 include(CheckVariableExists)
 include(CheckTypeSize)
 
+#
+# Get the size of a time_t, to know whether it's 32-bit or 64-bit.
+#
+cmake_push_check_state()
+set(CMAKE_EXTRA_INCLUDE_FILES time.h)
+check_type_size("time_t" SIZEOF_TIME_T)
+cmake_pop_check_state()
+
 #
 # Header files.
 #
index 98483a8517dd8e47c97a6f4cdf777be75ee0b34a..a2d690c5c5daa5a639bc6bcedc6cc6daf7ae04ae 100644 (file)
 /* Define to the version of this package. */
 #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
 
+/* The size of `time_t', as computed by sizeof. */
+#cmakedefine SIZEOF_TIME_T @SIZEOF_TIME_T@
+
+/* The size of `void *', as computed by sizeof. */
+#cmakedefine SIZEOF_VOID_P @SIZEOF_VOID_P@
+
 /* Define to 1 if you have the ANSI C header files. */
 #cmakedefine STDC_HEADERS 1
 
index 35b10fbcbe4c0e2e8d64c199300405d3c937ae46..77ad065c00d0f6a7f4b1ddb3fa097b6a17c3ce6a 100644 (file)
@@ -32,6 +32,15 @@ AC_LBL_C_INIT(V_CCOPT, V_INCLS)
 AC_C_INLINE
 
 AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h)
+#
+# Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
+#
+AC_CHECK_SIZEOF([void *])
+
+#
+# Get the size of a time_t, to know whether it's 32-bit or 64-bit.
+#
+AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
 
 case "$host_os" in