2 * Copyright 2004 Dimitrie O. Paun
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 * This file contains tests to ensure the consistency between symbols
19 * defined in the regular msvcrt headers, and the corresponding duplicated
20 * symbols defined in msvcrt.h (prefixed by MSVCRT_).
42 #include "sys/locking.h"
43 #include "sys/utime.h"
44 #include "sys/types.h"
46 #include "sys/timeb.h"
55 #include "wine/test.h"
57 #ifdef __WINE_USE_MSVCRT
58 /* Wine-specific msvcrt headers */
59 #define __WINE_MSVCRT_TEST
64 #define TYPEOF(type) typeof(type)
66 #define TYPEOF(type) int
68 #define MSVCRT(x) MSVCRT_##x
69 #define OFFSET(T,F) ((unsigned int)((char *)&((struct T *)0L)->F - (char *)0L))
70 #define CHECK_SIZE(e) ok(sizeof(e) == sizeof(MSVCRT(e)), "Element has different sizes\n")
71 #define CHECK_TYPE(t) { TYPEOF(t) a = 0; TYPEOF(MSVCRT(t)) b = 0; a = b; CHECK_SIZE(t); }
72 #define CHECK_STRUCT(s) ok(sizeof(struct s) == sizeof(struct MSVCRT(s)), "Struct has different sizes\n")
73 #define CHECK_FIELD(s,e) ok(OFFSET(s,e) == OFFSET(MSVCRT(s),e), "Bad offset\n")
74 #define CHECK_DEF(d) ok(d == MSVCRT_##d, "Defines (MSVCRT_)" #d " are different: %d vs. %d\n", d, MSVCRT_##d)
76 /************* Checking types ***************/
77 static void test_types(void)
86 CHECK_TYPE(uintptr_t);
91 CHECK_TYPE(__time64_t
);
94 CHECK_TYPE(terminate_handler
);
95 CHECK_TYPE(terminate_function
);
96 CHECK_TYPE(unexpected_handler
);
97 CHECK_TYPE(unexpected_function
);
98 CHECK_TYPE(_se_translator_function
);
99 CHECK_TYPE(_beginthread_start_routine_t
);
100 CHECK_TYPE(_onexit_t
);
101 CHECK_TYPE(__sighandler_t
);
104 /************* Checking structs ***************/
105 static void test_structs(void)
108 CHECK_FIELD(tm
, tm_sec
);
109 CHECK_FIELD(tm
, tm_min
);
110 CHECK_FIELD(tm
, tm_hour
);
111 CHECK_FIELD(tm
, tm_mday
);
112 CHECK_FIELD(tm
, tm_mon
);
113 CHECK_FIELD(tm
, tm_year
);
114 CHECK_FIELD(tm
, tm_wday
);
115 CHECK_FIELD(tm
, tm_yday
);
116 CHECK_FIELD(tm
, tm_isdst
);
117 CHECK_STRUCT(_timeb
);
118 CHECK_FIELD(_timeb
, time
);
119 CHECK_FIELD(_timeb
, millitm
);
120 CHECK_FIELD(_timeb
, timezone
);
121 CHECK_FIELD(_timeb
, dstflag
);
122 CHECK_STRUCT(_iobuf
);
123 CHECK_FIELD(_iobuf
, _ptr
);
124 CHECK_FIELD(_iobuf
, _cnt
);
125 CHECK_FIELD(_iobuf
, _base
);
126 CHECK_FIELD(_iobuf
, _flag
);
127 CHECK_FIELD(_iobuf
, _file
);
128 CHECK_FIELD(_iobuf
, _charbuf
);
129 CHECK_FIELD(_iobuf
, _bufsiz
);
130 CHECK_FIELD(_iobuf
, _tmpfname
);
132 CHECK_FIELD(lconv
, decimal_point
);
133 CHECK_FIELD(lconv
, thousands_sep
);
134 CHECK_FIELD(lconv
, grouping
);
135 CHECK_FIELD(lconv
, int_curr_symbol
);
136 CHECK_FIELD(lconv
, currency_symbol
);
137 CHECK_FIELD(lconv
, mon_decimal_point
);
138 CHECK_FIELD(lconv
, mon_thousands_sep
);
139 CHECK_FIELD(lconv
, mon_grouping
);
140 CHECK_FIELD(lconv
, positive_sign
);
141 CHECK_FIELD(lconv
, negative_sign
);
142 CHECK_FIELD(lconv
, int_frac_digits
);
143 CHECK_FIELD(lconv
, frac_digits
);
144 CHECK_FIELD(lconv
, p_cs_precedes
);
145 CHECK_FIELD(lconv
, p_sep_by_space
);
146 CHECK_FIELD(lconv
, n_cs_precedes
);
147 CHECK_FIELD(lconv
, n_sep_by_space
);
148 CHECK_FIELD(lconv
, p_sign_posn
);
149 CHECK_FIELD(lconv
, n_sign_posn
);
150 CHECK_STRUCT(_exception
);
151 CHECK_FIELD(_exception
, type
);
152 CHECK_FIELD(_exception
, name
);
153 CHECK_FIELD(_exception
, arg1
);
154 CHECK_FIELD(_exception
, arg2
);
155 CHECK_FIELD(_exception
, retval
);
156 CHECK_STRUCT(_complex
);
157 CHECK_FIELD(_complex
, x
);
158 CHECK_FIELD(_complex
, y
);
159 CHECK_STRUCT(_div_t
);
160 CHECK_FIELD(_div_t
, quot
);
161 CHECK_FIELD(_div_t
, rem
);
162 CHECK_STRUCT(_ldiv_t
);
163 CHECK_FIELD(_ldiv_t
, quot
);
164 CHECK_FIELD(_ldiv_t
, rem
);
165 CHECK_STRUCT(_heapinfo
);
166 CHECK_FIELD(_heapinfo
, _pentry
);
167 CHECK_FIELD(_heapinfo
, _size
);
168 CHECK_FIELD(_heapinfo
, _useflag
);
170 CHECK_STRUCT(__JUMP_BUFFER
);
171 CHECK_FIELD(__JUMP_BUFFER
, Ebp
);
172 CHECK_FIELD(__JUMP_BUFFER
, Ebx
);
173 CHECK_FIELD(__JUMP_BUFFER
, Edi
);
174 CHECK_FIELD(__JUMP_BUFFER
, Esi
);
175 CHECK_FIELD(__JUMP_BUFFER
, Esp
);
176 CHECK_FIELD(__JUMP_BUFFER
, Eip
);
177 CHECK_FIELD(__JUMP_BUFFER
, Registration
);
178 CHECK_FIELD(__JUMP_BUFFER
, TryLevel
);
179 CHECK_FIELD(__JUMP_BUFFER
, Cookie
);
180 CHECK_FIELD(__JUMP_BUFFER
, UnwindFunc
);
181 CHECK_FIELD(__JUMP_BUFFER
, UnwindData
[6]);
183 CHECK_STRUCT(_diskfree_t
);
184 CHECK_FIELD(_diskfree_t
, total_clusters
);
185 CHECK_FIELD(_diskfree_t
, avail_clusters
);
186 CHECK_FIELD(_diskfree_t
, sectors_per_cluster
);
187 CHECK_FIELD(_diskfree_t
, bytes_per_sector
);
188 CHECK_STRUCT(_finddata_t
);
189 CHECK_FIELD(_finddata_t
, attrib
);
190 CHECK_FIELD(_finddata_t
, time_create
);
191 CHECK_FIELD(_finddata_t
, time_access
);
192 CHECK_FIELD(_finddata_t
, time_write
);
193 CHECK_FIELD(_finddata_t
, size
);
194 CHECK_FIELD(_finddata_t
, name
[260]);
195 CHECK_STRUCT(_finddatai64_t
);
196 CHECK_FIELD(_finddatai64_t
, attrib
);
197 CHECK_FIELD(_finddatai64_t
, time_create
);
198 CHECK_FIELD(_finddatai64_t
, time_access
);
199 CHECK_FIELD(_finddatai64_t
, time_write
);
200 CHECK_FIELD(_finddatai64_t
, size
);
201 CHECK_FIELD(_finddatai64_t
, name
[260]);
202 CHECK_STRUCT(_wfinddata_t
);
203 CHECK_FIELD(_wfinddata_t
, attrib
);
204 CHECK_FIELD(_wfinddata_t
, time_create
);
205 CHECK_FIELD(_wfinddata_t
, time_access
);
206 CHECK_FIELD(_wfinddata_t
, time_write
);
207 CHECK_FIELD(_wfinddata_t
, size
);
208 CHECK_FIELD(_wfinddata_t
, name
[260]);
209 CHECK_STRUCT(_wfinddatai64_t
);
210 CHECK_FIELD(_wfinddatai64_t
, attrib
);
211 CHECK_FIELD(_wfinddatai64_t
, time_create
);
212 CHECK_FIELD(_wfinddatai64_t
, time_access
);
213 CHECK_FIELD(_wfinddatai64_t
, time_write
);
214 CHECK_FIELD(_wfinddatai64_t
, size
);
215 CHECK_FIELD(_wfinddatai64_t
, name
[260]);
216 CHECK_STRUCT(_utimbuf
);
217 CHECK_FIELD(_utimbuf
, actime
);
218 CHECK_FIELD(_utimbuf
, modtime
);
220 CHECK_FIELD(_stat
, st_dev
);
221 CHECK_FIELD(_stat
, st_ino
);
222 CHECK_FIELD(_stat
, st_mode
);
223 CHECK_FIELD(_stat
, st_nlink
);
224 CHECK_FIELD(_stat
, st_uid
);
225 CHECK_FIELD(_stat
, st_gid
);
226 CHECK_FIELD(_stat
, st_rdev
);
227 CHECK_FIELD(_stat
, st_size
);
228 CHECK_FIELD(_stat
, st_atime
);
229 CHECK_FIELD(_stat
, st_mtime
);
230 CHECK_FIELD(_stat
, st_ctime
);
231 CHECK_FIELD(_stat
, st_dev
);
232 CHECK_FIELD(_stat
, st_ino
);
233 CHECK_FIELD(_stat
, st_mode
);
234 CHECK_FIELD(_stat
, st_nlink
);
235 CHECK_FIELD(_stat
, st_uid
);
236 CHECK_FIELD(_stat
, st_gid
);
237 CHECK_FIELD(_stat
, st_rdev
);
238 CHECK_FIELD(_stat
, st_size
);
239 CHECK_FIELD(_stat
, st_atime
);
240 CHECK_FIELD(_stat
, st_mtime
);
241 CHECK_FIELD(_stat
, st_ctime
);
242 CHECK_FIELD(_stat
, st_dev
);
243 CHECK_FIELD(_stat
, st_ino
);
244 CHECK_FIELD(_stat
, st_mode
);
245 CHECK_FIELD(_stat
, st_nlink
);
246 CHECK_FIELD(_stat
, st_uid
);
247 CHECK_FIELD(_stat
, st_gid
);
248 CHECK_FIELD(_stat
, st_rdev
);
249 CHECK_FIELD(_stat
, st_size
);
250 CHECK_FIELD(_stat
, st_atime
);
251 CHECK_FIELD(_stat
, st_mtime
);
252 CHECK_FIELD(_stat
, st_ctime
);
254 CHECK_FIELD(stat
, st_dev
);
255 CHECK_FIELD(stat
, st_ino
);
256 CHECK_FIELD(stat
, st_mode
);
257 CHECK_FIELD(stat
, st_nlink
);
258 CHECK_FIELD(stat
, st_uid
);
259 CHECK_FIELD(stat
, st_gid
);
260 CHECK_FIELD(stat
, st_rdev
);
261 CHECK_FIELD(stat
, st_size
);
262 CHECK_FIELD(stat
, st_atime
);
263 CHECK_FIELD(stat
, st_mtime
);
264 CHECK_FIELD(stat
, st_ctime
);
265 CHECK_FIELD(stat
, st_dev
);
266 CHECK_FIELD(stat
, st_ino
);
267 CHECK_FIELD(stat
, st_mode
);
268 CHECK_FIELD(stat
, st_nlink
);
269 CHECK_FIELD(stat
, st_uid
);
270 CHECK_FIELD(stat
, st_gid
);
271 CHECK_FIELD(stat
, st_rdev
);
272 CHECK_FIELD(stat
, st_size
);
273 CHECK_FIELD(stat
, st_atime
);
274 CHECK_FIELD(stat
, st_mtime
);
275 CHECK_FIELD(stat
, st_ctime
);
276 CHECK_FIELD(stat
, st_dev
);
277 CHECK_FIELD(stat
, st_ino
);
278 CHECK_FIELD(stat
, st_mode
);
279 CHECK_FIELD(stat
, st_nlink
);
280 CHECK_FIELD(stat
, st_uid
);
281 CHECK_FIELD(stat
, st_gid
);
282 CHECK_FIELD(stat
, st_rdev
);
283 CHECK_FIELD(stat
, st_size
);
284 CHECK_FIELD(stat
, st_atime
);
285 CHECK_FIELD(stat
, st_mtime
);
286 CHECK_FIELD(stat
, st_ctime
);
287 CHECK_STRUCT(_stati64
);
288 CHECK_FIELD(_stati64
, st_dev
);
289 CHECK_FIELD(_stati64
, st_ino
);
290 CHECK_FIELD(_stati64
, st_mode
);
291 CHECK_FIELD(_stati64
, st_nlink
);
292 CHECK_FIELD(_stati64
, st_uid
);
293 CHECK_FIELD(_stati64
, st_gid
);
294 CHECK_FIELD(_stati64
, st_rdev
);
295 CHECK_FIELD(_stati64
, st_size
);
296 CHECK_FIELD(_stati64
, st_atime
);
297 CHECK_FIELD(_stati64
, st_mtime
);
298 CHECK_FIELD(_stati64
, st_ctime
);
299 CHECK_STRUCT(_stat64
);
300 CHECK_FIELD(_stat64
, st_dev
);
301 CHECK_FIELD(_stat64
, st_ino
);
302 CHECK_FIELD(_stat64
, st_mode
);
303 CHECK_FIELD(_stat64
, st_nlink
);
304 CHECK_FIELD(_stat64
, st_uid
);
305 CHECK_FIELD(_stat64
, st_gid
);
306 CHECK_FIELD(_stat64
, st_rdev
);
307 CHECK_FIELD(_stat64
, st_size
);
308 CHECK_FIELD(_stat64
, st_atime
);
309 CHECK_FIELD(_stat64
, st_mtime
);
310 CHECK_FIELD(_stat64
, st_ctime
);
313 /************* Checking defines ***************/
314 static void test_defines(void)
321 CHECK_DEF(STDIN_FILENO
);
322 CHECK_DEF(STDOUT_FILENO
);
323 CHECK_DEF(STDERR_FILENO
);
327 CHECK_DEF(FILENAME_MAX
);
329 CHECK_DEF(_P_NOWAIT
);
330 CHECK_DEF(_P_OVERLAY
);
331 CHECK_DEF(_P_NOWAITO
);
332 CHECK_DEF(_P_DETACH
);
366 CHECK_DEF(EDEADLOCK
);
367 CHECK_DEF(ENAMETOOLONG
);
370 CHECK_DEF(ENOTEMPTY
);
373 CHECK_DEF(LC_COLLATE
);
375 CHECK_DEF(LC_MONETARY
);
376 CHECK_DEF(LC_NUMERIC
);
380 CHECK_DEF(CLOCKS_PER_SEC
);
381 CHECK_DEF(_HEAPEMPTY
);
383 CHECK_DEF(_HEAPBADBEGIN
);
384 CHECK_DEF(_HEAPBADNODE
);
386 CHECK_DEF(_HEAPBADPTR
);
387 CHECK_DEF(_FREEENTRY
);
388 CHECK_DEF(_USEDENTRY
);
389 CHECK_DEF(_OUT_TO_DEFAULT
);
390 CHECK_DEF(_REPORT_ERRMODE
);
399 CHECK_DEF(_LEADBYTE
);
409 CHECK_DEF(_S_IWRITE
);
416 CHECK_DEF(_LK_UNLCK
);
418 CHECK_DEF(_LK_NBLCK
);
420 CHECK_DEF(_LK_NBRLCK
);
421 CHECK_DEF(_O_RDONLY
);
422 CHECK_DEF(_O_WRONLY
);
424 CHECK_DEF(_O_ACCMODE
);
425 CHECK_DEF(_O_APPEND
);
426 CHECK_DEF(_O_RANDOM
);
427 CHECK_DEF(_O_SEQUENTIAL
);
428 CHECK_DEF(_O_TEMPORARY
);
429 CHECK_DEF(_O_NOINHERIT
);
433 CHECK_DEF(_O_SHORT_LIVED
);
435 CHECK_DEF(_O_BINARY
);
437 CHECK_DEF(_SW_INEXACT
);
438 CHECK_DEF(_SW_UNDERFLOW
);
439 CHECK_DEF(_SW_OVERFLOW
);
440 CHECK_DEF(_SW_ZERODIVIDE
);
441 CHECK_DEF(_SW_INVALID
);
442 CHECK_DEF(_SW_UNEMULATED
);
443 CHECK_DEF(_SW_SQRTNEG
);
444 CHECK_DEF(_SW_STACKOVERFLOW
);
445 CHECK_DEF(_SW_STACKUNDERFLOW
);
446 CHECK_DEF(_SW_DENORMAL
);
447 CHECK_DEF(_FPCLASS_SNAN
);
448 CHECK_DEF(_FPCLASS_QNAN
);
449 CHECK_DEF(_FPCLASS_NINF
);
450 CHECK_DEF(_FPCLASS_NN
);
451 CHECK_DEF(_FPCLASS_ND
);
452 CHECK_DEF(_FPCLASS_NZ
);
453 CHECK_DEF(_FPCLASS_PZ
);
454 CHECK_DEF(_FPCLASS_PD
);
455 CHECK_DEF(_FPCLASS_PN
);
456 CHECK_DEF(_FPCLASS_PINF
);
466 CHECK_DEF(_EM_INVALID
);
467 CHECK_DEF(_EM_DENORMAL
);
468 CHECK_DEF(_EM_ZERODIVIDE
);
469 CHECK_DEF(_EM_OVERFLOW
);
470 CHECK_DEF(_EM_UNDERFLOW
);
471 CHECK_DEF(_EM_INEXACT
);
472 CHECK_DEF(_IC_AFFINE
);
473 CHECK_DEF(_IC_PROJECTIVE
);
484 #endif /* __WINE_USE_MSVCRT */
488 #ifdef __WINE_USE_MSVCRT