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
This commit is contained in:
parent
f60f872bcd
commit
10fe952da0
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
42
configure.ac
42
configure.ac
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user