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.

336 lines
11 KiB

  1. /***
  2. *time.h - definitions/declarations for time routines
  3. *
  4. * Copyright (c) 1985-2001, 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. *Revision History:
  15. * 07-27-87 SKS Added _strdate(), _strtime()
  16. * 10-20-87 JCR Removed "MSC40_ONLY" entries
  17. * 12-11-87 JCR Added "_loadds" functionality
  18. * 12-18-87 JCR Added _FAR_ to declarations
  19. * 01-16-88 JCR Added function versions of daylight/timezone/tzset
  20. * 01-20-88 SKS Change _timezone(n) to _timezone(), _daylight()
  21. * 02-10-88 JCR Cleaned up white space
  22. * 12-07-88 JCR DLL timezone/daylight/tzname now directly refers to data
  23. * 03-14-89 JCR Added strftime() prototype and size_t definition
  24. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  25. * 08-15-89 GJF Cleanup, now specific to OS/2 2.0 (i.e., 386 flat model)
  26. * 10-30-89 GJF Fixed copyright, removed dummy args from prototypes
  27. * 11-02-89 JCR Changed "DLL" to "_DLL"
  28. * 11-20-89 JCR difftime() always _cdecl (not pascal even under mthread)
  29. * 03-02-90 GJF Added #ifndef _INC_TIME and #include <cruntime.h>
  30. * stuff. Also, removed some (now) useless preprocessor
  31. * directives.
  32. * 03-29-90 GJF Replaced _cdecl with _CALLTYPE1 in prototypes and with
  33. * _VARTYPE1 in variable declarations.
  34. * 08-16-90 SBM Added NULL definition for ANSI compliance
  35. * 11-12-90 GJF Changed NULL to (void *)0.
  36. * 01-21-91 GJF ANSI naming.
  37. * 02-12-91 GJF Only #define NULL if it isn't #define-d.
  38. * 08-20-91 JCR C++ and ANSI naming
  39. * 08-26-91 BWM Added prototypes for _getsystime and _setsystem.
  40. * 09-28-91 JCR ANSI names: DOSX32=prototypes, WIN32=#defines for now
  41. * 01-22-92 GJF Fixed up definitions of global variables for build of,
  42. * and users of, crtdll.dll.
  43. * 03-25-92 DJM POSIX support.
  44. * 08-05-92 GJF Function calling type and variable type macros.
  45. * 08-24-92 PBS Support for Posix TZ variable.
  46. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  47. * 03-10-93 MJB Fixes for Posix TZ stuff.
  48. * 03-20-93 SKS Remove obsolete functions _getsystime/_setsystime
  49. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  50. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  51. * Use link-time aliases for old names, not #define's
  52. * Remove POSIX #ifdef's
  53. * 05-05-93 CFW Add wcsftime proto.
  54. * 06-08-93 SKS Cannot #define the old name "timezone" to "_timezone"
  55. * because of conflict conflict with the timezone field
  56. * in struct timeb in <sys/timeb.h>.
  57. * 09-13-93 GJF Merged NT SDK and Cuda versions.
  58. * 11-15-93 GJF Enclosed _getlocaltime, _setlocaltime prototypes with
  59. * a warning noting they are obsolete.
  60. * 12-07-93 CFW Add wide char version protos.
  61. * 12-07-93 CFW Move wide defs outside __STDC__ check.
  62. * 04-13-94 GJF Made _daylight, _timezone and _tzname into deferences
  63. * of function return values (for compatibility with the
  64. * Win32s version of msvcrt*.dll). Also, added
  65. * conditional include for win32s.h.
  66. * 05-04-94 GJF Made definitions of _daylight, _timezone and _tzname
  67. * for _DLL conditional on _M_IX86 also.
  68. * 11-03-94 GJF Ensure 8 byte alignment.
  69. * 12-16-94 CFW Wcsftime format must be wchar_t!
  70. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  71. * 02-14-95 CFW Clean up Mac merge.
  72. * 06-21-95 CFW Oldnames daylight, timezone, and tzname for Win32s.
  73. * 06-23-95 CFW Remove timezone oldname support for Win32 DLL
  74. * conflicts with timeb.h.
  75. * 08-30-95 GJF Added _dstbias.
  76. * 12-14-95 JWM Add "#pragma once".
  77. * 01-22-97 GJF Cleaned out obsolete support for Win32s, _NTSDK and
  78. * _CRTAPI*.
  79. * 08-13-97 GJF Strip __p_* prototypes from release version.
  80. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  81. * 10-07-97 RDL Added IA64.
  82. * 02-06-98 GJF Changes for Win64: made time_t __int64.
  83. * 05-04-98 GJF Added __time64_t support.
  84. * 01-06-99 GJF Changes for 64-bit size_t.
  85. * 05-13-99 PML Remove _CRTAPI1
  86. * 05-17-99 PML Remove all Macintosh support.
  87. * 10-06-99 PML Add _W64 modifier to types which are 32 bits in Win32,
  88. * 64 bits in Win64.
  89. * 11-12-99 PML Wrap __time64_t in its own #ifndef.
  90. *
  91. ****/
  92. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  93. #pragma once
  94. #endif
  95. #ifndef _INC_TIME
  96. #define _INC_TIME
  97. #if !defined(_WIN32)
  98. #error ERROR: Only Win32 target supported!
  99. #endif
  100. #ifndef _CRTBLD
  101. /* This version of the header files is NOT for user programs.
  102. * It is intended for use when building the C runtimes ONLY.
  103. * The version intended for public use will not have this message.
  104. */
  105. #error ERROR: Use of C runtime library internal header file.
  106. #endif /* _CRTBLD */
  107. #ifdef _MSC_VER
  108. /*
  109. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  110. * alignment.
  111. */
  112. #pragma pack(push,8)
  113. #endif /* _MSC_VER */
  114. #ifdef __cplusplus
  115. extern "C" {
  116. #endif
  117. #ifndef _INTERNAL_IFSTRIP_
  118. #include <cruntime.h>
  119. #endif /* _INTERNAL_IFSTRIP_ */
  120. #if !defined(_W64)
  121. #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 /*IFSTRIP=IGN*/
  122. #define _W64 __w64
  123. #else
  124. #define _W64
  125. #endif
  126. #endif
  127. /* Define _CRTIMP */
  128. #ifndef _CRTIMP
  129. #ifdef CRTDLL
  130. #define _CRTIMP __declspec(dllexport)
  131. #else /* ndef CRTDLL */
  132. #ifdef _DLL
  133. #define _CRTIMP __declspec(dllimport)
  134. #else /* ndef _DLL */
  135. #define _CRTIMP
  136. #endif /* _DLL */
  137. #endif /* CRTDLL */
  138. #endif /* _CRTIMP */
  139. /* Define __cdecl for non-Microsoft compilers */
  140. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  141. #define __cdecl
  142. #endif
  143. #ifndef _WCHAR_T_DEFINED
  144. typedef unsigned short wchar_t;
  145. #define _WCHAR_T_DEFINED
  146. #endif
  147. /* Define the implementation defined time type */
  148. #ifndef _TIME_T_DEFINED
  149. #ifdef _WIN64
  150. typedef __int64 time_t; /* time value */
  151. #else
  152. typedef _W64 long time_t; /* time value */
  153. #endif
  154. #define _TIME_T_DEFINED /* avoid multiple def's of time_t */
  155. #endif
  156. #ifndef _TIME64_T_DEFINED
  157. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  158. typedef __int64 __time64_t; /* 64-bit time value */
  159. #endif
  160. #define _TIME64_T_DEFINED
  161. #endif
  162. #ifndef _CLOCK_T_DEFINED
  163. typedef long clock_t;
  164. #define _CLOCK_T_DEFINED
  165. #endif
  166. #ifndef _SIZE_T_DEFINED
  167. #ifdef _WIN64
  168. typedef unsigned __int64 size_t;
  169. #else
  170. typedef _W64 unsigned int size_t;
  171. #endif
  172. #define _SIZE_T_DEFINED
  173. #endif
  174. /* Define NULL pointer value */
  175. #ifndef NULL
  176. #ifdef __cplusplus
  177. #define NULL 0
  178. #else
  179. #define NULL ((void *)0)
  180. #endif
  181. #endif
  182. #ifndef _TM_DEFINED
  183. struct tm {
  184. int tm_sec; /* seconds after the minute - [0,59] */
  185. int tm_min; /* minutes after the hour - [0,59] */
  186. int tm_hour; /* hours since midnight - [0,23] */
  187. int tm_mday; /* day of the month - [1,31] */
  188. int tm_mon; /* months since January - [0,11] */
  189. int tm_year; /* years since 1900 */
  190. int tm_wday; /* days since Sunday - [0,6] */
  191. int tm_yday; /* days since January 1 - [0,365] */
  192. int tm_isdst; /* daylight savings time flag */
  193. };
  194. #define _TM_DEFINED
  195. #endif
  196. /* Clock ticks macro - ANSI version */
  197. #define CLOCKS_PER_SEC 1000
  198. /* Extern declarations for the global variables used by the ctime family of
  199. * routines.
  200. */
  201. #ifndef _INTERNAL_IFSTRIP_
  202. #if defined(_DLL) && defined(_M_IX86)
  203. /* Retained for compatibility with VC++ 5.0 and earlier versions */
  204. _CRTIMP int * __cdecl __p__daylight(void);
  205. _CRTIMP long * __cdecl __p__dstbias(void);
  206. _CRTIMP long * __cdecl __p__timezone(void);
  207. _CRTIMP char ** __cdecl __p__tzname(void);
  208. #endif
  209. #endif /* _INTERNAL_IFSTRIP_ */
  210. /* non-zero if daylight savings time is used */
  211. _CRTIMP extern int _daylight;
  212. /* offset for Daylight Saving Time */
  213. _CRTIMP extern long _dstbias;
  214. /* difference in seconds between GMT and local time */
  215. _CRTIMP extern long _timezone;
  216. /* standard/daylight savings time zone names */
  217. _CRTIMP extern char * _tzname[2];
  218. /* Function prototypes */
  219. _CRTIMP char * __cdecl asctime(const struct tm *);
  220. _CRTIMP char * __cdecl ctime(const time_t *);
  221. _CRTIMP clock_t __cdecl clock(void);
  222. _CRTIMP double __cdecl difftime(time_t, time_t);
  223. _CRTIMP struct tm * __cdecl gmtime(const time_t *);
  224. _CRTIMP struct tm * __cdecl localtime(const time_t *);
  225. _CRTIMP time_t __cdecl mktime(struct tm *);
  226. _CRTIMP size_t __cdecl strftime(char *, size_t, const char *,
  227. const struct tm *);
  228. _CRTIMP char * __cdecl _strdate(char *);
  229. _CRTIMP char * __cdecl _strtime(char *);
  230. _CRTIMP time_t __cdecl time(time_t *);
  231. #ifdef _POSIX_
  232. _CRTIMP void __cdecl tzset(void);
  233. #else
  234. _CRTIMP void __cdecl _tzset(void);
  235. #endif
  236. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  237. _CRTIMP char * __cdecl _ctime64(const __time64_t *);
  238. _CRTIMP struct tm * __cdecl _gmtime64(const __time64_t *);
  239. _CRTIMP struct tm * __cdecl _localtime64(const __time64_t *);
  240. _CRTIMP __time64_t __cdecl _mktime64(struct tm *);
  241. _CRTIMP __time64_t __cdecl _time64(__time64_t *);
  242. #endif
  243. /* --------- The following functions are OBSOLETE --------- */
  244. /* The Win32 API GetLocalTime and SetLocalTime should be used instead. */
  245. unsigned __cdecl _getsystime(struct tm *);
  246. unsigned __cdecl _setsystime(struct tm *, unsigned);
  247. /* --------- The preceding functions are OBSOLETE --------- */
  248. #ifndef _SIZE_T_DEFINED
  249. typedef unsigned int size_t;
  250. #define _SIZE_T_DEFINED
  251. #endif
  252. #ifndef _WTIME_DEFINED
  253. /* wide function prototypes, also declared in wchar.h */
  254. _CRTIMP wchar_t * __cdecl _wasctime(const struct tm *);
  255. _CRTIMP wchar_t * __cdecl _wctime(const time_t *);
  256. _CRTIMP size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *,
  257. const struct tm *);
  258. _CRTIMP wchar_t * __cdecl _wstrdate(wchar_t *);
  259. _CRTIMP wchar_t * __cdecl _wstrtime(wchar_t *);
  260. #if _INTEGRAL_MAX_BITS >= 64 /*IFSTRIP=IGN*/
  261. _CRTIMP wchar_t * __cdecl _wctime64(const __time64_t *);
  262. #endif
  263. #define _WTIME_DEFINED
  264. #endif
  265. #if !__STDC__ || defined(_POSIX_)
  266. /* Non-ANSI names for compatibility */
  267. #define CLK_TCK CLOCKS_PER_SEC
  268. _CRTIMP extern int daylight;
  269. _CRTIMP extern long timezone;
  270. _CRTIMP extern char * tzname[2];
  271. _CRTIMP void __cdecl tzset(void);
  272. #endif /* __STDC__ */
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276. #ifdef _MSC_VER
  277. #pragma pack(pop)
  278. #endif /* _MSC_VER */
  279. #endif /* _INC_TIME */