Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

316 lines
6.8 KiB

  1. /***
  2. *time.h - definitions/declarations for time routines
  3. *
  4. * Copyright (c) 1985-1995, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file has declarations of time routines and defines
  8. * the structure returned by the localtime and gmtime routines and
  9. * used by asctime.
  10. * [ANSI/System V]
  11. *
  12. * [Public]
  13. *
  14. ****/
  15. #ifndef _INC_TIME
  16. #define _INC_TIME
  17. #if !defined(_WIN32) && !defined(_MAC)
  18. #error ERROR: Only Mac or Win32 targets supported!
  19. #endif
  20. #ifdef _MSC_VER
  21. /*
  22. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  23. * alignment.
  24. */
  25. #pragma pack(push,8)
  26. #endif /* _MSC_VER */
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  31. #ifndef _CRTAPI1
  32. #if _MSC_VER >= 800 && _M_IX86 >= 300
  33. #define _CRTAPI1 __cdecl
  34. #else
  35. #define _CRTAPI1
  36. #endif
  37. #endif
  38. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  39. #ifndef _CRTAPI2
  40. #if _MSC_VER >= 800 && _M_IX86 >= 300
  41. #define _CRTAPI2 __cdecl
  42. #else
  43. #define _CRTAPI2
  44. #endif
  45. #endif
  46. /* Define _CRTIMP */
  47. #ifndef _CRTIMP
  48. #ifdef _NTSDK
  49. /* definition compatible with NT SDK */
  50. #define _CRTIMP
  51. #else /* ndef _NTSDK */
  52. /* current definition */
  53. #ifdef _DLL
  54. #define _CRTIMP __declspec(dllimport)
  55. #else /* ndef _DLL */
  56. #define _CRTIMP
  57. #endif /* _DLL */
  58. #endif /* _NTSDK */
  59. #endif /* _CRTIMP */
  60. /* Define __cdecl for non-Microsoft compilers */
  61. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  62. #define __cdecl
  63. #endif
  64. #ifndef _MAC
  65. #ifndef _WCHAR_T_DEFINED
  66. typedef unsigned short wchar_t;
  67. #define _WCHAR_T_DEFINED
  68. #endif
  69. #endif /* ndef _MAC */
  70. /* Define the implementation defined time type */
  71. #ifndef _TIME_T_DEFINED
  72. typedef long time_t; /* time value */
  73. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  74. #endif
  75. #ifndef _CLOCK_T_DEFINED
  76. typedef long clock_t;
  77. #define _CLOCK_T_DEFINED
  78. #endif
  79. #ifndef _SIZE_T_DEFINED
  80. typedef unsigned int size_t;
  81. #define _SIZE_T_DEFINED
  82. #endif
  83. /* Define NULL pointer value */
  84. #ifndef NULL
  85. #ifdef __cplusplus
  86. #define NULL 0
  87. #else
  88. #define NULL ((void *)0)
  89. #endif
  90. #endif
  91. #ifndef _TM_DEFINED
  92. struct tm {
  93. int tm_sec; /* seconds after the minute - [0,59] */
  94. int tm_min; /* minutes after the hour - [0,59] */
  95. int tm_hour; /* hours since midnight - [0,23] */
  96. int tm_mday; /* day of the month - [1,31] */
  97. int tm_mon; /* months since January - [0,11] */
  98. int tm_year; /* years since 1900 */
  99. int tm_wday; /* days since Sunday - [0,6] */
  100. int tm_yday; /* days since January 1 - [0,365] */
  101. int tm_isdst; /* daylight savings time flag */
  102. };
  103. #define _TM_DEFINED
  104. #endif
  105. /* Clock ticks macro - ANSI version */
  106. #define CLOCKS_PER_SEC 1000
  107. /* Extern declarations for the global variables used by the ctime family of
  108. * routines.
  109. */
  110. #ifdef _NTSDK
  111. #ifdef _DLL
  112. /* Declarations and definitions compatible with the NT SDK */
  113. #define _daylight (*_daylight_dll)
  114. #define _timezone (*_timezone_dll)
  115. /* non-zero if daylight savings time is used */
  116. extern int * _daylight_dll;
  117. /* difference in seconds between GMT and local time */
  118. extern long * _timezone_dll;
  119. /* standard/daylight savings time zone names */
  120. extern char ** _tzname;
  121. #else /* ndef _DLL */
  122. #ifdef _POSIX_
  123. extern char * _rule;
  124. #endif /* _POSIX_ */
  125. /* non-zero if daylight savings time is used */
  126. extern int _daylight;
  127. /* difference in seconds between GMT and local time */
  128. extern long _timezone;
  129. /* standard/daylight savings time zone names */
  130. #ifdef _POSIX_
  131. extern char * tzname[2];
  132. #else /* ndef _POSIX_ */
  133. extern char * _tzname[2];
  134. #endif /* _POSIX_ */
  135. #endif /* _DLL */
  136. #else /* ndef _NTSDK */
  137. /* Current declarations and definitions */
  138. #if defined(_DLL) && defined(_M_IX86)
  139. #define _daylight (*__p__daylight())
  140. _CRTIMP int * __cdecl __p__daylight(void);
  141. #define _timezone (*__p__timezone())
  142. _CRTIMP long * __cdecl __p__timezone(void);
  143. #define _tzname (__p__tzname())
  144. _CRTIMP char ** __cdecl __p__tzname(void);
  145. #else /* !(defined(_DLL) && defined(_M_IX86)) */
  146. /* non-zero if daylight savings time is used */
  147. _CRTIMP extern int _daylight;
  148. /* difference in seconds between GMT and local time */
  149. _CRTIMP extern long _timezone;
  150. /* standard/daylight savings time zone names */
  151. _CRTIMP extern char * _tzname[2];
  152. #endif /* defined(_DLL) && defined(_M_IX86) */
  153. #endif /* _NTSDK */
  154. /* Function prototypes */
  155. _CRTIMP char * __cdecl asctime(const struct tm *);
  156. _CRTIMP char * __cdecl ctime(const time_t *);
  157. _CRTIMP clock_t __cdecl clock(void);
  158. _CRTIMP double __cdecl difftime(time_t, time_t);
  159. _CRTIMP struct tm * __cdecl gmtime(const time_t *);
  160. _CRTIMP struct tm * __cdecl localtime(const time_t *);
  161. _CRTIMP time_t __cdecl mktime(struct tm *);
  162. _CRTIMP size_t __cdecl strftime(char *, size_t, const char *,
  163. const struct tm *);
  164. _CRTIMP char * __cdecl _strdate(char *);
  165. _CRTIMP char * __cdecl _strtime(char *);
  166. _CRTIMP time_t __cdecl time(time_t *);
  167. #ifdef _POSIX_
  168. _CRTIMP void __cdecl tzset(void);
  169. #else
  170. _CRTIMP void __cdecl _tzset(void);
  171. #endif
  172. /* --------- The following functions are OBSOLETE --------- */
  173. /* The Win32 API GetLocalTime and SetLocalTime should be used instead. */
  174. unsigned __cdecl _getsystime(struct tm *);
  175. unsigned __cdecl _setsystime(struct tm *, unsigned);
  176. /* --------- The preceding functions are OBSOLETE --------- */
  177. #ifndef _SIZE_T_DEFINED
  178. typedef unsigned int size_t;
  179. #define _SIZE_T_DEFINED
  180. #endif
  181. #ifndef _MAC
  182. #ifndef _WTIME_DEFINED
  183. /* wide function prototypes, also declared in wchar.h */
  184. _CRTIMP wchar_t * __cdecl _wasctime(const struct tm *);
  185. _CRTIMP wchar_t * __cdecl _wctime(const time_t *);
  186. _CRTIMP size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *,
  187. const struct tm *);
  188. _CRTIMP wchar_t * __cdecl _wstrdate(wchar_t *);
  189. _CRTIMP wchar_t * __cdecl _wstrtime(wchar_t *);
  190. #define _WTIME_DEFINED
  191. #endif
  192. #endif /* ndef _MAC */
  193. #if !__STDC__ || defined(_POSIX_)
  194. /* Non-ANSI names for compatibility */
  195. #define CLK_TCK CLOCKS_PER_SEC
  196. #ifdef _NTSDK
  197. /* Declarations and definitions compatible with the NT SDK */
  198. #define daylight _daylight
  199. /* timezone cannot be #defined because of <sys/timeb.h> */
  200. #ifndef _POSIX_
  201. #define tzname _tzname
  202. #define tzset _tzset
  203. #endif /* _POSIX_ */
  204. #else /* ndef _NTSDK */
  205. #if defined(_DLL) && defined(_M_IX86)
  206. #define daylight (*__p__daylight())
  207. /* timezone cannot be #defined because of <sys/timeb.h>
  208. so CRT DLL for win32s will not have timezone */
  209. _CRTIMP extern long timezone;
  210. #define tzname (__p__tzname())
  211. #else /* !(defined(_DLL) && defined(_M_IX86)) */
  212. _CRTIMP extern int daylight;
  213. _CRTIMP extern long timezone;
  214. _CRTIMP extern char * tzname[2];
  215. #endif /* !(defined(_DLL) && defined(_M_IX86)) */
  216. _CRTIMP void __cdecl tzset(void);
  217. #endif /* _NTSDK */
  218. #endif /* __STDC__ */
  219. #ifdef __cplusplus
  220. }
  221. #endif
  222. #ifdef _MSC_VER
  223. #pragma pack(pop)
  224. #endif /* _MSC_VER */
  225. #endif /* _INC_TIME */