]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: fix unsigned `time_t` detection for cmake, MS-DOS, AmigaOS
authorViktor Szakats <commit@vsz.me>
Mon, 30 Dec 2024 19:57:41 +0000 (20:57 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 31 Dec 2024 10:36:56 +0000 (11:36 +0100)
- cmake: add auto-detection. Sync this with autotools.
- enable for MS-DOS and AmigaOS builds.
  (auto-detection doesn't work for cross-builds.)
- tidy up detection snippet.
- fix comment.

Closes #15868

CMake/win32-cache.cmake
CMakeLists.txt
configure.ac
lib/curl_config.h.cmake

index 1203459a4f481cd90ef2e8a81f72358258f88770..76b0d8c1143e7f4634d548110435d4b4d56eb1bf 100644 (file)
@@ -170,6 +170,7 @@ set(HAVE_POSIX_STRERROR_R 0)
 set(HAVE_MSG_NOSIGNAL 0)
 set(HAVE_STRUCT_TIMEVAL 1)
 set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
+set(HAVE_TIME_T_UNSIGNED 0)
 
 set(HAVE_GETHOSTBYNAME_R_3 0)
 set(HAVE_GETHOSTBYNAME_R_3_REENTRANT 0)
index 0721ff243362e84200e4bafce24314dee40ee176..f79895d04473f2aff102eed53adcff0ad656d619 100644 (file)
@@ -536,6 +536,9 @@ elseif(APPLE)
 elseif(AMIGA)
   set(HAVE_GETADDRINFO 0)  # Breaks the build when detected and used.
 endif()
+if(DOS OR AMIGA)
+  set(HAVE_TIME_T_UNSIGNED 1)
+endif()
 
 if(ENABLE_THREADED_RESOLVER)
   if(WIN32)
@@ -1787,6 +1790,16 @@ if(NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
     }" HAVE_WRITABLE_ARGV)
 endif()
 
+if(NOT CMAKE_CROSSCOMPILING)
+  include(CheckCSourceRuns)
+  check_c_source_runs("
+    #include <time.h>
+    int main(void) {
+      time_t t = -1;
+      return t < 0;
+    }" HAVE_TIME_T_UNSIGNED)
+endif()
+
 curl_internal_test(HAVE_GLIBC_STRERROR_R)
 curl_internal_test(HAVE_POSIX_STRERROR_R)
 
index 5d99c4482a60b0b420017bd2b2b2d4735effa0df..f97a704682eafe678491086157b487d3e1a169b9 100644 (file)
@@ -3965,24 +3965,30 @@ AC_CHECK_TYPE([suseconds_t],[
 #endif
 ])
 
-AC_MSG_CHECKING([if time_t is unsigned])
-CURL_RUN_IFELSE(
-  [
-  #include <time.h>
-  #include <limits.h>
-  int main(void) {
-    time_t t = -1;
-    return (t < 0);
-  }
-  ],[
-  AC_MSG_RESULT([yes])
-  AC_DEFINE(HAVE_TIME_T_UNSIGNED, 1, [Define this if time_t is unsigned])
-],[
-  AC_MSG_RESULT([no])
-],[
-  dnl cross-compiling, most systems are unsigned
-  AC_MSG_RESULT([no])
-])
+case $host_os in
+  amigaos*|msdos*)
+    AC_DEFINE(HAVE_TIME_T_UNSIGNED, 1, [Define this if time_t is unsigned])
+    ;;
+  *)
+    AC_MSG_CHECKING([if time_t is unsigned])
+    CURL_RUN_IFELSE(
+      [
+      #include <time.h>
+      int main(void) {
+        time_t t = -1;
+        return t < 0;
+      }
+      ],[
+      AC_MSG_RESULT([yes])
+      AC_DEFINE(HAVE_TIME_T_UNSIGNED, 1, [Define this if time_t is unsigned])
+    ],[
+      AC_MSG_RESULT([no])
+    ],[
+      dnl cross-compiling, most systems are signed
+      AC_MSG_RESULT([no])
+    ])
+    ;;
+esac
 
 TYPE_IN_ADDR_T
 
index 8676e7b27bb0739415ca6a31855c74c0d41d1b99..f21c74f494c0e5f81ca37fe364ffa2b5cdeb4951 100644 (file)
 /* Define this symbol if your OS supports changing the contents of argv */
 #cmakedefine HAVE_WRITABLE_ARGV 1
 
+/* Define this if time_t is unsigned */
+#cmakedefine HAVE_TIME_T_UNSIGNED 1
+
 /* Define to 1 if _REENTRANT preprocessor symbol must be defined. */
 #cmakedefine NEED_REENTRANT 1