LCOV - code coverage report
Current view: top level - /usr/share/mingw-w64/include - time.h (source / functions) Coverage Total Hit
Test: asar build #66 Lines: 100.0 % 1 1
Test Date: 2024-01-16 02:45:19 Functions: 100.0 % 1 1
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /**
       2                 :             :  * This file has no copyright assigned and is placed in the Public Domain.
       3                 :             :  * This file is part of the mingw-w64 runtime package.
       4                 :             :  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
       5                 :             :  */
       6                 :             : #ifndef _TIME_H_
       7                 :             : #define _TIME_H_
       8                 :             : 
       9                 :             : #include <crtdefs.h>
      10                 :             : 
      11                 :             : #ifndef _WIN32
      12                 :             : #error Only Win32 target is supported!
      13                 :             : #endif
      14                 :             : 
      15                 :             : #if defined(__LIBMSVCRT__)
      16                 :             : /* When building mingw-w64, this should be blank.  */
      17                 :             : #define _SECIMP
      18                 :             : #else
      19                 :             : #ifndef _SECIMP
      20                 :             : #define _SECIMP __declspec(dllimport)
      21                 :             : #endif /* _SECIMP */
      22                 :             : #endif /* defined(_CRTBLD) || defined(__LIBMSVCRT__) */
      23                 :             : 
      24                 :             : /* Adding timespec definition.  */
      25                 :             : #include <sys/timeb.h>
      26                 :             : 
      27                 :             : #pragma pack(push,_CRT_PACKING)
      28                 :             : 
      29                 :             : #ifdef __cplusplus
      30                 :             : extern "C" {
      31                 :             : #endif
      32                 :             : 
      33                 :             : #ifndef _CRTIMP
      34                 :             : #define _CRTIMP __declspec(dllimport)
      35                 :             : #endif
      36                 :             : 
      37                 :             : #ifndef _WCHAR_T_DEFINED
      38                 :             : #define _WCHAR_T_DEFINED
      39                 :             :   typedef unsigned short wchar_t;
      40                 :             : #endif
      41                 :             : 
      42                 :             : #ifndef _TIME32_T_DEFINED
      43                 :             : #define _TIME32_T_DEFINED
      44                 :             :   typedef long __time32_t;
      45                 :             : #endif
      46                 :             : 
      47                 :             : #ifndef _TIME64_T_DEFINED
      48                 :             : #define _TIME64_T_DEFINED
      49                 :             :   __MINGW_EXTENSION typedef __int64 __time64_t;
      50                 :             : #endif
      51                 :             : 
      52                 :             : #ifndef _TIME_T_DEFINED
      53                 :             : #define _TIME_T_DEFINED
      54                 :             : #ifdef _USE_32BIT_TIME_T
      55                 :             :   typedef __time32_t time_t;
      56                 :             : #else
      57                 :             :   typedef __time64_t time_t;
      58                 :             : #endif
      59                 :             : #endif
      60                 :             : 
      61                 :             : #ifndef _CLOCK_T_DEFINED
      62                 :             : #define _CLOCK_T_DEFINED
      63                 :             :   typedef long clock_t;
      64                 :             : #endif
      65                 :             : 
      66                 :             : #ifndef _SIZE_T_DEFINED
      67                 :             : #define _SIZE_T_DEFINED
      68                 :             : #undef size_t
      69                 :             : #ifdef _WIN64
      70                 :             :   __MINGW_EXTENSION typedef unsigned __int64 size_t;
      71                 :             : #else
      72                 :             :   typedef unsigned int size_t;
      73                 :             : #endif
      74                 :             : #endif
      75                 :             : 
      76                 :             : #ifndef _SSIZE_T_DEFINED
      77                 :             : #define _SSIZE_T_DEFINED
      78                 :             : #undef ssize_t
      79                 :             : #ifdef _WIN64
      80                 :             :   __MINGW_EXTENSION typedef __int64 ssize_t;
      81                 :             : #else
      82                 :             :   typedef int ssize_t;
      83                 :             : #endif
      84                 :             : #endif
      85                 :             : 
      86                 :             : #ifndef NULL
      87                 :             : #ifdef __cplusplus
      88                 :             : #ifndef _WIN64
      89                 :             : #define NULL 0
      90                 :             : #else
      91                 :             : #define NULL 0LL
      92                 :             : #endif  /* W64 */
      93                 :             : #else
      94                 :             : #define NULL ((void *)0)
      95                 :             : #endif
      96                 :             : #endif
      97                 :             : 
      98                 :             : #ifndef _TM_DEFINED
      99                 :             : #define _TM_DEFINED
     100                 :             :   struct tm {
     101                 :             :     int tm_sec;
     102                 :             :     int tm_min;
     103                 :             :     int tm_hour;
     104                 :             :     int tm_mday;
     105                 :             :     int tm_mon;
     106                 :             :     int tm_year;
     107                 :             :     int tm_wday;
     108                 :             :     int tm_yday;
     109                 :             :     int tm_isdst;
     110                 :             :   };
     111                 :             : #endif
     112                 :             : 
     113                 :             : #define CLOCKS_PER_SEC 1000
     114                 :             : 
     115                 :             : #ifdef _UCRT
     116                 :             : #define TIME_UTC 1
     117                 :             : #endif
     118                 :             : 
     119                 :             : #ifdef _UCRT
     120                 :             :   _CRTIMP int *__cdecl __daylight(void);
     121                 :             :   _CRTIMP long *__cdecl __dstbias(void);
     122                 :             :   _CRTIMP long *__cdecl __timezone(void);
     123                 :             :   _CRTIMP char **__cdecl __tzname(void);
     124                 :             : #define _daylight (* __daylight())
     125                 :             : #define _dstbias (* __dstbias())
     126                 :             : #define _timezone (* __timezone())
     127                 :             : #define _tzname (__tzname())
     128                 :             : #else
     129                 :             :   __MINGW_IMPORT int _daylight;
     130                 :             :   __MINGW_IMPORT long _dstbias;
     131                 :             :   __MINGW_IMPORT long _timezone;
     132                 :             :   __MINGW_IMPORT char * _tzname[2];
     133                 :             : #endif
     134                 :             : 
     135                 :             :   _CRTIMP errno_t __cdecl _get_daylight(int *_Daylight);
     136                 :             :   _CRTIMP errno_t __cdecl _get_dstbias(long *_Daylight_savings_bias);
     137                 :             :   _CRTIMP errno_t __cdecl _get_timezone(long *_Timezone);
     138                 :             :   _CRTIMP errno_t __cdecl _get_tzname(size_t *_ReturnValue,char *_Buffer,size_t _SizeInBytes,int _Index);
     139                 :             :   char *__cdecl asctime(const struct tm *_Tm) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     140                 :             :   _SECIMP errno_t __cdecl asctime_s (char *_Buf,size_t _SizeInWords,const struct tm *_Tm);
     141                 :             :   _CRTIMP char *__cdecl _ctime32(const __time32_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     142                 :             :   _SECIMP errno_t __cdecl _ctime32_s (char *_Buf,size_t _SizeInBytes,const __time32_t *_Time);
     143                 :             :   clock_t __cdecl clock(void);
     144                 :             :   _CRTIMP double __cdecl _difftime32(__time32_t _Time1,__time32_t _Time2);
     145                 :             :   _CRTIMP struct tm *__cdecl _gmtime32(const __time32_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     146                 :             :   _SECIMP errno_t __cdecl _gmtime32_s (struct tm *_Tm,const __time32_t *_Time);
     147                 :             :   _CRTIMP struct tm *__cdecl _localtime32(const __time32_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     148                 :             :   _SECIMP errno_t __cdecl _localtime32_s (struct tm *_Tm,const __time32_t *_Time);
     149                 :             :   size_t __cdecl strftime(char * __restrict__ _Buf,size_t _SizeInBytes,const char * __restrict__ _Format,const struct tm * __restrict__ _Tm);
     150                 :             :   _CRTIMP size_t __cdecl _strftime_l(char * __restrict__ _Buf,size_t _Max_size,const char * __restrict__ _Format,const struct tm * __restrict__ _Tm,_locale_t _Locale);
     151                 :             :   _CRTIMP char *__cdecl _strdate(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     152                 :             :   _SECIMP errno_t __cdecl _strdate_s (char *_Buf,size_t _SizeInBytes);
     153                 :             :   _CRTIMP char *__cdecl _strtime(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     154                 :             :   _SECIMP errno_t __cdecl _strtime_s (char *_Buf ,size_t _SizeInBytes);
     155                 :             :   _CRTIMP __time32_t __cdecl _time32(__time32_t *_Time);
     156                 :             : #ifdef _UCRT
     157                 :             :   _CRTIMP int __cdecl _timespec32_get(struct _timespec32 *_Ts, int _Base);
     158                 :             : #endif
     159                 :             :   _CRTIMP __time32_t __cdecl _mktime32(struct tm *_Tm);
     160                 :             :   _CRTIMP __time32_t __cdecl _mkgmtime32(struct tm *_Tm);
     161                 :             : 
     162                 :             : #if defined (_POSIX_) || defined(__GNUC__)
     163                 :             :   void __cdecl tzset(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
     164                 :             : #endif
     165                 :             : #if !defined (_POSIX_)
     166                 :             : #ifndef _UCRT
     167                 :             :   _CRTIMP
     168                 :             : #endif
     169                 :             :   void __cdecl _tzset(void);
     170                 :             : #endif
     171                 :             : 
     172                 :             :   _CRTIMP double __cdecl _difftime64(__time64_t _Time1,__time64_t _Time2);
     173                 :             :   _CRTIMP char *__cdecl _ctime64(const __time64_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     174                 :             :   _SECIMP errno_t __cdecl _ctime64_s (char *_Buf,size_t _SizeInBytes,const __time64_t *_Time);
     175                 :             :   _CRTIMP struct tm *__cdecl _gmtime64(const __time64_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     176                 :             :   _SECIMP errno_t __cdecl _gmtime64_s (struct tm *_Tm,const __time64_t *_Time);
     177                 :             :   _CRTIMP struct tm *__cdecl _localtime64(const __time64_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     178                 :             :   _SECIMP errno_t __cdecl _localtime64_s (struct tm *_Tm,const __time64_t *_Time);
     179                 :             :   _CRTIMP __time64_t __cdecl _mktime64(struct tm *_Tm);
     180                 :             :   _CRTIMP __time64_t __cdecl _mkgmtime64(struct tm *_Tm);
     181                 :             :   _CRTIMP __time64_t __cdecl _time64(__time64_t *_Time);
     182                 :             : #ifdef _UCRT
     183                 :             :   _CRTIMP int __cdecl _timespec64_get(struct _timespec64 *_Ts, int _Base);
     184                 :             : #endif
     185                 :             :   unsigned __cdecl _getsystime(struct tm *_Tm);
     186                 :             :   unsigned __cdecl _setsystime(struct tm *_Tm,unsigned _MilliSec);
     187                 :             : 
     188                 :             : #ifndef _WTIME_DEFINED
     189                 :             :   _CRTIMP wchar_t *__cdecl _wasctime(const struct tm *_Tm);
     190                 :             :   _SECIMP errno_t __cdecl _wasctime_s (wchar_t *_Buf,size_t _SizeInWords,const struct tm *_Tm);
     191                 :             :   wchar_t *__cdecl _wctime32(const __time32_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     192                 :             :   _SECIMP errno_t __cdecl _wctime32_s (wchar_t *_Buf,size_t _SizeInWords,const __time32_t *_Time);
     193                 :             :   size_t __cdecl wcsftime(wchar_t * __restrict__ _Buf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,const struct tm * __restrict__ _Tm);
     194                 :             :   _CRTIMP size_t __cdecl _wcsftime_l(wchar_t * __restrict__ _Buf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,const struct tm * __restrict__ _Tm,_locale_t _Locale);
     195                 :             :   _CRTIMP wchar_t *__cdecl _wstrdate(wchar_t *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     196                 :             :   _SECIMP errno_t __cdecl _wstrdate_s (wchar_t *_Buf,size_t _SizeInWords);
     197                 :             :   _CRTIMP wchar_t *__cdecl _wstrtime(wchar_t *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     198                 :             :   _SECIMP errno_t __cdecl _wstrtime_s (wchar_t *_Buf,size_t _SizeInWords);
     199                 :             :   _CRTIMP wchar_t *__cdecl _wctime64(const __time64_t *_Time) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     200                 :             :   _SECIMP errno_t __cdecl _wctime64_s (wchar_t *_Buf,size_t _SizeInWords,const __time64_t *_Time);
     201                 :             : 
     202                 :             : #if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
     203                 :             : #define _INC_WTIME_INL
     204                 :             :   wchar_t *__cdecl _wctime(const time_t *) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
     205                 :             : #ifndef __CRT__NO_INLINE
     206                 :             : #ifndef _USE_32BIT_TIME_T
     207                 :             :   __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
     208                 :             : #else
     209                 :             :   __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
     210                 :             : #endif
     211                 :             : #endif /* __CRT__NO_INLINE */
     212                 :             : #endif
     213                 :             : 
     214                 :             : #if !defined (RC_INVOKED) && !defined (_INC_WTIME_S_INL)
     215                 :             : #define _INC_WTIME_S_INL
     216                 :             :   errno_t __cdecl _wctime_s(wchar_t *, size_t, const time_t *);
     217                 :             : #ifndef __CRT__NO_INLINE
     218                 :             : #ifndef _USE_32BIT_TIME_T
     219                 :             :   __CRT_INLINE errno_t __cdecl _wctime_s (wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime64_s (_Buffer,_SizeInWords,_Time); }
     220                 :             : #else
     221                 :             :   __CRT_INLINE errno_t __cdecl _wctime_s (wchar_t *_Buffer,size_t _SizeInWords,const time_t *_Time) { return _wctime32_s (_Buffer,_SizeInWords,_Time); }
     222                 :             : #endif
     223                 :             : #endif  /* __CRT__NO_INLINE */
     224                 :             : #endif
     225                 :             : 
     226                 :             : #define _WTIME_DEFINED
     227                 :             : #endif
     228                 :             : 
     229                 :             : #ifndef RC_INVOKED
     230                 :             : 
     231                 :             : #ifdef _USE_32BIT_TIME_T
     232                 :             : static __inline time_t __CRTDECL time(time_t *_Time) { return _time32(_Time); }
     233                 :             : #ifdef _UCRT
     234                 :             : static __inline int __CRTDECL timespec_get(struct timespec* _Ts, int _Base) { return _timespec32_get((struct _timespec32*)_Ts, _Base); }
     235                 :             : #endif
     236                 :             : static __inline double __CRTDECL difftime(time_t _Time1,time_t _Time2)  { return _difftime32(_Time1,_Time2); }
     237                 :             : static __inline struct tm *__CRTDECL localtime(const time_t *_Time) { return _localtime32(_Time); }
     238                 :             : static __inline errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime32_s(_Tm,_Time); }
     239                 :             : static __inline struct tm *__CRTDECL gmtime(const time_t *_Time) { return _gmtime32(_Time); }
     240                 :             : static __inline errno_t __CRTDECL gmtime_s(struct tm *_Tm, const time_t *_Time)   { return _gmtime32_s(_Tm, _Time); }
     241                 :             : static __inline char *__CRTDECL ctime(const time_t *_Time) { return _ctime32(_Time); }
     242                 :             : static __inline errno_t __CRTDECL ctime_s(char *_Buf,size_t _SizeInBytes,const time_t *_Time) { return _ctime32_s(_Buf,_SizeInBytes,_Time); }
     243                 :             : static __inline time_t __CRTDECL mktime(struct tm *_Tm) { return _mktime32(_Tm); }
     244                 :             : static __inline time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
     245                 :             : #else
     246                 :         115 : static __inline time_t __CRTDECL time(time_t *_Time) { return _time64(_Time); }
     247                 :             : #ifdef _UCRT
     248                 :             : static __inline int __CRTDECL timespec_get(struct timespec* _Ts, int _Base) { return _timespec64_get((struct _timespec64*)_Ts, _Base); }
     249                 :             : #endif
     250                 :             : static __inline double __CRTDECL difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
     251                 :             : static __inline struct tm *__CRTDECL localtime(const time_t *_Time) { return _localtime64(_Time); }
     252                 :             : static __inline errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t *_Time) { return _localtime64_s(_Tm,_Time); }
     253                 :             : static __inline struct tm *__CRTDECL gmtime(const time_t *_Time) { return _gmtime64(_Time); }
     254                 :             : static __inline errno_t __CRTDECL gmtime_s(struct tm *_Tm, const time_t *_Time) { return _gmtime64_s(_Tm, _Time); }
     255                 :             : static __inline char *__CRTDECL ctime(const time_t *_Time) { return _ctime64(_Time); }
     256                 :             : static __inline errno_t __CRTDECL ctime_s(char *_Buf,size_t _SizeInBytes,const time_t *_Time) { return _ctime64_s(_Buf,_SizeInBytes,_Time); }
     257                 :             : static __inline time_t __CRTDECL mktime(struct tm *_Tm) { return _mktime64(_Tm); }
     258                 :             : static __inline time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
     259                 :             : #endif
     260                 :             : 
     261                 :             : #endif /* !RC_INVOKED */
     262                 :             : 
     263                 :             : #if !defined(NO_OLDNAMES) || defined(_POSIX)
     264                 :             : #define CLK_TCK CLOCKS_PER_SEC
     265                 :             : 
     266                 :             : #ifdef _UCRT
     267                 :             : #define __MINGW_ATTRIB_DEPRECATED_UCRT \
     268                 :             :     __MINGW_ATTRIB_DEPRECATED_MSG( \
     269                 :             :         "Only provided for source compatibility; this variable might " \
     270                 :             :         "not always be accurate when linking to UCRT.")
     271                 :             : #else
     272                 :             : #define __MINGW_ATTRIB_DEPRECATED_UCRT
     273                 :             : #endif
     274                 :             : 
     275                 :             :   _CRTIMP extern int daylight __MINGW_ATTRIB_DEPRECATED_UCRT;
     276                 :             :   _CRTIMP extern long timezone __MINGW_ATTRIB_DEPRECATED_UCRT;
     277                 :             :   _CRTIMP extern char *tzname[2] __MINGW_ATTRIB_DEPRECATED_UCRT;
     278                 :             :   void __cdecl tzset(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
     279                 :             : #endif
     280                 :             : 
     281                 :             : #include <_timeval.h>
     282                 :             : 
     283                 :             : #ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
     284                 :             : #define _TIMEZONE_DEFINED
     285                 :             : struct timezone {
     286                 :             :   int tz_minuteswest;
     287                 :             :   int tz_dsttime;
     288                 :             : };
     289                 :             : 
     290                 :             :   extern int __cdecl mingw_gettimeofday (struct timeval *p, struct timezone *z);
     291                 :             : #endif /* _TIMEZONE_DEFINED */
     292                 :             : 
     293                 :             : #pragma pack(pop)
     294                 :             : 
     295                 :             : #if defined(_POSIX_C_SOURCE) && !defined(_POSIX_THREAD_SAFE_FUNCTIONS)
     296                 :             : #define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
     297                 :             : #endif
     298                 :             : 
     299                 :             : #ifdef _POSIX_THREAD_SAFE_FUNCTIONS
     300                 :             : __forceinline struct tm *__CRTDECL localtime_r(const time_t *_Time, struct tm *_Tm) {
     301                 :             :   return localtime_s(_Tm, _Time) ? NULL : _Tm;
     302                 :             : }
     303                 :             : __forceinline struct tm *__CRTDECL gmtime_r(const time_t *_Time, struct tm *_Tm) {
     304                 :             :   return gmtime_s(_Tm, _Time) ? NULL : _Tm;
     305                 :             : }
     306                 :             : __forceinline char *__CRTDECL ctime_r(const time_t *_Time, char *_Str) {
     307                 :             :   return ctime_s(_Str, 0x7fffffff, _Time) ? NULL : _Str;
     308                 :             : }
     309                 :             : __forceinline char *__CRTDECL asctime_r(const struct tm *_Tm, char * _Str) {
     310                 :             :   return asctime_s(_Str, 0x7fffffff, _Tm) ? NULL : _Str;
     311                 :             : }
     312                 :             : #endif
     313                 :             : 
     314                 :             : #ifdef __cplusplus
     315                 :             : }
     316                 :             : #endif
     317                 :             : 
     318                 :             : /* POSIX 2008 says clock_gettime and timespec are defined in time.h header,
     319                 :             :    but other systems - like Linux, Solaris, etc - tend to declare such
     320                 :             :    recent extensions only if the following guards are met.  */
     321                 :             : #if !defined(IN_WINPTHREAD) && \
     322                 :             :         ((!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
     323                 :             :          (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__))
     324                 :             : #include <pthread_time.h>
     325                 :             : #endif
     326                 :             : 
     327                 :             : #endif /* End _TIME_H_ */
     328                 :             : 
        

Generated by: LCOV version 2.0-1