summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Minichmayr <markus@tapkey.com>2022-03-06 22:32:25 +0100
committerAllen Winter <allen.winter@kdab.com>2022-06-03 11:17:08 -0400
commit0d932910200e77b884d89917545495215567a9f6 (patch)
tree3c95f72bd3424e756964781db9e2c568a8d8426e
parent19ca5336c707bb70b3c62805c04fe04e35941d68 (diff)
downloadlibical-git-0d932910200e77b884d89917545495215567a9f6.tar.gz
Introduce `USE_64BIT_ICALTIME_T` CMake option to allow redirecting icaltime_t to 64-bit types.
-rw-r--r--CMakeLists.txt18
-rw-r--r--ConfigureChecks.cmake1
-rw-r--r--config.h.cmake18
-rw-r--r--config_public.h.cmake5
-rw-r--r--src/libical/ical_file.cmake1
-rw-r--r--src/libical/icaltime.h.cmake3
6 files changed, 34 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 062f3de8..5a8ae773 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,10 @@
# Set to build using a 32bit time_t (ignored unless building with MSVC on Windows)
# Default=false (use the default size of time_t)
#
+# -DUSE_64BIT_ICALTIME_T=[true|false]
+# Experimental: Redirect icaltime_t (and related functions) to a 64-bit version of time_t rather than to time_t.
+# Default=false (use plain time_t)
+#
# -DLIBICAL_BUILD_TESTING=[true|false]
# Set to build the test suite
# Default=true
@@ -325,6 +329,19 @@ if(WIN32)
add_definitions(-DBIG_ENDIAN=0 -DLITTLE_ENDIAN=1 -DBYTE_ORDER=BIG_ENDIAN)
endif()
+# define icaltime_t
+libical_option(USE_64BIT_ICALTIME_T "Experimental: Redirect icaltime_t (and related functions) to a 64-bit version of time_t rather than to time_t." False)
+if(USE_64BIT_ICALTIME_T)
+ if(MSVC)
+ set(ICAL_ICALTIME_T_TYPE "__time64_t")
+ else()
+ message(FATAL_ERROR
+ "Option USE_64BIT_ICALTIME_T is not supported with this compiler or architecture.")
+ endif()
+else()
+ set(ICAL_ICALTIME_T_TYPE "time_t")
+endif()
+
# Use GNUInstallDirs
include(GNUInstallDirs)
@@ -392,7 +409,6 @@ endif()
include(ConfigureChecks.cmake)
add_definitions(-DHAVE_CONFIG_H)
-configure_file(config_public.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_public.h)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set(INSTALL_TARGETS_DEFAULT_ARGS
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 08b74f4e..71a4284b 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -81,6 +81,7 @@ check_type_size(pid_t SIZEOF_PID_T)
check_type_size(size_t SIZEOF_SIZE_T)
check_type_size(ssize_t SIZEOF_SSIZE_T)
check_type_size(time_t SIZEOF_TIME_T)
+check_type_size(${ICAL_ICALTIME_T_TYPE} SIZEOF_ICALTIME_T)
check_type_size(wint_t SIZEOF_WINT_T)
include(FindThreads)
diff --git a/config.h.cmake b/config.h.cmake
index 561b91a8..039a8446 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -1,7 +1,5 @@
/* config.h. Generated by cmake from config.h.cmake */
-#include "config_public.h"
-
/* Define if you have the ICU library. */
#cmakedefine HAVE_LIBICU 1
@@ -235,6 +233,7 @@ typedef unsigned int wint_t;
#endif
#cmakedefine SIZEOF_TIME_T ${SIZEOF_TIME_T}
+#cmakedefine SIZEOF_ICALTIME_T ${SIZEOF_ICALTIME_T}
/* whether we have ICU DANGI calendar */
#cmakedefine HAVE_ICU_DANGI
@@ -523,17 +522,28 @@ typedef ssize_t IO_SSIZE_T;
#define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
#endif
-#define SIZEOF_ICALTIME_T SIZEOF_TIME_T
-
/*
* Substitute functions for those from time.h but working with icaltime_t instead of time_t.
* icaltime_t is defined in config_public.h.cmake.
*/
+ #cmakedefine USE_64BIT_ICALTIME_T 1
+#if (defined(USE_64BIT_ICALTIME_T) && (SIZEOF_TIME_T != 8))
+#if defined(_MSC_VER)
+#define icaltime(timer) _time64(timer)
+#define icalctime(timer) _ctime64(timer)
+#define icalmktime(timeptr) _mktime64(timeptr)
+#define icalgmtime_r(tp,tmp) (_gmtime64(tp)?(*(tmp)=*_gmtime64(tp),(tmp)):0)
+#define icallocaltime_r(tp,tmp) (_localtime64(tp)?(*(tmp)=*_localtime64(tp),(tmp)):0)
+#else
+#error "This compiler is not supported together with the 'USE_64BIT_ICALTIME_T' option."
+#endif
+#else
#define icaltime(timer) time(timer)
#define icalctime(timer) ctime(timer)
#define icalmktime(timeptr) mktime(timeptr)
#define icalgmtime_r(timer, buf) gmtime_r(timer, buf)
#define icallocaltime_r(timer, buf) localtime_r(timer, buf)
+#endif
/* define MAXPATHLEN */
#if defined(_WIN32)
diff --git a/config_public.h.cmake b/config_public.h.cmake
deleted file mode 100644
index 2cffaced..00000000
--- a/config_public.h.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-/* config_public.h. Generated by cmake from config_public.h.cmake */
-
-#include <time.h>
-
-typedef time_t icaltime_t;
diff --git a/src/libical/ical_file.cmake b/src/libical/ical_file.cmake
index 6ea99deb..1ad0bbb5 100644
--- a/src/libical/ical_file.cmake
+++ b/src/libical/ical_file.cmake
@@ -1,7 +1,6 @@
# ORDERING OF HEADERS IS SIGNIFICANT. Don't change this ordering.
# It is required to make the combined header ical.h properly.
set(COMBINEDHEADERSICAL
- ${TOPB}/config_public.h
${TOPB}/src/libical/icalversion.h
${TOPB}/src/libical/icaltime.h
${TOPS}/src/libical/icalduration.h
diff --git a/src/libical/icaltime.h.cmake b/src/libical/icaltime.h.cmake
index c663ba2e..af1c89d4 100644
--- a/src/libical/icaltime.h.cmake
+++ b/src/libical/icaltime.h.cmake
@@ -82,7 +82,8 @@
#include "libical_ical_export.h"
-#include "config_public.h"
+#include <time.h>
+#define icaltime_t ${ICAL_ICALTIME_T_TYPE}
/* An opaque struct representing a timezone. We declare this here to avoid
a circular dependency. */