? 1.txt ? time64.txt ? runtime/POSIX/a.out Index: m3core.h =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/m3core.h,v retrieving revision 1.48 diff -u -r1.48 m3core.h --- m3core.h 6 Jun 2010 15:49:28 -0000 1.48 +++ m3core.h 6 Jun 2010 21:10:05 -0000 @@ -12,6 +12,9 @@ #ifndef _XOPEN_SOURCE #define _XOPEN_SOURCE 500 #endif +#ifndef _TIME64_T +#define _TIME64_T +#endif #endif /* http://gcc.gnu.org/wiki/Visibility */ Index: time/POSIX/DatePosixC.c =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/DatePosixC.c,v retrieving revision 1.20 diff -u -r1.20 DatePosixC.c --- time/POSIX/DatePosixC.c 6 Jun 2010 15:51:35 -0000 1.20 +++ time/POSIX/DatePosixC.c 6 Jun 2010 21:10:05 -0000 @@ -23,9 +23,11 @@ #define Local 0 #define UTC 1 -static -time_t -TimePosix__ToSeconds(LONGREAL/*Time.T*/ t) +#ifdef _TIME64_T +static time64_t TimePosix__ToSeconds(LONGREAL/*Time.T*/ t) +#else +static time_t TimePosix__ToSeconds(LONGREAL/*Time.T*/ t) +#endif { double n = { 0 }; modf(t, &n); @@ -37,11 +39,19 @@ DatePosix__FromTime(double t, const ptrdiff_t* pzone, Date_t* date, TEXT unknown, TEXT gmt) { struct tm* tm = { 0 }; +#ifdef _TIME64_T + time64_t sec = TimePosix__ToSeconds(t); +#else time_t sec = TimePosix__ToSeconds(t); +#endif ptrdiff_t zone = (pzone ? *pzone : Local); ZeroMemory(date, sizeof(*date)); assert(zone == Local || zone == UTC); +#ifdef _TIME64_T + tm = ((zone == Local) ? localtime64(&sec) : gmtime64(&sec)); +#else tm = ((zone == Local) ? localtime(&sec) : gmtime(&sec)); +#endif assert(tm != NULL); date->year = tm->tm_year + 1900; date->month = tm->tm_mon; @@ -97,7 +107,11 @@ double t = { 0 }; #ifdef DATE_BSD const unsigned SecsPerHour = 60 * 60; +#ifdef _TIME64_T + time64_t now = { 0 }; +#else time_t now = { 0 }; +#endif struct tm* local_now = { 0 }; #endif @@ -112,14 +126,23 @@ /* tm.tm_wday ignored */ tm.tm_isdst = 0; /* tell mktime that DST is not in effect */ /* tm_zone, tm_gmtoff ignored */ +#ifdef _TIME64_T + t = mktime64(&tm); +#else t = mktime(&tm); +#endif #ifdef DATE_BSD if (t == -1) goto Exit; /* adjust result to reflect "date->offset" */ +#ifdef _TIME64_T + time64(&now); + local_now = localtime64(&now); +#else time(&now); local_now = localtime(&now); +#endif assert(local_now != NULL); if (local_now->tm_isdst > 0) /* decrement the local time zone by one hour if DST is in effect */ Index: time/POSIX/TimePosixC.c =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/time/POSIX/TimePosixC.c,v retrieving revision 1.18 diff -u -r1.18 TimePosixC.c --- time/POSIX/TimePosixC.c 6 Jun 2010 20:46:14 -0000 1.18 +++ time/POSIX/TimePosixC.c 6 Jun 2010 21:10:05 -0000 @@ -15,10 +15,11 @@ #define MILLION (1000 * 1000) -static -LONGREAL/*Time.T*/ -__cdecl -TimePosix__FromUtime(const struct timeval* tv) +#ifdef _TIME64_T +static LONGREAL/*Time.T*/ __cdecl TimePosix__FromUtime(const struct timeval64* tv) +#else +static LONGREAL/*Time.T*/ __cdecl TimePosix__FromUtime(const struct timeval* tv) +#endif /* see also TimePosix__ToUtime */ { return ((LONGREAL)tv->tv_sec) + ((LONGREAL)tv->tv_usec) / (LONGREAL)MILLION; @@ -28,11 +29,19 @@ __cdecl TimePosix__Now(void) { +#ifdef _TIME64_T + struct timeval64 tv; +#else struct timeval tv; +#endif int i = { 0 }; ZERO_MEMORY(tv); +#ifdef _TIME64_T + i = gettimeofday64(&tv, NULL); +#else i = gettimeofday(&tv, NULL); +#endif assert(i == 0); return TimePosix__FromUtime(&tv); Index: unix/Common/UtimeC.c =================================================================== RCS file: /usr/cvs/cm3/m3-libs/m3core/src/unix/Common/UtimeC.c,v retrieving revision 1.58 diff -u -r1.58 UtimeC.c --- unix/Common/UtimeC.c 25 Apr 2010 21:34:01 -0000 1.58 +++ unix/Common/UtimeC.c 6 Jun 2010 21:10:05 -0000 @@ -17,14 +17,22 @@ * time() doesn't really take an input. * ctime() needs to be replaced with a 64bit version or possibly removed. */ +#ifdef _TIME64_T +M3_STATIC_ASSERT(sizeof(time64_t) <= sizeof(m3_time_t)); +#else M3_STATIC_ASSERT(sizeof(time_t) <= sizeof(m3_time_t)); +#endif m3_time_t __cdecl Utime__time(m3_time_t* tloc) { time_t b = tloc ? (time_t)*tloc : 0; +#ifdef _TIME64_T + time64_t a = time64(tloc ? &b : 0); +#else time_t a = time(tloc ? &b : 0); +#endif if (tloc) *tloc = b; return a; } @@ -33,8 +41,13 @@ __cdecl Utime__ctime(const m3_time_t* m) { +#ifdef _TIME64_T + time64_t t = m ? (time64_t)*m : 0; + return ctime64(m ? &t : 0); +#else time_t t = m ? (time_t)*m : 0; return ctime(m ? &t : 0); +#endif } void