Questions. 1. _timespec32_get and _timespec64_get are only exported from ucrtbase.dll. Do the declarations need `#if _UCRT` condition? 2. The declarations in WinSDK have const parameters but glibc does not. Which is the correct one?
From 37ab843c234f16bfb7fef94769d76cf4d2dd8f6e Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath <[email protected]> Date: Sun, 12 Dec 2021 15:10:19 +0530 Subject: [PATCH] headers/crt: Add timespec_get in time.h
Signed-off-by: Biswapriyo Nath <[email protected]> --- mingw-w64-headers/crt/sys/timeb.h | 10 ++++++++++ mingw-w64-headers/crt/time.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/mingw-w64-headers/crt/sys/timeb.h b/mingw-w64-headers/crt/sys/timeb.h index 7bfe98e..8f69a46 100644 --- a/mingw-w64-headers/crt/sys/timeb.h +++ b/mingw-w64-headers/crt/sys/timeb.h @@ -86,6 +86,16 @@ extern "C" { #define _ftime _ftime32 #endif +struct _timespec32 { + __time32_t tv_sec; + long tv_nsec; +}; + +struct _timespec64 { + __time64_t tv_sec; + long tv_nsec; +}; + #ifndef _TIMESPEC_DEFINED #define _TIMESPEC_DEFINED struct timespec { diff --git a/mingw-w64-headers/crt/time.h b/mingw-w64-headers/crt/time.h index ad4d52d..666116d 100644 --- a/mingw-w64-headers/crt/time.h +++ b/mingw-w64-headers/crt/time.h @@ -109,6 +109,8 @@ extern "C" { #define CLOCKS_PER_SEC 1000 +#define TIME_UTC 1 + #ifdef _UCRT _CRTIMP int *__cdecl __daylight(void); _CRTIMP long *__cdecl __dstbias(void); @@ -146,6 +148,7 @@ extern "C" { _CRTIMP char *__cdecl _strtime(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN; _SECIMP errno_t __cdecl _strtime_s (char *_Buf ,size_t _SizeInBytes); _CRTIMP __time32_t __cdecl _time32(__time32_t *_Time); + _CRTIMP int __cdecl _timespec32_get(struct _timespec32 *_Ts, int _Base); _CRTIMP __time32_t __cdecl _mktime32(struct tm *_Tm); _CRTIMP __time32_t __cdecl _mkgmtime32(struct tm *_Tm); @@ -169,6 +172,7 @@ extern "C" { _CRTIMP __time64_t __cdecl _mktime64(struct tm *_Tm); _CRTIMP __time64_t __cdecl _mkgmtime64(struct tm *_Tm); _CRTIMP __time64_t __cdecl _time64(__time64_t *_Time); + _CRTIMP int __cdecl _timespec64_get(struct _timespec64 *_Ts, int _Base); unsigned __cdecl _getsystime(struct tm *_Tm); unsigned __cdecl _setsystime(struct tm *_Tm,unsigned _MilliSec); @@ -217,6 +221,7 @@ extern "C" { #ifdef _USE_32BIT_TIME_T static __inline time_t __CRTDECL time(time_t *_Time) { return _time32(_Time); } +static __inline int __CRTDECL timespec_get(struct timespec* const _Ts, int const _Base) { return _timespec32_get((struct _timespec32*)_Ts, _Base); } static __inline double __CRTDECL difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); } static __inline struct tm *__CRTDECL localtime(const time_t *_Time) { return _localtime32(_Time); } static __inline errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime32_s(_Tm,_Time); } @@ -228,6 +233,7 @@ static __inline time_t __CRTDECL mktime(struct tm *_Tm) { return _mktime32(_Tm); static __inline time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); } #else static __inline time_t __CRTDECL time(time_t *_Time) { return _time64(_Time); } +static __inline int __CRTDECL timespec_get(struct timespec* const _Ts, int const _Base) { return _timespec64_get((struct _timespec64*)_Ts, _Base); } static __inline double __CRTDECL difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); } static __inline struct tm *__CRTDECL localtime(const time_t *_Time) { return _localtime64(_Time); } static __inline errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime64_s(_Tm,_Time); } -- 2.34.1
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
