From: Viktor Szakats Date: Mon, 30 Dec 2024 19:57:41 +0000 (+0100) Subject: build: fix unsigned `time_t` detection for cmake, MS-DOS, AmigaOS X-Git-Tag: curl-8_12_0~235 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10fe952da08a2952cb517847a691e46d2dd7bbb1;p=thirdparty%2Fcurl.git build: fix unsigned `time_t` detection for cmake, MS-DOS, AmigaOS - 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 --- diff --git a/CMake/win32-cache.cmake b/CMake/win32-cache.cmake index 1203459a4f..76b0d8c114 100644 --- a/CMake/win32-cache.cmake +++ b/CMake/win32-cache.cmake @@ -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) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0721ff2433..f79895d044 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 + 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) diff --git a/configure.ac b/configure.ac index 5d99c4482a..f97a704682 100644 --- a/configure.ac +++ b/configure.ac @@ -3965,24 +3965,30 @@ AC_CHECK_TYPE([suseconds_t],[ #endif ]) -AC_MSG_CHECKING([if time_t is unsigned]) -CURL_RUN_IFELSE( - [ - #include - #include - 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 + 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 diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 8676e7b27b..f21c74f494 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -622,6 +622,9 @@ /* 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