Module: wine Branch: stable Commit: 7e369abf1896b149bb1ca1b88c2f5c9d3d986235 URL: https://source.winehq.org/git/wine.git/?a=commit;h=7e369abf1896b149bb1ca1b88...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Apr 18 20:38:18 2018 +0200
ucrtbase: Add _timespec{32,64}_get implementation.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 7a50abd8949c47fd35c68358ba07336ed5f1c5eb) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
.../api-ms-win-crt-time-l1-1-0.spec | 4 +- dlls/msvcrt/time.c | 53 ++++++++++++++++++++++ dlls/ucrtbase/ucrtbase.spec | 4 +- 3 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/dlls/api-ms-win-crt-time-l1-1-0/api-ms-win-crt-time-l1-1-0.spec b/dlls/api-ms-win-crt-time-l1-1-0/api-ms-win-crt-time-l1-1-0.spec index db36c29..e21e07e 100644 --- a/dlls/api-ms-win-crt-time-l1-1-0/api-ms-win-crt-time-l1-1-0.spec +++ b/dlls/api-ms-win-crt-time-l1-1-0/api-ms-win-crt-time-l1-1-0.spec @@ -47,8 +47,8 @@ @ cdecl _strtime_s(ptr long) ucrtbase._strtime_s @ cdecl _time32(ptr) ucrtbase._time32 @ cdecl _time64(ptr) ucrtbase._time64 -@ stub _timespec32_get -@ stub _timespec64_get +@ cdecl _timespec32_get(ptr long) ucrtbase._timespec32_get +@ cdecl _timespec64_get(ptr long) ucrtbase._timespec64_get @ cdecl _tzset() ucrtbase._tzset @ cdecl _utime32(str ptr) ucrtbase._utime32 @ cdecl _utime64(str ptr) ucrtbase._utime64 diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index b7b76af..9e62c9f 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -1613,3 +1613,56 @@ int CDECL _get_daylight(int *hours) }
#endif /* _MSVCR_VER >= 80 */ + +#if _MSVCR_VER >= 140 + +#define TIME_UTC 1 + +struct _timespec32 +{ + MSVCRT___time32_t tv_sec; + LONG tv_nsec; +}; + +struct _timespec64 +{ + MSVCRT___time64_t tv_sec; + LONG tv_nsec; +}; + +/********************************************************************* + * _timespec64_get (UCRTBASE.@) + */ +int CDECL _timespec64_get(struct _timespec64 *ts, int base) +{ + ULONGLONG time; + FILETIME ft; + + if(!MSVCRT_CHECK_PMT(ts != NULL)) return 0; + if(base != TIME_UTC) return 0; + + GetSystemTimePreciseAsFileTime(&ft); + time = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime; + + ts->tv_sec = time / TICKSPERSEC - SECS_1601_TO_1970; + ts->tv_nsec = time % TICKSPERSEC * 100; + return base; +} + +/********************************************************************* + * _timespec32_get (UCRTBASE.@) + */ +int CDECL _timespec32_get(struct _timespec32 *ts, int base) +{ + struct _timespec64 ts64; + + if(_timespec64_get(&ts64, base) != base) + return 0; + if(ts64.tv_sec != (MSVCRT___time32_t)ts64.tv_sec) + return 0; + + ts->tv_sec = ts64.tv_sec; + ts->tv_nsec = ts64.tv_nsec; + return base; +} +#endif /* _MSVCR_VER >= 140 */ diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index 00d779c..423bb96 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -1972,8 +1972,8 @@ @ cdecl _tempnam(str str) MSVCRT__tempnam @ cdecl _time32(ptr) MSVCRT__time32 @ cdecl _time64(ptr) MSVCRT__time64 -@ stub _timespec32_get -@ stub _timespec64_get +@ cdecl _timespec32_get(ptr long) +@ cdecl _timespec64_get(ptr long) @ cdecl _tolower(long) MSVCRT__tolower @ cdecl _tolower_l(long ptr) MSVCRT__tolower_l @ cdecl _toupper(long) MSVCRT__toupper