timer.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /**
  2. * @file time.h
  3. * Copyright 2012, 2013 MinGW.org project
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. */
  24. #ifndef _TIME_H
  25. #define _TIME_H
  26. #pragma GCC system_header
  27. #include <_mingw.h>
  28. #define __need_wchar_t
  29. #define __need_size_t
  30. #define __need_NULL
  31. #ifndef RC_INVOKED
  32. #include <stddef.h>
  33. #endif /* Not RC_INVOKED */
  34. /*
  35. * Number of clock ticks per second. A clock tick is the unit by which
  36. * processor time is measured and is returned by 'clock'.
  37. */
  38. #define CLOCKS_PER_SEC ((clock_t)1000)
  39. #define CLK_TCK CLOCKS_PER_SEC
  40. #ifndef RC_INVOKED
  41. /*
  42. * A type for storing the current time and date. This is the number of
  43. * seconds since midnight Jan 1, 1970.
  44. * NOTE: This is also defined in non-ISO sys/types.h.
  45. */
  46. #ifndef _TIME32_T_DEFINED
  47. typedef __int32 __time32_t;
  48. #define _TIME32_T_DEFINED
  49. #endif
  50. #ifndef _TIME64_T_DEFINED
  51. /* A 64-bit time_t to get to Y3K */
  52. typedef __int64 __time64_t;
  53. #define _TIME64_T_DEFINED
  54. #endif
  55. #ifndef _TIME_T_DEFINED
  56. # if defined(_USE_32BIT_TIME_T) && MSVCRT_VERSION >= 800
  57. typedef __time32_t time_t;
  58. # else
  59. typedef __time64_t time_t;
  60. # endif /* _USE_32BIT_TIME_T */
  61. # define _TIME_T_DEFINED
  62. #endif
  63. /*
  64. * A type for measuring processor time (in clock ticks).
  65. */
  66. #ifndef _CLOCK_T_DEFINED
  67. typedef long clock_t;
  68. #define _CLOCK_T_DEFINED
  69. #endif
  70. #ifndef _TM_DEFINED
  71. /*
  72. * A structure for storing all kinds of useful information about the
  73. * current (or another) time.
  74. */
  75. struct tm
  76. {
  77. int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
  78. int tm_min; /* Minutes: 0-59 */
  79. int tm_hour; /* Hours since midnight: 0-23 */
  80. int tm_mday; /* Day of the month: 1-31 */
  81. int tm_mon; /* Months *since* january: 0-11 */
  82. int tm_year; /* Years since 1900 */
  83. int tm_wday; /* Days since Sunday (0-6) */
  84. int tm_yday; /* Days since Jan. 1: 0-365 */
  85. int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
  86. * -1 don't know */
  87. };
  88. #define _TM_DEFINED
  89. #endif
  90. #ifdef __cplusplus
  91. extern "C" {
  92. #endif
  93. _CRTIMP clock_t __cdecl __MINGW_NOTHROW clock (void);
  94. _CRTIMP time_t __cdecl __MINGW_NOTHROW time (time_t*);
  95. _CRTIMP double __cdecl __MINGW_NOTHROW difftime (time_t, time_t);
  96. _CRTIMP time_t __cdecl __MINGW_NOTHROW mktime (struct tm*);
  97. /*
  98. * These functions write to and return pointers to static buffers that may
  99. * be overwritten by other function calls. Yikes!
  100. *
  101. * NOTE: localtime, and perhaps the others of the four functions grouped
  102. * below may return NULL if their argument is not 'acceptable'. Also note
  103. * that calling asctime with a NULL pointer will produce an Invalid Page
  104. * Fault and crap out your program. Guess how I know. Hint: stat called on
  105. * a directory gives 'invalid' times in st_atime etc...
  106. */
  107. _CRTIMP char* __cdecl __MINGW_NOTHROW asctime (const struct tm*);
  108. _CRTIMP char* __cdecl __MINGW_NOTHROW ctime (const time_t*);
  109. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t*);
  110. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t*);
  111. _CRTIMP size_t __cdecl __MINGW_NOTHROW strftime (char*, size_t, const char*, const struct tm*);
  112. #ifndef __STRICT_ANSI__
  113. extern _CRTIMP void __cdecl __MINGW_NOTHROW _tzset (void);
  114. #ifndef _NO_OLDNAMES
  115. extern _CRTIMP void __cdecl __MINGW_NOTHROW tzset (void);
  116. #endif
  117. _CRTIMP char* __cdecl __MINGW_NOTHROW _strdate(char*);
  118. _CRTIMP char* __cdecl __MINGW_NOTHROW _strtime(char*);
  119. /* These require newer versions of msvcrt.dll (6.10 or higher). */
  120. _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _time64( __time64_t*);
  121. _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mktime64 (struct tm*);
  122. _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime64 (const __time64_t*);
  123. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
  124. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
  125. /* These require newer versions of msvcrt.dll (8.00 or higher). */
  126. #ifdef MSVCRT_VERSION >= 800
  127. _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _time32 (__time32_t*);
  128. _CRTIMP double __cdecl __MINGW_NOTHROW _difftime32 (__time32_t, __time32_t);
  129. _CRTIMP double __cdecl __MINGW_NOTHROW _difftime64 (__time64_t, __time64_t);
  130. _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mktime32 (struct tm*);
  131. _CRTIMP __time32_t __cdecl __MINGW_NOTHROW _mkgmtime32 (struct tm*);
  132. _CRTIMP __time64_t __cdecl __MINGW_NOTHROW _mkgmtime64 (struct tm*);
  133. _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime32 (const __time32_t*);
  134. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _gmtime32 (const __time32_t*);
  135. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW _localtime32(const __time32_t*);
  136. #if defined(_USE_32BIT_TIME_T)
  137. _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v)
  138. { return(_time32 (_v)); }
  139. _CRTALIAS double __cdecl __MINGW_NOTHROW difftime(time_t _v1, time_t _v2)
  140. { return(_difftime32 (_v1,_v2)); }
  141. _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v)
  142. { return(_mktime32 (_v)); }
  143. _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v)
  144. { return(_mkgmtime32 (_v)); }
  145. _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v)
  146. { return(_ctime32 (_v)); }
  147. _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v)
  148. { return(_gmtime32 (_v)); }
  149. _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v)
  150. { return(_localtime32 (_v)); }
  151. #else
  152. _CRTALIAS time_t __cdecl __MINGW_NOTHROW time (time_t* _v)
  153. { return(_time64 (_v)); }
  154. _CRTALIAS double __cdecl __MINGW_NOTHROW difftime(time_t _v1, time_t _v2)
  155. { return(_difftime64 (_v1,_v2)); }
  156. _CRTALIAS time_t __cdecl __MINGW_NOTHROW mktime (struct tm* _v)
  157. { return(_mktime64 (_v)); }
  158. _CRTALIAS time_t __cdecl __MINGW_NOTHROW _mkgmtime (struct tm* _v)
  159. { return(_mkgmtime64 (_v)); }
  160. _CRTALIAS char* __cdecl __MINGW_NOTHROW ctime (const time_t* _v)
  161. { return(_ctime64 (_v)); }
  162. _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW gmtime (const time_t* _v)
  163. { return(_gmtime64 (_v)); }
  164. _CRTALIAS struct tm* __cdecl __MINGW_NOTHROW localtime (const time_t* _v)
  165. { return(_localtime64 (_v)); }
  166. #endif /* _USE_32BIT_TIME_T */
  167. #else /* MSVCRT_VERSION < 800 */
  168. _CRTIMP time_t __cdecl __MINGW32_NOTHROW time (time_t*);
  169. _CRTIMP double __cdecl __MINGW32_NOTHROW difftime (time_t, time_t);
  170. _CRTIMP time_t __cdecl __MINGW32_NOTHROW mktime (struct tm*);
  171. _CRTIMP char* __cdecl __MINGW32_NOTRHOW ctime (const time_t*);
  172. _CRTIMP struct tm* __cdecl __MINGW32_NOTHROW gmtime (const time_t*);
  173. _CRTIMP struct tm* __cdecl __MINGW32_NOTHROW localtime (const time_t*);
  174. #endif /* MSVCRT_VERSION >= 800 */
  175. /*
  176. * _daylight: non zero if daylight savings time is used.
  177. * _timezone: difference in seconds between GMT and local time.
  178. * _tzname: standard/daylight savings time zone names (an array with two
  179. * elements).
  180. */
  181. /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
  182. extern _CRTIMP int* __cdecl __MINGW_NOTHROW __p__daylight (void);
  183. extern _CRTIMP long* __cdecl __MINGW_NOTHROW __p__timezone (void);
  184. extern _CRTIMP char** __cdecl __MINGW_NOTHROW __p__tzname (void);
  185. __MINGW_IMPORT int _daylight;
  186. __MINGW_IMPORT long _timezone;
  187. __MINGW_IMPORT char *_tzname[2];
  188. #endif /* Not __STRICT_ANSI__ */
  189. #ifndef _NO_OLDNAMES
  190. /* These go in the oldnames import library for MSVCRT. */
  191. __MINGW_IMPORT int daylight;
  192. __MINGW_IMPORT long timezone;
  193. __MINGW_IMPORT char *tzname[2];
  194. #endif /* Not _NO_OLDNAMES */
  195. #ifndef _WTIME_DEFINED
  196. /* wide function prototypes, also declared in wchar.h */
  197. #ifndef __STRICT_ANSI__
  198. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wasctime(const struct tm*);
  199. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime(const time_t*);
  200. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrdate(wchar_t*);
  201. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wstrtime(wchar_t*);
  202. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime64 (const __time64_t*);
  203. #ifdef MSVCRT_VERSION >= 800
  204. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wctime32 (const __time32_t*);
  205. #endif
  206. #ifdef _USE_32BIT_TIME_T && MSVCRT_VERSION >= 800
  207. _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime32 (_v)); }
  208. #else
  209. _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW _wctime (const time_t* _v) { return(_wctime64 (_v)); }
  210. #endif
  211. #endif /* __STRICT_ANSI__ */
  212. _CRTIMP size_t __cdecl __MINGW_NOTHROW wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
  213. #define _WTIME_DEFINED
  214. #endif /* _WTIME_DEFINED */
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218. #endif /* Not RC_INVOKED */
  219. #endif /* Not _TIME_H */