time.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the w64 mingw-runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER within this package.
  5. */
  6. #ifndef _TIME_H_
  7. #define _TIME_H_
  8. #include <_mingw.h>
  9. #ifndef _WIN32
  10. #error Only Win32 target is supported!
  11. #endif
  12. #pragma pack(push,_CRT_PACKING)
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #ifndef _CRTIMP
  17. #define _CRTIMP __declspec(dllimport)
  18. #endif
  19. #ifndef _WCHAR_T_DEFINED
  20. #define _WCHAR_T_DEFINED
  21. typedef unsigned short wchar_t;
  22. #endif
  23. #ifndef _TIME32_T_DEFINED
  24. #define _TIME32_T_DEFINED
  25. typedef long __time32_t;
  26. #endif
  27. #ifndef _TIME64_T_DEFINED
  28. #define _TIME64_T_DEFINED
  29. #if _INTEGRAL_MAX_BITS >= 64
  30. #if defined(__GNUC__) && defined(__STRICT_ANSI__)
  31. typedef int _time64_t __attribute__ ((mode (DI)));
  32. #else
  33. typedef __int64 __time64_t;
  34. #endif
  35. #endif
  36. #endif
  37. #ifndef _TIME_T_DEFINED
  38. #define _TIME_T_DEFINED
  39. #ifdef _USE_32BIT_TIME_T
  40. typedef __time32_t time_t;
  41. #else
  42. typedef __time64_t time_t;
  43. #endif
  44. #endif
  45. #ifndef _CLOCK_T_DEFINED
  46. #define _CLOCK_T_DEFINED
  47. typedef long clock_t;
  48. #endif
  49. #ifndef _SIZE_T_DEFINED
  50. #define _SIZE_T_DEFINED
  51. #undef size_t
  52. #ifdef _WIN64
  53. #if defined(__GNUC__) && defined(__STRICT_ANSI__)
  54. typedef unsigned int size_t __attribute__ ((mode (DI)));
  55. #else
  56. typedef unsigned __int64 size_t;
  57. #endif
  58. #else
  59. typedef unsigned int size_t;
  60. #endif
  61. #endif
  62. #ifndef _SSIZE_T_DEFINED
  63. #define _SSIZE_T_DEFINED
  64. #undef ssize_t
  65. #ifdef _WIN64
  66. #if defined(__GNUC__) && defined(__STRICT_ANSI__)
  67. typedef int ssize_t __attribute__ ((mode (DI)));
  68. #else
  69. typedef __int64 ssize_t;
  70. #endif
  71. #else
  72. typedef int ssize_t;
  73. #endif
  74. #endif
  75. #ifndef NULL
  76. #ifdef __cplusplus
  77. #define NULL 0
  78. #else
  79. #define NULL ((void *)0)
  80. #endif
  81. #endif
  82. #ifdef _USE_32BIT_TIME_T
  83. #define _localtime32 localtime
  84. #define _difftime32 difftime
  85. #define _ctime32 ctime
  86. #define _gmtime32 gmtime
  87. #define _mktime32 mktime
  88. #define _time32 time
  89. #endif
  90. #ifndef _TM_DEFINED
  91. #define _TM_DEFINED
  92. struct tm {
  93. int tm_sec;
  94. int tm_min;
  95. int tm_hour;
  96. int tm_mday;
  97. int tm_mon;
  98. int tm_year;
  99. int tm_wday;
  100. int tm_yday;
  101. int tm_isdst;
  102. };
  103. #endif
  104. #define CLOCKS_PER_SEC 1000
  105. __MINGW_IMPORT int _daylight;
  106. __MINGW_IMPORT long _dstbias;
  107. __MINGW_IMPORT long _timezone;
  108. __MINGW_IMPORT char * _tzname[2];
  109. _CRTIMP errno_t __cdecl _get_daylight(int *_Daylight);
  110. _CRTIMP errno_t __cdecl _get_dstbias(long *_Daylight_savings_bias);
  111. _CRTIMP errno_t __cdecl _get_timezone(long *_Timezone);
  112. _CRTIMP errno_t __cdecl _get_tzname(size_t *_ReturnValue,char *_Buffer,size_t _SizeInBytes,int _Index);
  113. char *__cdecl asctime(const struct tm *_Tm);
  114. _CRTIMP char *__cdecl _ctime32(const __time32_t *_Time);
  115. clock_t __cdecl clock(void);
  116. _CRTIMP double __cdecl _difftime32(__time32_t _Time1,__time32_t _Time2);
  117. _CRTIMP struct tm *__cdecl _gmtime32(const __time32_t *_Time);
  118. _CRTIMP struct tm *__cdecl _localtime32(const __time32_t *_Time);
  119. size_t __cdecl strftime(char *_Buf,size_t _SizeInBytes,const char *_Format,const struct tm *_Tm);
  120. _CRTIMP size_t __cdecl _strftime_l(char *_Buf,size_t _Max_size,const char *_Format,const struct tm *_Tm,_locale_t _Locale);
  121. _CRTIMP char *__cdecl _strdate(char *_Buffer);
  122. _CRTIMP char *__cdecl _strtime(char *_Buffer);
  123. _CRTIMP __time32_t __cdecl _time32(__time32_t *_Time);
  124. _CRTIMP __time32_t __cdecl _mktime32(struct tm *_Tm);
  125. _CRTIMP __time32_t __cdecl _mkgmtime32(struct tm *_Tm);
  126. #if defined (_POSIX_) || defined(__GNUC__)
  127. void __cdecl tzset(void);
  128. #else
  129. _CRTIMP void __cdecl _tzset(void);
  130. #endif
  131. #if _INTEGRAL_MAX_BITS >= 64
  132. double __cdecl _difftime64(__time64_t _Time1,__time64_t _Time2);
  133. _CRTIMP char *__cdecl _ctime64(const __time64_t *_Time);
  134. _CRTIMP struct tm *__cdecl _gmtime64(const __time64_t *_Time);
  135. _CRTIMP struct tm *__cdecl _localtime64(const __time64_t *_Time);
  136. _CRTIMP __time64_t __cdecl _mktime64(struct tm *_Tm);
  137. _CRTIMP __time64_t __cdecl _mkgmtime64(struct tm *_Tm);
  138. _CRTIMP __time64_t __cdecl _time64(__time64_t *_Time);
  139. #endif
  140. unsigned __cdecl _getsystime(struct tm *_Tm);
  141. unsigned __cdecl _setsystime(struct tm *_Tm,unsigned _MilliSec);
  142. #ifndef _SIZE_T_DEFINED
  143. #define _SIZE_T_DEFINED
  144. #ifdef _WIN64
  145. #if defined(__GNUC__) && defined(__STRICT_ANSI__)
  146. typedef unsigned int size_t __attribute__ ((mode (DI)));
  147. #else
  148. typedef unsigned __int64 size_t;
  149. #endif
  150. #else
  151. typedef unsigned long size_t;
  152. #endif
  153. #endif
  154. #ifndef _SSIZE_T_DEFINED
  155. #define _SSIZE_T_DEFINED
  156. #ifdef _WIN64
  157. #if defined(__GNUC__) && defined(__STRICT_ANSI__)
  158. typedef int ssize_t __attribute__ ((mode (DI)));
  159. #else
  160. typedef __int64 ssize_t;
  161. #endif
  162. #else
  163. typedef long ssize_t;
  164. #endif
  165. #endif
  166. #ifndef _WTIME_DEFINED
  167. _CRTIMP wchar_t *__cdecl _wasctime(const struct tm *_Tm);
  168. _CRTIMP wchar_t *__cdecl _wctime32(const __time32_t *_Time);
  169. size_t __cdecl wcsftime(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm);
  170. _CRTIMP size_t __cdecl _wcsftime_l(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm,_locale_t _Locale);
  171. _CRTIMP wchar_t *__cdecl _wstrdate(wchar_t *_Buffer);
  172. _CRTIMP wchar_t *__cdecl _wstrtime(wchar_t *_Buffer);
  173. #if _INTEGRAL_MAX_BITS >= 64
  174. _CRTIMP wchar_t *__cdecl _wctime64(const __time64_t *_Time);
  175. #endif
  176. #if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
  177. #define _INC_WTIME_INL
  178. #ifdef _USE_32BIT_TIME_T
  179. __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
  180. #else
  181. __CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
  182. #endif
  183. #endif
  184. #define _WTIME_DEFINED
  185. #endif
  186. #ifndef RC_INVOKED
  187. double __cdecl difftime(time_t _Time1,time_t _Time2);
  188. char *__cdecl ctime(const time_t *_Time);
  189. struct tm *__cdecl gmtime(const time_t *_Time);
  190. struct tm *__cdecl localtime(const time_t *_Time);
  191. struct tm *__cdecl localtime_r(const time_t *_Time,struct tm *);
  192. time_t __cdecl mktime(struct tm *_Tm);
  193. time_t __cdecl _mkgmtime(struct tm *_Tm);
  194. time_t __cdecl time(time_t *_Time);
  195. #ifdef _USE_32BIT_TIME_T
  196. #if 0
  197. __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); }
  198. __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime32(_Time); }
  199. __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime32(_Time); }
  200. __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime32(_Time); }
  201. __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime32(_Tm); }
  202. __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
  203. __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time32(_Time); }
  204. #endif
  205. #else
  206. __CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
  207. __CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime64(_Time); }
  208. __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime64(_Time); }
  209. __CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
  210. __CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime64(_Tm); }
  211. __CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
  212. __CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
  213. #endif
  214. #endif
  215. #if !defined(NO_OLDNAMES) || defined(_POSIX)
  216. #define CLK_TCK CLOCKS_PER_SEC
  217. __MINGW_IMPORT int daylight;
  218. __MINGW_IMPORT long dstbias;
  219. __MINGW_IMPORT long timezone;
  220. __MINGW_IMPORT char *tzname[2];
  221. void __cdecl tzset(void);
  222. #endif
  223. #ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
  224. #define _TIMEVAL_DEFINED
  225. struct timeval {
  226. long tv_sec;
  227. long tv_usec;
  228. };
  229. #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  230. #define timercmp(tvp,uvp,cmp) ((tvp)->tv_sec cmp (uvp)->tv_sec || (tvp)->tv_sec==(uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  231. #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
  232. #endif /* _TIMEVAL_DEFINED */
  233. #ifndef __STRICT_ANSI__
  234. #ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
  235. #define _TIMEZONE_DEFINED
  236. struct timezone {
  237. int tz_minuteswest;
  238. int tz_dsttime;
  239. };
  240. extern int __cdecl mingw_gettimeofday (struct timeval *p, struct timezone *z);
  241. #endif
  242. #endif /* __STRICT_ANSI__ */
  243. #ifdef __cplusplus
  244. }
  245. #endif
  246. #pragma pack(pop)
  247. #include <sec_api/time_s.h>
  248. /* Adding timespec definition. */
  249. #include <sys/timeb.h>
  250. #endif /* End _TIME_H_ */