Advertisement
Guest User

Untitled

a guest
Aug 31st, 2013
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.59 KB | None | 0 0
  1. /*
  2.  * time.h
  3.  * This file has no copyright assigned and is placed in the Public Domain.
  4.  * This file is a part of the mingw-runtime package.
  5.  * No warranty is given; refer to the file DISCLAIMER within the package.
  6.  *
  7.  * Date and time functions and types.
  8.  *
  9.  */
  10.  
  11. #ifndef _TIME_H_
  12. #define _TIME_H_
  13.  
  14. /* All the headers include this file. */
  15. #include <_mingw.h>
  16.  
  17. #define __need_wchar_t
  18. #define __need_size_t
  19. #define __need_NULL
  20. #ifndef RC_INVOKED
  21. #include <stddef.h>
  22. #endif  /* Not RC_INVOKED */
  23.  
  24. /*
  25.  * Number of clock ticks per second. A clock tick is the unit by which
  26.  * processor time is measured and is returned by 'clock'.
  27.  */
  28. #define CLOCKS_PER_SEC  ((clock_t)1000)
  29. #define CLK_TCK     CLOCKS_PER_SEC
  30.  
  31.  
  32. #ifndef RC_INVOKED
  33.  
  34. /*
  35.  * A type for storing the current time and date. This is the number of
  36.  * seconds since midnight Jan 1, 1970.
  37.  * NOTE: This is also defined in non-ISO sys/types.h.
  38.  */
  39. #ifndef _TIME32_T_DEFINED
  40. typedef __int32 __time32_t;
  41. #define _TIME32_T_DEFINED
  42. #endif
  43.  
  44. #ifndef __STRICT_ANSI__
  45. /* A 64-bit time_t to get to Y3K */
  46. #ifndef _TIME64_T_DEFINED
  47. typedef __int64 __time64_t;
  48. #define _TIME64_T_DEFINED
  49. #endif
  50. #endif
  51.  
  52. #ifndef _TIME_T_DEFINED
  53. /* FIXME __STRICT_ANSI__ ! */
  54. #if __MSVCRT_VERSION__ >= 0x0800
  55. #ifndef _USE_32BIT_TIME_T
  56. typedef __time64_t time_t;
  57. #else
  58. typedef __time32_t time_t;
  59. #endif /* !_USE_32BIT_TIME_T */
  60. #else
  61. typedef __time32_t time_t;
  62. #endif /* __MSVCRT_VERSION__ >= 0x0800 */
  63. #define _TIME_T_DEFINED
  64. #endif
  65.  
  66.  
  67. /*
  68.  * A type for measuring processor time (in clock ticks).
  69.  */
  70. #ifndef _CLOCK_T_DEFINED
  71. typedef long    clock_t;
  72. #define _CLOCK_T_DEFINED
  73. #endif
  74.  
  75. #ifndef _TM_DEFINED
  76. /*
  77.  * A structure for storing all kinds of useful information about the
  78.  * current (or another) time.
  79.  */
  80. struct tm
  81. {
  82.     int tm_sec;     /* Seconds: 0-59 (K&R says 0-61?) */
  83.     int tm_min;     /* Minutes: 0-59 */
  84.     int tm_hour;    /* Hours since midnight: 0-23 */
  85.     int tm_mday;    /* Day of the month: 1-31 */
  86.     int tm_mon;     /* Months *since* january: 0-11 */
  87.     int tm_year;    /* Years since 1900 */
  88.     int tm_wday;    /* Days since Sunday (0-6) */
  89.     int tm_yday;    /* Days since Jan. 1: 0-365 */
  90.     int tm_isdst;   /* +1 Daylight Savings Time, 0 No DST,
  91.                  * -1 don't know */
  92. };
  93. #define _TM_DEFINED
  94. #endif
  95.  
  96. #ifdef  __cplusplus
  97. extern "C" {
  98. #endif
  99.  
  100. _CRTIMP clock_t __cdecl __MINGW_NOTHROW clock (void);
  101. #if __MSVCRT_VERSION__ < 0x0800
  102. _CRTIMP time_t __cdecl __MINGW_NOTHROW  time (time_t*);
  103. _CRTIMP double __cdecl __MINGW_NOTHROW  difftime (time_t, time_t);
  104. _CRTIMP time_t __cdecl __MINGW_NOTHROW  mktime (struct tm*);
  105. #endif
  106.  
  107. /*
  108.  * These functions write to and return pointers to static buffers that may
  109.  * be overwritten by other function calls. Yikes!
  110.  *
  111.  * NOTE: localtime, and perhaps the others of the four functions grouped
  112.  * below may return NULL if their argument is not 'acceptable'. Also note
  113.  * that calling asctime with a NULL pointer will produce an Invalid Page
  114.  * Fault and crap out your program. Guess how I know. Hint: stat called on
  115.  * a directory gives 'invalid' times in st_atime etc...
  116.  */
  117. _CRTIMP char* __cdecl __MINGW_NOTHROW       asctime (const struct tm*);
  118. #if __MSVCRT_VERSION__ < 0x0800
  119. _CRTIMP char* __cdecl __MINGW_NOTHROW       ctime (const time_t*);
  120. _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW gmtime (const time_t*);
  121. _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW localtime (const time_t*);
  122. #endif
  123.  
  124. _CRTIMP size_t __cdecl __MINGW_NOTHROW      strftime (char*, size_t, const char*, const struct tm*);
  125.  
  126. #ifndef __STRICT_ANSI__
  127.  
  128. extern _CRTIMP void __cdecl __MINGW_NOTHROW _tzset (void);
  129.  
  130. #ifndef _NO_OLDNAMES
  131. extern _CRTIMP void __cdecl __MINGW_NOTHROW tzset (void);
  132. #endif
  133.  
  134. _CRTIMP char* __cdecl __MINGW_NOTHROW   _strdate(char*);
  135. _CRTIMP char* __cdecl __MINGW_NOTHROW   _strtime(char*);
  136.  
  137. /* These require newer versions of msvcrt.dll (6.10 or higher). */
  138. #if __MSVCRT_VERSION__ >= 0x0601
  139. _CRTIMP __time64_t __cdecl __MINGW_NOTHROW  _time64( __time64_t*);
  140. _CRTIMP __time64_t __cdecl __MINGW_NOTHROW  _mktime64 (struct tm*);
  141. _CRTIMP char* __cdecl __MINGW_NOTHROW _ctime64 (const __time64_t*);
  142. _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW _gmtime64 (const __time64_t*);
  143. _CRTIMP struct tm*  __cdecl __MINGW_NOTHROW _localtime64 (const __time64_t*);
  144. #endif /* __MSVCRT_VERSION__ >= 0x0601 */
  145.  
  146. /* These require newer versions of msvcrt.dll (8.00 or higher). */
  147. #if __MSVCRT_VERSION__ >= 0x0800
  148. _CRTIMP __time32_t __cdecl __MINGW_NOTHROW  _time32 (__time32_t*);
  149. _CRTIMP double     __cdecl __MINGW_NOTHROW  _difftime32 (__time32_t, __time32_t);
  150. _CRTIMP double     __cdecl __MINGW_NOTHROW  _difftime64 (__time64_t, __time64_t);
  151. _CRTIMP __time32_t __cdecl __MINGW_NOTHROW  _mktime32 (struct tm*);
  152. _CRTIMP __time32_t __cdecl __MINGW_NOTHROW  _mkgmtime32 (struct tm*);
  153. _CRTIMP __time64_t __cdecl __MINGW_NOTHROW  _mkgmtime64 (struct tm*);
  154. _CRTIMP char*      __cdecl __MINGW_NOTHROW  _ctime32 (const __time32_t*);
  155. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW  _gmtime32 (const __time32_t*);
  156. _CRTIMP struct tm* __cdecl __MINGW_NOTHROW  _localtime32 (const __time32_t*);
  157. #ifndef _USE_32BIT_TIME_T
  158. _CRTALIAS time_t       __cdecl __MINGW_NOTHROW  time (time_t* _v)         { return(_time64 (_v)); }
  159. _CRTALIAS double       __cdecl __MINGW_NOTHROW  difftime (time_t _v1, time_t _v2) { return(_difftime64 (_v1,_v2)); }
  160. _CRTALIAS time_t       __cdecl __MINGW_NOTHROW  mktime (struct tm* _v)        { return(_mktime64 (_v)); }
  161. _CRTALIAS time_t       __cdecl __MINGW_NOTHROW  _mkgmtime (struct tm* _v)     { return(_mkgmtime64 (_v)); }
  162. _CRTALIAS char*        __cdecl __MINGW_NOTHROW  ctime (const time_t* _v)      { return(_ctime64 (_v)); }
  163. _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW  gmtime (const time_t* _v)     { return(_gmtime64 (_v)); }
  164. _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW  localtime (const time_t* _v)      { return(_localtime64 (_v)); }
  165. #else
  166. _CRTALIAS time_t       __cdecl __MINGW_NOTHROW  time (time_t* _v)         { return(_time32 (_v)); }
  167. _CRTALIAS double       __cdecl __MINGW_NOTHROW  difftime (time_t _v1, time_t _v2) { return(_difftime32 (_v1,_v2)); }
  168. _CRTALIAS time_t       __cdecl __MINGW_NOTHROW  mktime (struct tm* _v)        { return(_mktime32 (_v)); }
  169. _CRTALIAS time_t       __cdecl __MINGW_NOTHROW  _mkgmtime (struct tm* _v)     { return(_mkgmtime32 (_v)); }
  170. _CRTALIAS char*        __cdecl __MINGW_NOTHROW  ctime (const time_t* _v)      { return(_ctime32 (_v)); }
  171. _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW  gmtime (const time_t* _v)     { return(_gmtime32 (_v)); }
  172. _CRTALIAS struct tm*       __cdecl __MINGW_NOTHROW  localtime (const time_t* _v)      { return(_localtime32 (_v)); }
  173. #endif /* !_USE_32BIT_TIME_T */
  174. #endif /* __MSVCRT_VERSION__ >= 0x0800 */
  175.  
  176.  
  177. /*
  178.  * _daylight: non zero if daylight savings time is used.
  179.  * _timezone: difference in seconds between GMT and local time.
  180.  * _tzname: standard/daylight savings time zone names (an array with two
  181.  *          elements).
  182.  */
  183. #ifdef __MSVCRT__
  184.  
  185. /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
  186. extern _CRTIMP int* __cdecl __MINGW_NOTHROW __p__daylight (void);
  187. extern _CRTIMP long* __cdecl __MINGW_NOTHROW    __p__timezone (void);
  188. extern _CRTIMP char** __cdecl __MINGW_NOTHROW   __p__tzname (void);
  189.  
  190. __MINGW_IMPORT int  _daylight;
  191. __MINGW_IMPORT long _timezone;
  192. __MINGW_IMPORT char     *_tzname[2];
  193.  
  194. #else /* not __MSVCRT (ie. crtdll) */
  195.  
  196. #ifndef __DECLSPEC_SUPPORTED
  197.  
  198. extern int* _imp___daylight_dll;
  199. extern long*    _imp___timezone_dll;
  200. extern char**   _imp___tzname;
  201.  
  202. #define _daylight   (*_imp___daylight_dll)
  203. #define _timezone   (*_imp___timezone_dll)
  204. #define _tzname     (*_imp___tzname)
  205.  
  206. #else /* __DECLSPEC_SUPPORTED */
  207.  
  208. __MINGW_IMPORT int  _daylight_dll;
  209. __MINGW_IMPORT long _timezone_dll;
  210. __MINGW_IMPORT char*    _tzname[2];
  211.  
  212. #define _daylight   _daylight_dll
  213. #define _timezone   _timezone_dll
  214.  
  215. #endif /* __DECLSPEC_SUPPORTED */
  216.  
  217. #endif /* not __MSVCRT__ */
  218.  
  219. #endif  /* Not __STRICT_ANSI__ */
  220.  
  221. #ifndef _NO_OLDNAMES
  222.  
  223. #ifdef __MSVCRT__
  224.  
  225. /* These go in the oldnames import library for MSVCRT. */
  226. __MINGW_IMPORT int  daylight;
  227. __MINGW_IMPORT long timezone;
  228. __MINGW_IMPORT char     *tzname[2];
  229.  
  230. #else /* not __MSVCRT__ */
  231.  
  232. /* CRTDLL is royally messed up when it comes to these macros.
  233.    TODO: import and alias these via oldnames import library instead
  234.    of macros.  */
  235.  
  236. #define daylight        _daylight
  237. /* NOTE: timezone not defined as macro because it would conflict with
  238.    struct timezone in sys/time.h.
  239.    Also, tzname used to a be macro, but now it's in moldname. */
  240. __MINGW_IMPORT char     *tzname[2];
  241.  
  242. #endif /* not __MSVCRT__ */
  243.  
  244. #endif  /* Not _NO_OLDNAMES */
  245.  
  246. #ifndef _WTIME_DEFINED
  247. /* wide function prototypes, also declared in wchar.h */
  248. #ifndef __STRICT_ANSI__
  249. #ifdef __MSVCRT__
  250. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW    _wasctime(const struct tm*);
  251. #if __MSVCRT_VERSION__ < 0x0800
  252. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW    _wctime(const time_t*);
  253. #endif
  254. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW    _wstrdate(wchar_t*);
  255. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW    _wstrtime(wchar_t*);
  256. #if __MSVCRT_VERSION__ >= 0x0601
  257. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW    _wctime64 (const __time64_t*);
  258. #endif
  259. #if __MSVCRT_VERSION__ >= 0x0800
  260. _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW    _wctime32 (const __time32_t*);
  261. #ifndef _USE_32BIT_TIME_T
  262. _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW  _wctime (const time_t* _v) { return(_wctime64 (_v)); }
  263. #else
  264. _CRTALIAS wchar_t* __cdecl __MINGW_NOTHROW  _wctime (const time_t* _v) { return(_wctime32 (_v)); }
  265. #endif
  266. #endif /* __MSVCRT_VERSION__ >= 0x0800 */
  267. #endif /*  __MSVCRT__ */
  268. #endif /* __STRICT_ANSI__ */
  269. _CRTIMP size_t __cdecl __MINGW_NOTHROW      wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
  270. #define _WTIME_DEFINED
  271. #endif /* _WTIME_DEFINED */
  272.  
  273. #ifdef  __cplusplus
  274. }
  275. #endif
  276.  
  277. #endif  /* Not RC_INVOKED */
  278.  
  279. #endif  /* Not _TIME_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement