diff options
author | Rosen Penev <rosenp@gmail.com> | 2023-01-09 06:15:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 15:15:55 +0100 |
commit | 0348e24bab24cc46642d29e3ceab64df22553298 (patch) | |
tree | e9d44e90d33989a413c9b726aa3b9d302949d142 | |
parent | 2e9bcba70685383426ad42c8856c50ce3214ae24 (diff) | |
download | libarchive-0348e24bab24cc46642d29e3ceab64df22553298.tar.gz |
replace time64 functions with normal ones (#1830)
Otherwise there are 32/64-bit pointer conversions going on. In Windows
since MSVC2005, time_t has been 64-bit. MinGW needs a hack to get 64-bit
time_t.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | build/cmake/config.h.in | 16 | ||||
-rw-r--r-- | configure.ac | 22 | ||||
-rw-r--r-- | contrib/android/config/windows_host.h | 12 | ||||
-rw-r--r-- | cpio/cpio.c | 6 | ||||
-rw-r--r-- | cpio/test/test_option_t.c | 6 | ||||
-rw-r--r-- | libarchive/archive_getdate.c | 42 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_iso9660.c | 4 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_rar.c | 6 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_warc.c | 4 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_xar.c | 4 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_iso9660.c | 12 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_warc.c | 6 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_xar.c | 4 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_zip.c | 6 | ||||
-rw-r--r-- | libarchive/test/test_write_format_zip_compression_store.c | 6 | ||||
-rw-r--r-- | libarchive/test/test_write_format_zip_file.c | 6 | ||||
-rw-r--r-- | libarchive/test/test_write_format_zip_file_zip64.c | 6 | ||||
-rw-r--r-- | tar/util.c | 6 | ||||
-rw-r--r-- | test_utils/test_main.c | 6 |
20 files changed, 101 insertions, 88 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1130b8c0..f5fb821c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,6 +299,7 @@ ENDIF() IF(MINGW) ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO) + ADD_DEFINITIONS(-D__MINGW_USE_VC2005_COMPAT) ENDIF() # @@ -1412,12 +1413,12 @@ CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP) CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) -CHECK_FUNCTION_EXISTS_GLIBC(_ctime64_s HAVE__CTIME64_S) CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64) CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) -CHECK_FUNCTION_EXISTS_GLIBC(_gmtime64_s HAVE__GMTIME64_S) -CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE__LOCALTIME64_S) -CHECK_FUNCTION_EXISTS_GLIBC(_mkgmtime64 HAVE__MKGMTIME64) +CHECK_SYMBOL_EXISTS(ctime_s "time.h" HAVE_CTIME_S) +CHECK_SYMBOL_EXISTS(gmtime_s "time.h" HAVE_GMTIME_S) +CHECK_SYMBOL_EXISTS(localtime_s "time.h" HAVE_LOCALTIME_S) +CHECK_SYMBOL_EXISTS(_mkgmtime "time.h" HAVE__MKGMTIME) SET(CMAKE_REQUIRED_LIBRARIES "") CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 5012ad2c..c8ae4ecc 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -1212,8 +1212,8 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the <zstd.h> header file. */ #cmakedefine HAVE_ZSTD_H 1 -/* Define to 1 if you have the `_ctime64_s' function. */ -#cmakedefine HAVE__CTIME64_S 1 +/* Define to 1 if you have the `ctime_s' function. */ +#cmakedefine HAVE_CTIME_S 1 /* Define to 1 if you have the `_fseeki64' function. */ #cmakedefine HAVE__FSEEKI64 1 @@ -1221,14 +1221,14 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `_get_timezone' function. */ #cmakedefine HAVE__GET_TIMEZONE 1 -/* Define to 1 if you have the `_gmtime64_s' function. */ -#cmakedefine HAVE__GMTIME64_S 1 +/* Define to 1 if you have the `gmtime_s' function. */ +#cmakedefine HAVE_GMTIME_S 1 -/* Define to 1 if you have the `_localtime64_s' function. */ -#cmakedefine HAVE__LOCALTIME64_S 1 +/* Define to 1 if you have the `localtime_s' function. */ +#cmakedefine HAVE_LOCALTIME_S 1 -/* Define to 1 if you have the `_mkgmtime64' function. */ -#cmakedefine HAVE__MKGMTIME64 1 +/* Define to 1 if you have the `_mkgmtime' function. */ +#cmakedefine HAVE__MKGMTIME 1 /* Define as const if the declaration of iconv() needs const. */ #define ICONV_CONST @ICONV_CONST@ diff --git a/configure.ac b/configure.ac index e2715cfd..f078f2cf 100644 --- a/configure.ac +++ b/configure.ac @@ -99,7 +99,7 @@ AM_CONDITIONAL([INC_CYGWIN_FILES], [test $inc_cygwin_files = yes]) dnl Defines that are required for specific platforms (e.g. -D_POSIX_SOURCE, etc) PLATFORMCPPFLAGS= case "$host_os" in - *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO ;; + *mingw* ) PLATFORMCPPFLAGS=-D__USE_MINGW_ANSI_STDIO -D__MINGW_USE_VC2005_COMPAT ;; esac AC_SUBST(PLATFORMCPPFLAGS) @@ -689,8 +689,24 @@ AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs]) AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink]) AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork]) AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove]) -AC_CHECK_FUNCS([_ctime64_s _fseeki64]) -AC_CHECK_FUNCS([_get_timezone _gmtime64_s _localtime64_s _mkgmtime64]) +AC_CHECK_FUNCS([_fseeki64 _get_timezone]) +AC_CHECK_DECL([cmtime_s], + [AC_DEFINE(HAVE_CMTIME_S, 1, [cmtime_s function])], + [], + [#include <time.h>]) +AC_CHECK_DECL([gmtime_s], + [AC_DEFINE(HAVE_GMTIME_S, 1, [gmtime_s function])], + [], + [#include <time.h>]) +AC_CHECK_TYPE([localtime_s], + [AC_DEFINE(HAVE_LOCALTIME_S, 1, [localtime_s function])], + [], + [#include <time.h>]) +AC_CHECK_DECL([_mkgmtime], + [AC_DEFINE(HAVE__MKGMTIME, 1, [_mkgmtime function])], + [], + [#include <time.h>]) + # detects cygwin-1.7, as opposed to older versions AC_CHECK_FUNCS([cygwin_conv_path]) diff --git a/contrib/android/config/windows_host.h b/contrib/android/config/windows_host.h index 2d899d1e..d82ca810 100644 --- a/contrib/android/config/windows_host.h +++ b/contrib/android/config/windows_host.h @@ -905,8 +905,8 @@ /* Define to 1 if you have the <zlib.h> header file. */ /* #undef HAVE_ZLIB_H */ -/* Define to 1 if you have the `_ctime64_s' function. */ -#define HAVE__CTIME64_S 1 +/* Define to 1 if you have the `ctime_s' function. */ +#define HAVE_CTIME_S 1 /* Define to 1 if you have the `_fseeki64' function. */ #define HAVE__FSEEKI64 1 @@ -914,11 +914,11 @@ /* Define to 1 if you have the `_get_timezone' function. */ /* #undef HAVE__GET_TIMEZONE */ -/* Define to 1 if you have the `_localtime64_s' function. */ -#define HAVE__LOCALTIME64_S 1 +/* Define to 1 if you have the `localtime_s' function. */ +#define HAVE_LOCALTIME_S 1 -/* Define to 1 if you have the `_mkgmtime64' function. */ -/* #define HAVE__MKGMTIME64 1 */ +/* Define to 1 if you have the `_mkgmtime' function. */ +/* #define HAVE__MKGMTIME 1 */ /* Define as const if the declaration of iconv() needs const. */ /* #undef ICONV_CONST */ diff --git a/cpio/cpio.c b/cpio/cpio.c index de0144fa..f2d83d94 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -1153,7 +1153,7 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) time_t mtime; static time_t now; struct tm *ltime; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -1203,8 +1203,8 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) else fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M"; #endif -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &mtime) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &mtime) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&mtime, &tmbuf); #else diff --git a/cpio/test/test_option_t.c b/cpio/test/test_option_t.c index 52bcff52..9eef0da5 100644 --- a/cpio/test/test_option_t.c +++ b/cpio/test/test_option_t.c @@ -37,7 +37,7 @@ DEFINE_TEST(test_option_t) char date[32]; char date2[32]; struct tm *tmptr; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -91,8 +91,8 @@ DEFINE_TEST(test_option_t) #ifdef HAVE_LOCALE_H setlocale(LC_ALL, ""); #endif -#if defined(HAVE__LOCALTIME64_S) - tmptr = _localtime64_s(&tmbuf, &mtime) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tmptr = localtime_s(&tmbuf, &mtime) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tmptr = localtime_r(&mtime, &tmbuf); #else diff --git a/libarchive/archive_getdate.c b/libarchive/archive_getdate.c index 47dcecc1..20ab1b15 100644 --- a/libarchive/archive_getdate.c +++ b/libarchive/archive_getdate.c @@ -698,7 +698,7 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Julian; int i; struct tm *ltime; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -727,8 +727,8 @@ Convert(time_t Month, time_t Day, time_t Year, Julian *= DAY; Julian += Timezone; Julian += Hours * HOUR + Minutes * MINUTE + Seconds; -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &Julian) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &Julian) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&Julian, &tmbuf); #else @@ -746,19 +746,19 @@ DSTcorrect(time_t Start, time_t Future) time_t StartDay; time_t FutureDay; struct tm *ltime; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &Start) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &Start) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&Start, &tmbuf); #else ltime = localtime(&Start); #endif StartDay = (ltime->tm_hour + 1) % 24; -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &Future) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &Future) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&Future, &tmbuf); #else @@ -775,13 +775,13 @@ RelativeDate(time_t Start, time_t zone, int dstmode, { struct tm *tm; time_t t, now; -#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S) +#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S) struct tm tmbuf; #endif t = Start - zone; -#if defined(HAVE__GMTIME64_S) - tm = _gmtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_GMTIME_S) + tm = gmtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_GMTIME_R) tm = gmtime_r(&t, &tmbuf); #else @@ -802,14 +802,14 @@ RelativeMonth(time_t Start, time_t Timezone, time_t RelMonth) struct tm *tm; time_t Month; time_t Year; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif if (RelMonth == 0) return 0; -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &Start) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &Start) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&Start, &tmbuf); #else @@ -959,8 +959,8 @@ __archive_get_date(time_t now, const char *p) gds = &_gds; /* Look up the current time. */ -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&local, &now) ? NULL : &local; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&local, &now) ? NULL : &local; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&now, &local); #else @@ -969,14 +969,14 @@ __archive_get_date(time_t now, const char *p) #endif if (tm == NULL) return -1; -#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE__LOCALTIME64_S) +#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) local = *tm; #endif /* Look up UTC if we can and use that to determine the current * timezone offset. */ -#if defined(HAVE__GMTIME64_S) - gmt_ptr = _gmtime64_s(&gmt, &now) ? NULL : &gmt; +#if defined(HAVE_GMTIME_S) + gmt_ptr = gmtime_s(&gmt, &now) ? NULL : &gmt; #elif defined(HAVE_GMTIME_R) gmt_ptr = gmtime_r(&now, &gmt); #else @@ -1020,8 +1020,8 @@ __archive_get_date(time_t now, const char *p) * time components instead of the local timezone. */ if (gds->HaveZone && gmt_ptr != NULL) { now -= gds->Timezone; -#if defined(HAVE__GMTIME64_S) - gmt_ptr = _gmtime64_s(&gmt, &now) ? NULL : &gmt; +#if defined(HAVE_GMTIME_S) + gmt_ptr = gmtime_s(&gmt, &now) ? NULL : &gmt; #elif defined(HAVE_GMTIME_R) gmt_ptr = gmtime_r(&now, &gmt); #else diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index 596c14ac..f5414be2 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -3180,8 +3180,8 @@ isodate17(const unsigned char *v) static time_t time_from_tm(struct tm *t) { -#if HAVE__MKGMTIME64 - return (_mkgmtime64(t)); +#if HAVE__MKGMTIME + return _mkgmtime(t); #elif HAVE_TIMEGM /* Use platform timegm() if available. */ return (timegm(t)); diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index b7adb2ba..8f239da9 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -1830,7 +1830,7 @@ read_exttime(const char *p, struct rar *rar, const char *endp) struct tm *tm; time_t t; long nsec; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -1864,8 +1864,8 @@ read_exttime(const char *p, struct rar *rar, const char *endp) rem = (((unsigned)(unsigned char)*p) << 16) | (rem >> 8); p++; } -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index b34c7fe3..61ab29ea 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -530,8 +530,8 @@ strtoi_lim(const char *str, const char **ep, int llim, int ulim) static time_t time_from_tm(struct tm *t) { -#if HAVE__MKGMTIME64 - return (_mkgmtime64(t)); +#if HAVE__MKGMTIME + return _mkgmtime(t); #elif HAVE_TIMEGM /* Use platform timegm() if available. */ return (timegm(t)); diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index f9e2de12..ec9cb198 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -1139,8 +1139,8 @@ atohex(unsigned char *b, size_t bsize, const char *p, size_t psize) static time_t time_from_tm(struct tm *t) { -#if HAVE__MKGMTIME64 - return (_mkgmtime64(t)); +#if HAVE__MKGMTIME + return _mkgmtime(t); #elif HAVE_TIMEGM /* Use platform timegm() if available. */ return (timegm(t)); diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 22e36f62..197b0ee6 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2521,9 +2521,8 @@ get_gmoffset(struct tm *tm) static void get_tmfromtime(struct tm *tm, time_t *t) { -#if HAVE__LOCALTIME64_S - __time64_t tmp_t = (__time64_t) *t; //time_t may be shorter than 64 bits - _localtime64_s(tm, &tmp_t); +#if HAVE_LOCALTIME_S + localtime_s(tm, t); #elif HAVE_LOCALTIME_R tzset(); localtime_r(t, tm); @@ -4074,11 +4073,8 @@ write_information_block(struct archive_write *a) } memset(info.s, 0, info_size); opt = 0; -#if defined(HAVE__CTIME64_S) - { - __time64_t iso9660_birth_time_tmp = (__time64_t) iso9660->birth_time; //time_t may be shorter than 64 bits - _ctime64_s(buf, sizeof(buf), &(iso9660_birth_time_tmp)); - } +#if defined(HAVE_CTIME_S) + ctime_s(buf, sizeof(buf), &(iso9660->birth_time)); #elif defined(HAVE_CTIME_R) ctime_r(&(iso9660->birth_time), buf); #else diff --git a/libarchive/archive_write_set_format_warc.c b/libarchive/archive_write_set_format_warc.c index 6f0a45d8..0ef003e2 100644 --- a/libarchive/archive_write_set_format_warc.c +++ b/libarchive/archive_write_set_format_warc.c @@ -329,14 +329,14 @@ xstrftime(struct archive_string *as, const char *fmt, time_t t) { /** like strftime(3) but for time_t objects */ struct tm *rt; -#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S) +#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S) struct tm timeHere; #endif char strtime[100]; size_t len; -#if defined(HAVE__GMTIME64_S) - rt = _gmtime64_s(&timeHere, &t) ? NULL : &timeHere; +#if defined(HAVE_GMTIME_S) + rt = gmtime_s(&timeHere, &t) ? NULL : &timeHere; #elif defined(HAVE_GMTIME_R) rt = gmtime_r(&t, &timeHere); #else diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index 9529ee91..7849062c 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -907,8 +907,8 @@ xmlwrite_time(struct archive_write *a, xmlTextWriterPtr writer, char timestr[100]; struct tm tm; -#if defined(HAVE__GMTIME64_S) - _gmtime64_s(&tm, &t); +#if defined(HAVE_GMTIME_S) + gmtime_s(&tm, &t); #elif defined(HAVE_GMTIME_R) gmtime_r(&t, &tm); #else diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index 86fa4858..6821049c 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -1382,12 +1382,12 @@ dos_time(const time_t unix_time) { struct tm *t; unsigned int dt; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - t = _localtime64_s(&tmbuf, &unix_time) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + t = localtime_s(&tmbuf, &unix_time) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) t = localtime_r(&unix_time, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_compression_store.c b/libarchive/test/test_write_format_zip_compression_store.c index 4d086edf..b52d170c 100644 --- a/libarchive/test/test_write_format_zip_compression_store.c +++ b/libarchive/test/test_write_format_zip_compression_store.c @@ -129,15 +129,15 @@ static void verify_uncompressed_contents(const char *buff, size_t used) /* Misc variables */ unsigned long crc; struct tm *tm; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif /* p is the pointer to walk over the central directory, * q walks over the local headers, the data and the data descriptors. */ const char *p, *q, *local_header, *extra_start; -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &now) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &now) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&now, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_file.c b/libarchive/test/test_write_format_zip_file.c index afd0eb6e..4ccc3036 100644 --- a/libarchive/test/test_write_format_zip_file.c +++ b/libarchive/test/test_write_format_zip_file.c @@ -74,7 +74,7 @@ DEFINE_TEST(test_write_format_zip_file) struct archive_entry *ae; time_t t = 1234567890; struct tm *tm; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif size_t used, buffsize = 1000000; @@ -94,8 +94,8 @@ DEFINE_TEST(test_write_format_zip_file) zip_compression = 0; #endif -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_file_zip64.c b/libarchive/test/test_write_format_zip_file_zip64.c index 8a506226..6a00fe14 100644 --- a/libarchive/test/test_write_format_zip_file_zip64.c +++ b/libarchive/test/test_write_format_zip_file_zip64.c @@ -76,7 +76,7 @@ DEFINE_TEST(test_write_format_zip_file_zip64) struct archive_entry *ae; time_t t = 1234567890; struct tm *tm; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif size_t used, buffsize = 1000000; @@ -95,8 +95,8 @@ DEFINE_TEST(test_write_format_zip_file_zip64) zip_compression = 0; #endif -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else @@ -668,7 +668,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) time_t tim; static time_t now; struct tm *ltime; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -742,8 +742,8 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) fmt = bsdtar->day_first ? DAY_FMT " %b %Y" : "%b " DAY_FMT " %Y"; else fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M"; -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &tim) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &tim) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&tim, &tmbuf); #else diff --git a/test_utils/test_main.c b/test_utils/test_main.c index 81b5002f..3250423a 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -3868,7 +3868,7 @@ main(int argc, char **argv) #endif time_t now; struct tm *tmptr; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif char *refdir_alloc = NULL; @@ -4105,8 +4105,8 @@ main(int argc, char **argv) */ now = time(NULL); for (i = 0; ; i++) { -#if defined(HAVE__LOCALTIME64_S) - tmptr = _localtime64_s(&tmbuf, &now) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tmptr = localtime_s(&tmbuf, &now) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tmptr = localtime_r(&now, &tmbuf); #else |