Optimize arithmetic with pointer to value on stack + constant
[tinycc/daniel.git] / win32 / include / time.h
blobade7f6db7c0048ef7b50d30b080a779d30821a51
1 /*
2 * time.h
4 * Date and time functions and types.
6 * This file is part of the Mingw32 package.
8 * Contributors:
9 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 * $Revision: 1.2 $
22 * $Author: bellard $
23 * $Date: 2005/04/17 13:14:29 $
27 #ifndef _TIME_H_
28 #define _TIME_H_
30 /* All the headers include this file. */
31 #include <_mingw.h>
33 #define __need_wchar_t
34 #define __need_size_t
35 #ifndef RC_INVOKED
36 #include <stddef.h>
37 #endif /* Not RC_INVOKED */
40 * Need a definition of time_t.
42 #include <sys/types.h>
45 * Number of clock ticks per second. A clock tick is the unit by which
46 * processor time is measured and is returned by 'clock'.
48 #define CLOCKS_PER_SEC ((clock_t)1000)
49 #define CLK_TCK CLOCKS_PER_SEC
52 #ifndef RC_INVOKED
55 * A type for storing the current time and date. This is the number of
56 * seconds since midnight Jan 1, 1970.
57 * NOTE: Normally this is defined by the above include of sys/types.h
59 #ifndef _TIME_T_DEFINED
60 typedef long time_t;
61 #define _TIME_T_DEFINED
62 #endif
65 * A type for measuring processor time (in clock ticks).
67 #ifndef _CLOCK_T_DEFINED
68 typedef long clock_t;
69 #define _CLOCK_T_DEFINED
70 #endif
74 * A structure for storing all kinds of useful information about the
75 * current (or another) time.
77 struct tm
79 int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
80 int tm_min; /* Minutes: 0-59 */
81 int tm_hour; /* Hours since midnight: 0-23 */
82 int tm_mday; /* Day of the month: 1-31 */
83 int tm_mon; /* Months *since* january: 0-11 */
84 int tm_year; /* Years since 1900 */
85 int tm_wday; /* Days since Sunday (0-6) */
86 int tm_yday; /* Days since Jan. 1: 0-365 */
87 int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
88 * -1 don't know */
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
95 clock_t clock (void);
96 time_t time (time_t*);
97 double difftime (time_t, time_t);
98 time_t mktime (struct tm*);
101 * These functions write to and return pointers to static buffers that may
102 * be overwritten by other function calls. Yikes!
104 * NOTE: localtime, and perhaps the others of the four functions grouped
105 * below may return NULL if their argument is not 'acceptable'. Also note
106 * that calling asctime with a NULL pointer will produce an Invalid Page
107 * Fault and crap out your program. Guess how I know. Hint: stat called on
108 * a directory gives 'invalid' times in st_atime etc...
110 char* asctime (const struct tm*);
111 char* ctime (const time_t*);
112 struct tm* gmtime (const time_t*);
113 struct tm* localtime (const time_t*);
116 size_t strftime (char*, size_t, const char*, const struct tm*);
118 size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
120 #ifndef __STRICT_ANSI__
121 extern void _tzset (void);
123 #ifndef _NO_OLDNAMES
124 extern void tzset (void);
125 #endif
127 size_t strftime(char*, size_t, const char*, const struct tm*);
128 char* _strdate(char*);
129 char* _strtime(char*);
131 #endif /* Not __STRICT_ANSI__ */
134 * _daylight: non zero if daylight savings time is used.
135 * _timezone: difference in seconds between GMT and local time.
136 * _tzname: standard/daylight savings time zone names (an array with two
137 * elements).
139 #ifdef __MSVCRT__
141 /* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
142 extern int* __p__daylight (void);
143 extern long* __p__timezone (void);
144 extern char** __p__tzname (void);
146 __MINGW_IMPORT int _daylight;
147 __MINGW_IMPORT long _timezone;
148 __MINGW_IMPORT char *_tzname[2];
150 #else /* not __MSVCRT (ie. crtdll) */
152 #ifndef __DECLSPEC_SUPPORTED
154 extern int* __imp__daylight_dll;
155 extern long* __imp__timezone_dll;
156 extern char** __imp__tzname;
158 #define _daylight (*__imp__daylight_dll)
159 #define _timezone (*__imp__timezone_dll)
160 #define _tzname (__imp__tzname)
162 #else /* __DECLSPEC_SUPPORTED */
164 __MINGW_IMPORT int _daylight_dll;
165 __MINGW_IMPORT long _timezone_dll;
166 __MINGW_IMPORT char* _tzname[2];
168 #define _daylight _daylight_dll
169 #define _timezone _timezone_dll
171 #endif /* __DECLSPEC_SUPPORTED */
173 #endif /* not __MSVCRT__ */
175 #ifndef _NO_OLDNAMES
177 #ifdef __MSVCRT__
179 /* These go in the oldnames import library for MSVCRT. */
180 __MINGW_IMPORT int daylight;
181 __MINGW_IMPORT long timezone;
182 __MINGW_IMPORT char *tzname[2];
184 #ifndef _WTIME_DEFINED
186 /* wide function prototypes, also declared in wchar.h */
188 wchar_t * _wasctime(const struct tm*);
189 wchar_t * _wctime(const time_t*);
190 wchar_t* _wstrdate(wchar_t*);
191 wchar_t* _wstrtime(wchar_t*);
193 #define _WTIME_DEFINED
194 #endif /* _WTIME_DEFINED */
197 #else /* not __MSVCRT__ */
199 /* CRTDLL is royally messed up when it comes to these macros.
200 TODO: import and alias these via oldnames import library instead
201 of macros. */
203 #define daylight _daylight
204 /* NOTE: timezone not defined because it would conflict with sys/timeb.h.
205 Also, tzname used to a be macro, but now it's in moldname. */
206 __MINGW_IMPORT char *tzname[2];
208 #endif /* not __MSVCRT__ */
210 #endif /* Not _NO_OLDNAMES */
212 #ifdef __cplusplus
214 #endif
216 #endif /* Not RC_INVOKED */
218 #endif /* Not _TIME_H_ */