diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 8ed8fd953ce..70ad8e262b1 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -198,8 +198,15 @@ extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**); #define _RT_CRNL 252 #define _RT_BANNER 255 -struct MSVCRT__timeb { - MSVCRT_time_t time; +struct MSVCRT___timeb32 { + MSVCRT___time32_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +struct MSVCRT___timeb64 { + MSVCRT___time64_t time; unsigned short millitm; short timezone; short dstflag; @@ -659,11 +666,9 @@ char* __cdecl MSVCRT_setlocale(int,const char*); int __cdecl MSVCRT_fclose(MSVCRT_FILE*); void __cdecl MSVCRT_terminate(void); MSVCRT_FILE* __cdecl MSVCRT__iob_func(void); -MSVCRT_time_t __cdecl MSVCRT_mktime(struct MSVCRT_tm *t); -struct MSVCRT_tm* __cdecl MSVCRT_localtime(const MSVCRT_time_t* secs); -struct MSVCRT_tm* __cdecl MSVCRT_gmtime(const MSVCRT_time_t* secs); MSVCRT_clock_t __cdecl MSVCRT_clock(void); -double __cdecl MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2); +MSVCRT___time32_t __cdecl MSVCRT__time32(MSVCRT___time32_t*); +MSVCRT___time64_t __cdecl MSVCRT__time64(MSVCRT___time64_t*); MSVCRT_time_t __cdecl MSVCRT_time(MSVCRT_time_t*); MSVCRT_FILE* __cdecl MSVCRT__fdopen(int, const char *); MSVCRT_FILE* __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *); @@ -697,7 +702,6 @@ MSVCRT_wchar_t*** __cdecl __p__wenviron(void); char* __cdecl _strdate(char* date); char* __cdecl _strtime(char* date); int __cdecl _setmbcp(int); -void __cdecl MSVCRT__ftime(struct MSVCRT__timeb *buf); int __cdecl MSVCRT__close(int); int __cdecl MSVCRT__dup(int); int __cdecl MSVCRT__dup2(int, int); diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index e67251dff7a..759d0c05175 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -210,9 +210,13 @@ @ cdecl _cputs(str) @ cdecl _creat(str long) MSVCRT__creat @ varargs _cscanf(str) +@ cdecl _ctime32(ptr) MSVCRT__ctime32 +@ cdecl _ctime64(ptr) MSVCRT__ctime64 @ extern _ctype MSVCRT__ctype @ cdecl _cwait(ptr long long) @ extern _daylight MSVCRT___daylight +@ cdecl _difftime32(long long) MSVCRT__difftime32 +@ cdecl _difftime64(long long) MSVCRT__difftime64 @ extern _dstbias MSVCRT__dstbias @ cdecl _dup (long) MSVCRT__dup @ cdecl _dup2 (long long) MSVCRT__dup2 @@ -263,6 +267,8 @@ @ cdecl _fstat64(long ptr) MSVCRT__fstat64 @ cdecl _fstati64(long ptr) MSVCRT__fstati64 @ cdecl _ftime(ptr) MSVCRT__ftime +@ cdecl _ftime32(ptr) MSVCRT__ftime32 +@ cdecl _ftime64(ptr) MSVCRT__ftime64 @ cdecl -ret64 _ftol() ntdll._ftol @ cdecl _fullpath(ptr str long) @ cdecl _futime(long ptr) @@ -286,6 +292,8 @@ @ cdecl _getw(ptr) MSVCRT__getw @ cdecl _getws(ptr) MSVCRT__getws @ cdecl _global_unwind2(ptr) +@ cdecl _gmtime32(ptr) MSVCRT__gmtime32 +@ cdecl _gmtime64(ptr) MSVCRT__gmtime64 @ cdecl _heapadd (ptr long) @ cdecl _heapchk() @ cdecl _heapmin() @@ -341,6 +349,8 @@ @ cdecl _lfind(ptr ptr ptr long ptr) @ cdecl _loaddll(str) @ cdecl -i386 _local_unwind2(ptr long) +@ cdecl _localtime32(ptr) MSVCRT__localtime32 +@ cdecl _localtime64(ptr) MSVCRT__localtime64 @ cdecl _lock(long) @ cdecl _locking(long long long) MSVCRT__locking @ cdecl _logb( double ) @@ -414,6 +424,8 @@ @ cdecl _memicmp(str str long) ntdll._memicmp @ cdecl _mkdir(str) MSVCRT__mkdir @ cdecl _mktemp(str) +@ cdecl _mktime32(ptr) MSVCRT__mktime32 +@ cdecl _mktime64(ptr) MSVCRT__mktime64 @ cdecl _msize(ptr) @ cdecl _nextafter(double double) @ cdecl _onexit(ptr) MSVCRT__onexit @@ -493,6 +505,8 @@ @ cdecl _tell(long) @ cdecl -ret64 _telli64(long) @ cdecl _tempnam(str str) +@ cdecl _time32(ptr) MSVCRT__time32 +@ cdecl _time64(ptr) MSVCRT__time64 @ extern _timezone MSVCRT___timezone @ cdecl _tolower(long) MSVCRT__tolower @ cdecl _toupper(long) MSVCRT__toupper @@ -530,6 +544,8 @@ @ cdecl _wcsset(wstr long) @ cdecl _wcsupr(wstr) ntdll._wcsupr @ cdecl _wctime(ptr) MSVCRT__wctime +@ cdecl _wctime32(ptr) MSVCRT__wctime32 +@ cdecl _wctime64(ptr) MSVCRT__wctime64 @ extern _wenviron @ varargs _wexecl(wstr wstr) @ varargs _wexecle(wstr wstr) diff --git a/dlls/msvcrt/tests/headers.c b/dlls/msvcrt/tests/headers.c index 7133e1ec05d..603134ff9df 100644 --- a/dlls/msvcrt/tests/headers.c +++ b/dlls/msvcrt/tests/headers.c @@ -115,11 +115,16 @@ static void test_structs(void) CHECK_FIELD(tm, tm_wday); CHECK_FIELD(tm, tm_yday); CHECK_FIELD(tm, tm_isdst); - CHECK_STRUCT(_timeb); - CHECK_FIELD(_timeb, time); - CHECK_FIELD(_timeb, millitm); - CHECK_FIELD(_timeb, timezone); - CHECK_FIELD(_timeb, dstflag); + CHECK_STRUCT(__timeb32); + CHECK_FIELD(__timeb32, time); + CHECK_FIELD(__timeb32, millitm); + CHECK_FIELD(__timeb32, timezone); + CHECK_FIELD(__timeb32, dstflag); + CHECK_STRUCT(__timeb64); + CHECK_FIELD(__timeb64, time); + CHECK_FIELD(__timeb64, millitm); + CHECK_FIELD(__timeb64, timezone); + CHECK_FIELD(__timeb64, dstflag); CHECK_STRUCT(_iobuf); CHECK_FIELD(_iobuf, _ptr); CHECK_FIELD(_iobuf, _cnt); diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index a929120e1de..6acf90056dd 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -85,9 +85,9 @@ static inline void unix_tm_to_msvcrt( struct MSVCRT_tm *dest, const struct tm *s #define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC) /********************************************************************** - * mktime (MSVCRT.@) + * _mktime64 (MSVCRT.@) */ -MSVCRT_time_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) +MSVCRT___time64_t CDECL MSVCRT__mktime64(struct MSVCRT_tm *mstm) { time_t secs; struct tm tm; @@ -99,10 +99,33 @@ MSVCRT_time_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) return secs < 0 ? -1 : secs; } -/********************************************************************* - * localtime (MSVCRT.@) +/********************************************************************** + * _mktime32 (MSVCRT.@) */ -struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT_time_t* secs) +MSVCRT___time32_t CDECL MSVCRT__mktime32(struct MSVCRT_tm *mstm) +{ + return MSVCRT__mktime64( mstm ); +} + +/********************************************************************** + * mktime (MSVCRT.@) + */ +#ifdef _WIN64 +MSVCRT___time64_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) +{ + return MSVCRT__mktime64( mstm ); +} +#else +MSVCRT___time32_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm) +{ + return MSVCRT__mktime32( mstm ); +} +#endif + +/********************************************************************* + * _localtime64 (MSVCRT.@) + */ +struct MSVCRT_tm* CDECL MSVCRT__localtime64(const MSVCRT___time64_t* secs) { struct tm tm; thread_data_t *data; @@ -119,9 +142,33 @@ struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT_time_t* secs) } /********************************************************************* - * gmtime (MSVCRT.@) + * _localtime32 (MSVCRT.@) */ -struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT_time_t* secs) +struct MSVCRT_tm* CDECL MSVCRT__localtime32(const MSVCRT___time32_t* secs) +{ + MSVCRT___time64_t secs64 = *secs; + return MSVCRT__localtime64( &secs64 ); +} + +/********************************************************************* + * localtime (MSVCRT.@) + */ +#ifdef _WIN64 +struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT___time64_t* secs) +{ + return MSVCRT__localtime64( secs ); +} +#else +struct MSVCRT_tm* CDECL MSVCRT_localtime(const MSVCRT___time32_t* secs) +{ + return MSVCRT__localtime32( secs ); +} +#endif + +/********************************************************************* + * _gmtime64 (MSVCRT.@) + */ +struct MSVCRT_tm* CDECL MSVCRT__gmtime64(const MSVCRT___time64_t* secs) { thread_data_t * const data = msvcrt_get_thread_data(); int i; @@ -154,6 +201,30 @@ struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT_time_t* secs) return &data->time_buffer; } +/********************************************************************* + * _gmtime32 (MSVCRT.@) + */ +struct MSVCRT_tm* CDECL MSVCRT__gmtime32(const MSVCRT___time32_t* secs) +{ + MSVCRT___time64_t secs64 = *secs; + return MSVCRT__gmtime64( &secs64 ); +} + +/********************************************************************* + * gmtime (MSVCRT.@) + */ +#ifdef _WIN64 +struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT___time64_t* secs) +{ + return MSVCRT__gmtime64( secs ); +} +#else +struct MSVCRT_tm* CDECL MSVCRT_gmtime(const MSVCRT___time32_t* secs) +{ + return MSVCRT__gmtime32( secs ); +} +#endif + /********************************************************************** * _strdate (MSVCRT.@) */ @@ -223,17 +294,40 @@ MSVCRT_clock_t CDECL MSVCRT_clock(void) } /********************************************************************* - * difftime (MSVCRT.@) + * _difftime64 (MSVCRT.@) */ -double CDECL MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2) +double CDECL MSVCRT__difftime64(MSVCRT___time64_t time1, MSVCRT___time64_t time2) { return (double)(time1 - time2); } /********************************************************************* - * _ftime (MSVCRT.@) + * _difftime32 (MSVCRT.@) */ -void CDECL MSVCRT__ftime(struct MSVCRT__timeb *buf) +double CDECL MSVCRT__difftime32(MSVCRT___time32_t time1, MSVCRT___time32_t time2) +{ + return (double)(time1 - time2); +} + +/********************************************************************* + * difftime (MSVCRT.@) + */ +#ifdef _WIN64 +double CDECL MSVCRT_difftime(MSVCRT___time64_t time1, MSVCRT___time64_t time2) +{ + return MSVCRT__difftime64( time1, time2 ); +} +#else +double CDECL MSVCRT_difftime(MSVCRT___time32_t time1, MSVCRT___time32_t time2) +{ + return MSVCRT__difftime32( time1, time2 ); +} +#endif + +/********************************************************************* + * _ftime64 (MSVCRT.@) + */ +void CDECL MSVCRT__ftime64(struct MSVCRT___timeb64 *buf) { TIME_ZONE_INFORMATION tzinfo; FILETIME ft; @@ -252,19 +346,77 @@ void CDECL MSVCRT__ftime(struct MSVCRT__timeb *buf) buf->dstflag = (tzid == TIME_ZONE_ID_DAYLIGHT?1:0); } +/********************************************************************* + * _ftime32 (MSVCRT.@) + */ +void CDECL MSVCRT__ftime32(struct MSVCRT___timeb32 *buf) +{ + struct MSVCRT___timeb64 buf64; + + MSVCRT__ftime64( &buf64 ); + buf->time = buf64.time; + buf->millitm = buf64.millitm; + buf->timezone = buf64.timezone; + buf->dstflag = buf64.dstflag; +} + +/********************************************************************* + * _ftime (MSVCRT.@) + */ +#ifdef _WIN64 +void CDECL MSVCRT__ftime(struct MSVCRT___timeb64 *buf) +{ + return MSVCRT__ftime64( buf ); +} +#else +void CDECL MSVCRT__ftime(struct MSVCRT___timeb32 *buf) +{ + return MSVCRT__ftime32( buf ); +} +#endif + +/********************************************************************* + * _time64 (MSVCRT.@) + */ +MSVCRT___time64_t CDECL MSVCRT__time64(MSVCRT___time64_t *buf) +{ + MSVCRT___time64_t curtime; + struct MSVCRT___timeb64 tb; + + MSVCRT__ftime64(&tb); + + curtime = tb.time; + return buf ? *buf = curtime : curtime; +} + +/********************************************************************* + * _time32 (MSVCRT.@) + */ +MSVCRT___time32_t CDECL MSVCRT__time32(MSVCRT___time32_t *buf) +{ + MSVCRT___time32_t curtime; + struct MSVCRT___timeb64 tb; + + MSVCRT__ftime64(&tb); + + curtime = tb.time; + return buf ? *buf = curtime : curtime; +} + /********************************************************************* * time (MSVCRT.@) */ -MSVCRT_time_t CDECL MSVCRT_time(MSVCRT_time_t* buf) +#ifdef _WIN64 +MSVCRT___time64_t CDECL MSVCRT_time(MSVCRT___time64_t* buf) { - MSVCRT_time_t curtime; - struct MSVCRT__timeb tb; - - MSVCRT__ftime(&tb); - - curtime = tb.time; - return buf ? *buf = curtime : curtime; + return MSVCRT__time64( buf ); } +#else +MSVCRT___time32_t CDECL MSVCRT_time(MSVCRT___time32_t* buf) +{ + return MSVCRT__time32( buf ); +} +#endif /********************************************************************* * _daylight (MSVCRT.@) @@ -443,20 +595,69 @@ MSVCRT_wchar_t * CDECL MSVCRT__wasctime(const struct MSVCRT_tm *mstm) } /********************************************************************* - * ctime (MSVCRT.@) + * _ctime64 (MSVCRT.@) */ -char * CDECL MSVCRT_ctime(const MSVCRT_time_t *time) +char * CDECL MSVCRT__ctime64(const MSVCRT___time64_t *time) { struct MSVCRT_tm *t; - t = MSVCRT_localtime( time ); + t = MSVCRT__localtime64( time ); if (!t) return NULL; return MSVCRT_asctime( t ); } +/********************************************************************* + * _ctime32 (MSVCRT.@) + */ +char * CDECL MSVCRT__ctime32(const MSVCRT___time32_t *time) +{ + struct MSVCRT_tm *t; + t = MSVCRT__localtime32( time ); + if (!t) return NULL; + return MSVCRT_asctime( t ); +} + +/********************************************************************* + * ctime (MSVCRT.@) + */ +#ifdef _WIN64 +char * CDECL MSVCRT_ctime(const MSVCRT___time64_t *time) +{ + return MSVCRT__ctime64( time ); +} +#else +char * CDECL MSVCRT_ctime(const MSVCRT___time32_t *time) +{ + return MSVCRT__ctime32( time ); +} +#endif + +/********************************************************************* + * _wctime64 (MSVCRT.@) + */ +MSVCRT_wchar_t * CDECL MSVCRT__wctime64(const MSVCRT___time64_t *time) +{ + return MSVCRT__wasctime( MSVCRT__localtime64(time) ); +} + +/********************************************************************* + * _wctime32 (MSVCRT.@) + */ +MSVCRT_wchar_t * CDECL MSVCRT__wctime32(const MSVCRT___time32_t *time) +{ + return MSVCRT__wasctime( MSVCRT__localtime32(time) ); +} + /********************************************************************* * _wctime (MSVCRT.@) */ -MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT_time_t *time) +#ifdef _WIN64 +MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT___time64_t *time) { - return MSVCRT__wasctime( MSVCRT_localtime(time) ); + return MSVCRT__wctime64( time ); } +#else +MSVCRT_wchar_t * CDECL MSVCRT__wctime(const MSVCRT___time32_t *time) +{ + return MSVCRT__wctime32( time ); +} +#endif diff --git a/include/msvcrt/crtdefs.h b/include/msvcrt/crtdefs.h index 9eac870ea75..9f622a72760 100644 --- a/include/msvcrt/crtdefs.h +++ b/include/msvcrt/crtdefs.h @@ -126,11 +126,19 @@ typedef __int64 __time64_t; #define _TIME64_T_DEFINED #endif +#ifdef _USE_32BIT_TIME_T +# ifdef _WIN64 +# error You cannot use 32-bit time_t in Win64 +# endif +#elif !defined(_WIN64) +# define _USE_32BIT_TIME_T +#endif + #ifndef _TIME_T_DEFINED -#ifdef _WIN64 -typedef __time64_t time_t; -#else +#ifdef _USE_32BIT_TIME_T typedef __time32_t time_t; +#else +typedef __time64_t time_t; #endif #define _TIME_T_DEFINED #endif diff --git a/include/msvcrt/sys/timeb.h b/include/msvcrt/sys/timeb.h index a3259130a60..783ccbccbc1 100644 --- a/include/msvcrt/sys/timeb.h +++ b/include/msvcrt/sys/timeb.h @@ -33,6 +33,20 @@ struct _timeb short timezone; short dstflag; }; +struct __timeb32 +{ + __time32_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; +struct __timeb64 +{ + __time64_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; #endif /* _TIMEB_DEFINED */ @@ -40,12 +54,18 @@ struct _timeb extern "C" { #endif -void __cdecl _ftime(struct _timeb*); +void __cdecl _ftime32(struct __timeb32*); +void __cdecl _ftime64(struct __timeb64*); #ifdef __cplusplus } #endif +#ifdef _USE_32BIT_TIME_T +static inline void __cdecl _ftime(struct _timeb *tb) { return _ftime32((struct __timeb32*)tb); } +#else +static inline void __cdecl _ftime(struct _timeb *tb) { return _ftime64((struct __timeb64*)tb); } +#endif #define timeb _timeb diff --git a/include/msvcrt/time.h b/include/msvcrt/time.h index 7b0eb4c8b13..5d81ee46625 100644 --- a/include/msvcrt/time.h +++ b/include/msvcrt/time.h @@ -77,6 +77,15 @@ extern long _timezone; extern char *_tzname; #endif +#ifdef _USE_32BIT_TIME_T +#define _ctime32 ctime +#define _difftime32 difftime +#define _gmtime32 gmtime +#define _localtime32 localtime +#define _mktime32 mktime +#define _time32 time +#endif + unsigned __cdecl _getsystime(struct tm*); unsigned __cdecl _setsystime(struct tm*,unsigned); char* __cdecl _strdate(char*); @@ -85,21 +94,47 @@ void __cdecl _tzset(void); char* __cdecl asctime(const struct tm*); clock_t __cdecl clock(void); -char* __cdecl ctime(const time_t*); -double __cdecl difftime(time_t,time_t); -struct tm* __cdecl gmtime(const time_t*); -struct tm* __cdecl localtime(const time_t*); -time_t __cdecl mktime(struct tm*); +char* __cdecl _ctime32(const __time32_t*); +char* __cdecl _ctime64(const __time64_t*); +double __cdecl _difftime32(__time32_t,__time32_t); +double __cdecl _difftime64(__time64_t,__time64_t); +struct tm* __cdecl _gmtime32(const __time32_t*); +struct tm* __cdecl _gmtime64(const __time64_t*); +struct tm* __cdecl _localtime32(const __time32_t*); +struct tm* __cdecl _localtime64(const __time64_t*); +__time32_t __cdecl _mktime32(struct tm*); +__time64_t __cdecl _mktime64(struct tm*); size_t __cdecl strftime(char*,size_t,const char*,const struct tm*); -time_t __cdecl time(time_t*); +__time32_t __cdecl _time32(__time32_t*); +__time64_t __cdecl _time64(__time64_t*); + +#ifndef _USE_32BIT_TIME_T +static inline char* ctime(const time_t *t) { return _ctime64(t); } +static inline double difftime(time_t t1, time_t t2) { return _difftime64(t1, t2); } +static inline struct tm* gmtime(const time_t *t) { return _gmtime64(t); } +static inline struct tm* localtime(const time_t *t) { return _localtime64(t); } +static inline time_t mktime(struct tm *tm) { return _mktime64(tm); } +static inline time_t time(time_t *t) { return _time64(t); } +#endif #ifndef _WTIME_DEFINED #define _WTIME_DEFINED + +#ifdef _USE_32BIT_TIME_T +#define _wctime32 _wctime +#endif + wchar_t* __cdecl _wasctime(const struct tm*); size_t __cdecl wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*); -wchar_t* __cdecl _wctime(const time_t*); +wchar_t* __cdecl _wctime32(const __time32_t*); +wchar_t* __cdecl _wctime64(const __time64_t*); wchar_t* __cdecl _wstrdate(wchar_t*); wchar_t* __cdecl _wstrtime(wchar_t*); + +#ifndef _USE_32BIT_TIME_T +static inline wchar_t* _wctime(const time_t *t) { return _wctime64(t); } +#endif + #endif /* _WTIME_DEFINED */ #ifdef __cplusplus diff --git a/include/msvcrt/wchar.h b/include/msvcrt/wchar.h index 03d6107edeb..128acda7b62 100644 --- a/include/msvcrt/wchar.h +++ b/include/msvcrt/wchar.h @@ -370,11 +370,22 @@ size_t __cdecl wcsxfrm(wchar_t*,const wchar_t*,size_t); #ifndef _WTIME_DEFINED #define _WTIME_DEFINED + +#ifdef _USE_32BIT_TIME_T +#define _wctime32 _wctime +#endif + wchar_t* __cdecl _wasctime(const struct tm*); size_t __cdecl wcsftime(wchar_t*,size_t,const wchar_t*,const struct tm*); -wchar_t* __cdecl _wctime(const time_t*); +wchar_t* __cdecl _wctime32(const __time32_t*); +wchar_t* __cdecl _wctime64(const __time64_t*); wchar_t* __cdecl _wstrdate(wchar_t*); wchar_t* __cdecl _wstrtime(wchar_t*); + +#ifndef _USE_32BIT_TIME_T +static inline wchar_t* _wctime(const time_t *t) { return _wctime64(t); } +#endif + #endif /* _WTIME_DEFINED */ wchar_t __cdecl btowc(int);