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)
/* 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 `_localtime64_s' function. */
#cmakedefine HAVE__LOCALTIME64_S 1
AC_CHECK_FUNCS([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 _localtime64_s _mkgmtime64])
+AC_CHECK_FUNCS([_get_timezone _gmtime64_s _localtime64_s _mkgmtime64])
# detects cygwin-1.7, as opposed to older versions
AC_CHECK_FUNCS([cygwin_conv_path])
time_t mtime;
static time_t now;
struct tm *ltime;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
if (!now)
time(&now);
else
fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
#endif
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
ltime = localtime_r(&mtime, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = mtime;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ ltime = NULL;
+ else
+ ltime = &tmbuf;
#else
- ltime = localtime(&mtime)
+ ltime = localtime(&mtime);
#endif
strftime(date, sizeof(date), fmt, ltime);
time_t Julian;
int i;
struct tm *ltime;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
if (Year < 69)
Year += 2000;
Julian *= DAY;
Julian += Timezone;
Julian += Hours * HOUR + Minutes * MINUTE + Seconds;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
ltime = localtime_r(&Julian, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = Julian;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ ltime = NULL;
+ else
+ ltime = &tmbuf;
#else
ltime = localtime(&Julian);
#endif
time_t StartDay;
time_t FutureDay;
struct tm *ltime;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
ltime = localtime_r(&Start, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = Start;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ ltime = NULL;
+ else
+ ltime = &tmbuf;
#else
ltime = localtime(&Start);
#endif
StartDay = (ltime->tm_hour + 1) % 24;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
ltime = localtime_r(&Future, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = Future;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ ltime = NULL;
+ else
+ ltime = &tmbuf;
#else
ltime = localtime(&Future);
#endif
{
struct tm *tm;
time_t t, now;
-#ifdef HAVE_GMTIME_R
+#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__GMTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
t = Start - zone;
-#ifdef HAVE_GMTIME_R
+#if defined(HAVE_GMTIME_R)
tm = gmtime_r(&t, &tmbuf);
+#elif defined(HAVE__GMTIME64_S)
+ tmptime = t;
+ terr = _gmtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &tmbuf;
#else
tm = gmtime(&t);
#endif
struct tm *tm;
time_t Month;
time_t Year;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
if (RelMonth == 0)
return 0;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
tm = localtime_r(&Start, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = Start;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &tmbuf;
#else
tm = localtime(&Start);
#endif
time_t Start;
time_t tod;
long tzone;
+#if defined(HAVE__LOCALTIME64_S) || defined(HAVE__GMTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
/* Clear out the parsed token array. */
memset(tokens, 0, sizeof(tokens));
gds = &_gds;
/* Look up the current time. */
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
tm = localtime_r(&now, &local);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = now;
+ terr = _localtime64_s(&local, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &local;
#else
memset(&local, 0, sizeof(local));
tm = localtime(&now);
#endif
if (tm == NULL)
return -1;
-#ifndef HAVE_LOCALTIME_R
+#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE__LOCALTIME64_S)
local = *tm;
#endif
/* Look up UTC if we can and use that to determine the current
* timezone offset. */
-#ifdef HAVE_GMTIME_R
+#if defined(HAVE_GMTIME_R)
gmt_ptr = gmtime_r(&now, &gmt);
+#elif defined(HAVE__GMTIME64_S)
+ tmptime = now;
+ terr = _gmtime64_s(&gmt, &tmptime);
+ if (terr)
+ gmt_ptr = NULL;
+ else
+ gmt_ptr = &gmt;
#else
memset(&gmt, 0, sizeof(gmt));
gmt_ptr = gmtime(&now);
* time components instead of the local timezone. */
if (gds->HaveZone && gmt_ptr != NULL) {
now -= gds->Timezone;
-#ifdef HAVE_GMTIME_R
+#if defined(HAVE_GMTIME_R)
gmt_ptr = gmtime_r(&now, &gmt);
+#elif defined(HAVE__GMTIME64_S)
+ tmptime = now;
+ terr = _gmtime64_s(&gmt, &tmptime);
+ if (terr)
+ gmt_ptr = NULL;
+ else
+ gmt_ptr = &gmt;
#else
gmt_ptr = gmtime(&now);
#endif
unsigned rmode, flags, rem, j, count;
int ttime, i;
struct tm *tm;
-#ifdef HAVE_LOCALTIME_R
- struct tm tmbuf;
-#endif
time_t t;
long nsec;
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
+ struct tm tmbuf;
+#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
if (p + 2 > endp)
return (-1);
rem = (((unsigned)(unsigned char)*p) << 16) | (rem >> 8);
p++;
}
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
tm = localtime_r(&t, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = t;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ tm = NULL;
+ else
+ tm = &tmbuf;
#else
tm = localtime(&t);
#endif
struct tm *rt;
#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
struct tm timeHere;
+#endif
+#if defined(HAVE__GMTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
#endif
char strtime[100];
size_t len;
if ((rt = gmtime_r(&t, &timeHere)) == NULL)
return;
#elif defined(HAVE__GMTIME64_S)
- _gmtime64_s(&timeHere, &t);
+ tmptime = t;
+ terr = _gmtime64_s(&timeHere, &tmptime);
+ if (terr)
+ rt = NULL;
+ else
+ rt = &timeHere;
#else
if ((rt = gmtime(&t)) == NULL)
return;
{
char timestr[100];
struct tm tm;
+#if defined(HAVE__GMTIME64_S)
+ __time64_t tmptime;
+#endif
#if defined(HAVE_GMTIME_R)
gmtime_r(&t, &tm);
#elif defined(HAVE__GMTIME64_S)
- _gmtime64_s(&tm, &t);
+ tmptime = t;
+ _gmtime64_s(&tm, &tmptime);
#else
memcpy(&tm, gmtime(&t), sizeof(tm));
#endif
{
struct tm *t;
unsigned int dt;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
/* This will not preserve time when creating/extracting the archive
* on two systems with different time zones. */
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
t = localtime_r(&unix_time, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = unix_time;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ t = NULL;
+ else
+ t = &tmbuf;
#else
t = localtime(&unix_time);
#endif
time_t tim;
static time_t now;
struct tm *ltime;
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
+#if defined(HAVE__LOCALTIME64_S)
+ errno_t terr;
+ __time64_t tmptime;
+#endif
/*
* We avoid collecting the entire list in memory at once by
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";
-#ifdef HAVE_LOCALTIME_R
+#if defined(HAVE_LOCALTIME_R)
ltime = localtime_r(&tim, &tmbuf);
+#elif defined(HAVE__LOCALTIME64_S)
+ tmptime = tim;
+ terr = _localtime64_s(&tmbuf, &tmptime);
+ if (terr)
+ ltime = NULL;
+ else
+ ltime = &tmbuf;
#else
ltime = localtime(&tim);
#endif