master
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _IO_H_
7#define _IO_H_
8
9#include <crtdefs.h>
10#include <string.h>
11
12#if defined(__LIBMSVCRT__)
13/* When building mingw-w64, this should be blank. */
14#define _SECIMP
15#else
16#ifndef _SECIMP
17#define _SECIMP __declspec(dllimport)
18#endif /* _SECIMP */
19#endif /* defined(__LIBMSVCRT__) */
20
21#pragma pack(push,_CRT_PACKING)
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
28#pragma push_macro("_getcwd")
29#undef _getcwd
30#endif
31_CRTIMP char* __cdecl _getcwd (char*, int);
32#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
33#pragma pop_macro("_getcwd")
34#endif
35
36#ifndef _FSIZE_T_DEFINED
37 typedef unsigned long _fsize_t;
38#define _FSIZE_T_DEFINED
39#endif
40
41#ifndef _FINDDATA_T_DEFINED
42
43 struct _finddata32_t {
44 unsigned attrib;
45 __time32_t time_create;
46 __time32_t time_access;
47 __time32_t time_write;
48 _fsize_t size;
49 char name[260];
50 };
51
52 struct _finddata32i64_t {
53 unsigned attrib;
54 __time32_t time_create;
55 __time32_t time_access;
56 __time32_t time_write;
57 __MINGW_EXTENSION __int64 size;
58 char name[260];
59 };
60
61 struct _finddata64i32_t {
62 unsigned attrib;
63 __time64_t time_create;
64 __time64_t time_access;
65 __time64_t time_write;
66 _fsize_t size;
67 char name[260];
68 };
69
70 struct __finddata64_t {
71 unsigned attrib;
72 __time64_t time_create;
73 __time64_t time_access;
74 __time64_t time_write;
75 __MINGW_EXTENSION __int64 size;
76 char name[260];
77 };
78
79#ifdef _USE_32BIT_TIME_T
80#define _finddata_t _finddata32_t
81#define _finddatai64_t _finddata32i64_t
82
83#define _findfirst _findfirst32
84#define _findnext _findnext32
85#define _findfirsti64 _findfirst32i64
86#define _findnexti64 _findnext32i64
87#else
88#define _finddata_t _finddata64i32_t
89#define _finddatai64_t __finddata64_t
90
91#define _findfirst _findfirst64i32
92#define _findnext _findnext64i32
93#define _findfirsti64 _findfirst64
94#define _findnexti64 _findnext64
95#endif /* _USE_32BIT_TIME_T */
96
97#define _FINDDATA_T_DEFINED
98#endif /* _FINDDATA_T_DEFINED */
99
100#ifndef _WFINDDATA_T_DEFINED
101
102 struct _wfinddata32_t {
103 unsigned attrib;
104 __time32_t time_create;
105 __time32_t time_access;
106 __time32_t time_write;
107 _fsize_t size;
108 wchar_t name[260];
109 };
110
111 struct _wfinddata32i64_t {
112 unsigned attrib;
113 __time32_t time_create;
114 __time32_t time_access;
115 __time32_t time_write;
116 __MINGW_EXTENSION __int64 size;
117 wchar_t name[260];
118 };
119
120 struct _wfinddata64i32_t {
121 unsigned attrib;
122 __time64_t time_create;
123 __time64_t time_access;
124 __time64_t time_write;
125 _fsize_t size;
126 wchar_t name[260];
127 };
128
129 struct _wfinddata64_t {
130 unsigned attrib;
131 __time64_t time_create;
132 __time64_t time_access;
133 __time64_t time_write;
134 __MINGW_EXTENSION __int64 size;
135 wchar_t name[260];
136 };
137
138#ifdef _USE_32BIT_TIME_T
139#define _wfinddata_t _wfinddata32_t
140#define _wfinddatai64_t _wfinddata32i64_t
141
142#define _wfindfirst _wfindfirst32
143#define _wfindnext _wfindnext32
144#define _wfindfirst32i64 _wfindfirsti64
145#define _wfindnext32i64 _wfindnexti64
146#else
147#define _wfinddata_t _wfinddata64i32_t
148#define _wfinddatai64_t _wfinddata64_t
149
150#define _wfindfirst _wfindfirst64i32
151#define _wfindnext _wfindnext64i32
152#define _wfindfirsti64 _wfindfirst64
153#define _wfindnexti64 _wfindnext64
154#endif /* _USE_32BIT_TIME_T */
155
156#define _WFINDDATA_T_DEFINED
157#endif /* _WFINDDATA_T_DEFINED */
158
159#define _A_NORMAL 0x00
160#define _A_RDONLY 0x01
161#define _A_HIDDEN 0x02
162#define _A_SYSTEM 0x04
163#define _A_SUBDIR 0x10
164#define _A_ARCH 0x20
165
166#ifndef _SIZE_T_DEFINED
167#define _SIZE_T_DEFINED
168#undef size_t
169#ifdef _WIN64
170 __MINGW_EXTENSION typedef unsigned __int64 size_t;
171#else
172 typedef unsigned int size_t;
173#endif /* _WIN64 */
174#endif /* _SIZE_T_DEFINED */
175
176#ifndef _SSIZE_T_DEFINED
177#define _SSIZE_T_DEFINED
178#undef ssize_t
179#ifdef _WIN64
180 __MINGW_EXTENSION typedef __int64 ssize_t;
181#else
182 typedef int ssize_t;
183#endif /* _WIN64 */
184#endif /* _SSIZE_T_DEFINED */
185
186#include <_mingw_off_t.h>
187
188 /* Some defines for _access nAccessMode (MS doesn't define them, but
189 * it doesn't seem to hurt to add them). */
190#define F_OK 0 /* Check for file existence */
191#define X_OK 1 /* Check for execute permission. */
192#define W_OK 2 /* Check for write permission */
193#define R_OK 4 /* Check for read permission */
194
195 _CRTIMP int __cdecl _access(const char *_Filename,int _AccessMode);
196 _SECIMP errno_t __cdecl _access_s(const char *_Filename,int _AccessMode);
197 _CRTIMP int __cdecl _chmod(const char *_Filename,int _Mode);
198 _CRTIMP int __cdecl _chsize(int _FileHandle,long _Size) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
199 _SECIMP errno_t __cdecl _chsize_s (int _FileHandle,__int64 _Size);
200 _CRTIMP int __cdecl _close(int _FileHandle);
201 _CRTIMP int __cdecl _commit(int _FileHandle);
202 _CRTIMP int __cdecl _creat(const char *_Filename,int _PermissionMode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
203 _CRTIMP int __cdecl _dup(int _FileHandle);
204 _CRTIMP int __cdecl _dup2(int _FileHandleSrc,int _FileHandleDst);
205 _CRTIMP int __cdecl _eof(int _FileHandle);
206 _CRTIMP long __cdecl _filelength(int _FileHandle);
207 _CRTIMP intptr_t __cdecl _findfirst32(const char *_Filename,struct _finddata32_t *_FindData);
208 _CRTIMP int __cdecl _findnext32(intptr_t _FindHandle,struct _finddata32_t *_FindData);
209 _CRTIMP int __cdecl _findclose(intptr_t _FindHandle);
210 _CRTIMP int __cdecl _isatty(int _FileHandle);
211 _CRTIMP int __cdecl _locking(int _FileHandle,int _LockMode,long _NumOfBytes);
212 _CRTIMP long __cdecl _lseek(int _FileHandle,long _Offset,int _Origin);
213 _off64_t lseek64(int fd,_off64_t offset, int whence);
214 _CRTIMP char *__cdecl _mktemp(char *_TemplateName) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
215 _SECIMP errno_t __cdecl _mktemp_s (char *_TemplateName,size_t _Size);
216#ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
217 _CRTIMP int __cdecl _pipe(int *_PtHandles,unsigned int _PipeSize,int _TextMode);
218#endif /* _CRT_USE_WINAPI_FAMILY_DESKTOP_APP */
219 _CRTIMP int __cdecl _read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount);
220
221#ifndef _CRT_DIRECTORY_DEFINED
222#define _CRT_DIRECTORY_DEFINED
223 int __cdecl remove(const char *_Filename);
224 int __cdecl rename(const char *_OldFilename,const char *_NewFilename);
225 _CRTIMP int __cdecl _unlink(const char *_Filename);
226#ifndef NO_OLDNAMES
227 int __cdecl unlink(const char *_Filename) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
228#endif
229#endif
230
231 _CRTIMP int __cdecl _setmode(int _FileHandle,int _Mode);
232 _CRTIMP long __cdecl _tell(int _FileHandle);
233 _CRTIMP int __cdecl _umask(int _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
234 _SECIMP errno_t __cdecl _umask_s (int _NewMode,int *_OldMode);
235 _CRTIMP int __cdecl _write(int _FileHandle,const void *_Buf,unsigned int _MaxCharCount);
236
237 __MINGW_EXTENSION _CRTIMP __int64 __cdecl _filelengthi64(int _FileHandle);
238 _CRTIMP intptr_t __cdecl _findfirst32i64(const char *_Filename,struct _finddata32i64_t *_FindData);
239 _CRTIMP intptr_t __cdecl _findfirst64(const char *_Filename,struct __finddata64_t *_FindData);
240#ifdef __cplusplus
241#include <string.h>
242#endif
243 intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData);
244#ifndef __CRT__NO_INLINE
245 __CRT_INLINE intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *_FindData)
246 {
247 struct __finddata64_t fd;
248 intptr_t ret = _findfirst64(_Filename,&fd);
249 if (ret == -1) {
250 memset(_FindData,0,sizeof(struct _finddata64i32_t));
251 return -1;
252 }
253 _FindData->attrib=fd.attrib;
254 _FindData->time_create=fd.time_create;
255 _FindData->time_access=fd.time_access;
256 _FindData->time_write=fd.time_write;
257 _FindData->size=(_fsize_t) fd.size;
258 strncpy(_FindData->name,fd.name,260);
259 return ret;
260 }
261#endif /* __CRT__NO_INLINE */
262 _CRTIMP int __cdecl _findnext32i64(intptr_t _FindHandle,struct _finddata32i64_t *_FindData);
263 _CRTIMP int __cdecl _findnext64(intptr_t _FindHandle,struct __finddata64_t *_FindData);
264 int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData);
265#ifndef __CRT__NO_INLINE
266 __CRT_INLINE int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindData)
267 {
268 struct __finddata64_t fd;
269 int __ret = _findnext64(_FindHandle,&fd);
270 if (__ret == -1) {
271 memset(_FindData,0,sizeof(struct _finddata64i32_t));
272 return -1;
273 }
274 _FindData->attrib=fd.attrib;
275 _FindData->time_create=fd.time_create;
276 _FindData->time_access=fd.time_access;
277 _FindData->time_write=fd.time_write;
278 _FindData->size=(_fsize_t) fd.size;
279 strncpy(_FindData->name,fd.name,260);
280 return __ret;
281 }
282#endif /* __CRT__NO_INLINE */
283 __MINGW_EXTENSION __int64 __cdecl _lseeki64(int _FileHandle,__int64 _Offset,int _Origin);
284 __MINGW_EXTENSION __int64 __cdecl _telli64(int _FileHandle);
285
286#ifndef NO_OLDNAMES
287#ifndef _UWIN
288 int __cdecl chdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
289#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
290#pragma push_macro("getcwd")
291#undef getcwd
292#endif
293 char *__cdecl getcwd (char *, int) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
294#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
295#pragma pop_macro("getcwd")
296#endif
297 int __cdecl mkdir (const char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
298 char *__cdecl mktemp(char *) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
299 int __cdecl rmdir (const char*) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
300 int __cdecl chmod (const char *, int) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
301#endif /* _UWIN */
302#endif /* Not NO_OLDNAMES */
303
304 _SECIMP errno_t __cdecl _sopen_s(int *_FileHandle,const char *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode);
305
306 _CRTIMP int __cdecl _open(const char *_Filename,int _OpenFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
307 _CRTIMP int __cdecl _sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
308
309#ifndef _WIO_DEFINED
310#define _WIO_DEFINED
311 _CRTIMP int __cdecl _waccess(const wchar_t *_Filename,int _AccessMode);
312 _SECIMP errno_t __cdecl _waccess_s (const wchar_t *_Filename,int _AccessMode);
313 _CRTIMP int __cdecl _wchmod(const wchar_t *_Filename,int _Mode);
314 _CRTIMP int __cdecl _wcreat(const wchar_t *_Filename,int _PermissionMode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
315 _CRTIMP intptr_t __cdecl _wfindfirst32(const wchar_t *_Filename,struct _wfinddata32_t *_FindData);
316 _CRTIMP int __cdecl _wfindnext32(intptr_t _FindHandle,struct _wfinddata32_t *_FindData);
317 _CRTIMP int __cdecl _wunlink(const wchar_t *_Filename);
318 _CRTIMP int __cdecl _wrename(const wchar_t *_OldFilename,const wchar_t *_NewFilename);
319 _CRTIMP wchar_t *__cdecl _wmktemp(wchar_t *_TemplateName) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
320 _SECIMP errno_t __cdecl _wmktemp_s (wchar_t *_TemplateName, size_t _SizeInWords);
321
322 _CRTIMP intptr_t __cdecl _wfindfirst32i64(const wchar_t *_Filename,struct _wfinddata32i64_t *_FindData);
323 intptr_t __cdecl _wfindfirst64i32(const wchar_t *_Filename,struct _wfinddata64i32_t *_FindData);
324 _CRTIMP intptr_t __cdecl _wfindfirst64(const wchar_t *_Filename,struct _wfinddata64_t *_FindData);
325 _CRTIMP int __cdecl _wfindnext32i64(intptr_t _FindHandle,struct _wfinddata32i64_t *_FindData);
326 int __cdecl _wfindnext64i32(intptr_t _FindHandle,struct _wfinddata64i32_t *_FindData);
327 _CRTIMP int __cdecl _wfindnext64(intptr_t _FindHandle,struct _wfinddata64_t *_FindData);
328
329 _CRTIMP errno_t __cdecl _wsopen_s(int *_FileHandle,const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionFlag);
330
331 _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
332 _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
333
334#endif
335
336 int __cdecl __lock_fhandle(int _Filehandle);
337 void __cdecl _unlock_fhandle(int _Filehandle);
338 _CRTIMP intptr_t __cdecl _get_osfhandle(int _FileHandle);
339 _CRTIMP int __cdecl _open_osfhandle(intptr_t _OSFileHandle,int _Flags);
340
341#ifndef NO_OLDNAMES
342 int __cdecl access(const char *_Filename,int _AccessMode) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
343 int __cdecl chmod(const char *_Filename,int _AccessMode) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
344 int __cdecl chsize(int _FileHandle,long _Size) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
345 int __cdecl close(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
346 int __cdecl creat(const char *_Filename,int _PermissionMode) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
347 int __cdecl dup(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
348 int __cdecl dup2(int _FileHandleSrc,int _FileHandleDst) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
349 int __cdecl eof(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
350 long __cdecl filelength(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
351 int __cdecl isatty(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
352 int __cdecl locking(int _FileHandle,int _LockMode,long _NumOfBytes) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
353 long __cdecl lseek(int _FileHandle,long _Offset,int _Origin) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
354 char *__cdecl mktemp(char *_TemplateName) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
355 int __cdecl open(const char *_Filename,int _OpenFlag,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
356 int __cdecl read(int _FileHandle,void *_DstBuf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
357 int __cdecl setmode(int _FileHandle,int _Mode) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
358 int __cdecl sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
359 long __cdecl tell(int _FileHandle) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
360 int __cdecl umask(int _Mode) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
361 int __cdecl write(int _Filehandle,const void *_Buf,unsigned int _MaxCharCount) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
362#endif
363
364#ifndef _FILE_OFFSET_BITS_SET_LSEEK
365#define _FILE_OFFSET_BITS_SET_LSEEK
366#if (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64))
367#define lseek lseek64
368#endif /* (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */
369#endif /* _FILE_OFFSET_BITS_SET_LSEEK */
370
371#ifdef _POSIX
372
373/* Misc stuff */
374char *getlogin(void);
375#ifdef __USE_MINGW_ALARM
376unsigned int alarm(unsigned int seconds);
377#endif
378
379#endif
380
381#ifdef __USE_MINGW_ACCESS
382/* Old versions of MSVCRT access() just ignored X_OK, while the version
383 shipped with Vista, returns an error code. This will restore the
384 old behaviour */
385int __cdecl __mingw_access (const char *__fname, int __mode);
386
387#define access(__f,__m) __mingw_access (__f, __m)
388#endif
389
390#if __MINGW_FORTIFY_LEVEL > 0
391
392_CRTIMP int __cdecl __mingw_call__read(int, void *, unsigned int) __MINGW_ASM_CRT_CALL(_read);
393
394__mingw_bos_extern_ovr
395int _read(int __fh, void * __dst, unsigned int __n)
396{
397 __mingw_bos_ptr_chk_warn(__dst, __n, 0);
398 return __mingw_call__read(__fh, __dst, __n);
399}
400
401#ifndef NO_OLDNAMES
402__mingw_bos_extern_ovr
403int read(int __fh, void * __dst, unsigned int __n)
404{
405 return _read(__fh, __dst, __n);
406}
407#endif
408
409#if __MINGW_FORTIFY_VA_ARG
410
411#define _O_CREAT 0x0100
412
413_CRTIMP int __cdecl __mingw_call__open(const char *, int, ...) __MINGW_ASM_CRT_CALL(_open);
414_CRTIMP int __cdecl __mingw_call__open_warn_toomany(const char *, int, ...) __MINGW_ASM_CRT_CALL(_open)
415 __attribute__((__warning__("_open(): too many arguments")));
416_CRTIMP int __cdecl __mingw_call__open_warn_missing(const char *, int, ...) __MINGW_ASM_CRT_CALL(_open)
417 __attribute__((__warning__("_open(..._O_CREAT...): missing argument")));
418
419__mingw_bos_extern_ovr
420int _open(const char * __filename, int __flags, ...)
421{
422 if (__builtin_va_arg_pack_len() > 1)
423 return __mingw_call__open_warn_toomany(__filename, __flags, __builtin_va_arg_pack());
424 if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags & _O_CREAT) && (__flags & _O_CREAT))
425 return __mingw_call__open_warn_missing(__filename, __flags, 0);
426 if (__builtin_va_arg_pack_len() < 1)
427 return __mingw_call__open(__filename, __flags, 0);
428 return __mingw_call__open(__filename, __flags, __builtin_va_arg_pack());
429}
430
431_CRTIMP int __cdecl __mingw_call__sopen(const char *, int, int, ...) __MINGW_ASM_CRT_CALL(_sopen);
432_CRTIMP int __cdecl __mingw_call__sopen_warn_toomany(const char *, int, int, ...) __MINGW_ASM_CRT_CALL(_sopen)
433 __attribute__((__warning__("_sopen(): too many arguments")));
434_CRTIMP int __cdecl __mingw_call__sopen_warn_missing(const char *, int, int, ...) __MINGW_ASM_CRT_CALL(_sopen)
435 __attribute__((__warning__("_sopen(..._O_CREAT...): missing argument")));
436
437__mingw_bos_extern_ovr
438int _sopen(const char * __filename, int __flags, int __share, ...)
439{
440 if (__builtin_va_arg_pack_len() > 1)
441 return __mingw_call__sopen_warn_toomany(__filename, __flags, __share, __builtin_va_arg_pack());
442 if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags & _O_CREAT) && (__flags & _O_CREAT))
443 return __mingw_call__sopen_warn_missing(__filename, __flags, __share, 0);
444 if (__builtin_va_arg_pack_len() < 1)
445 return __mingw_call__sopen(__filename, __flags, __share, 0);
446 return __mingw_call__sopen(__filename, __flags, __share, __builtin_va_arg_pack());
447}
448
449_CRTIMP int __cdecl __mingw_call__wopen(const wchar_t *, int, ...) __MINGW_ASM_CRT_CALL(_wopen);
450_CRTIMP int __cdecl __mingw_call__wopen_warn_toomany(const wchar_t *, int, ...) __MINGW_ASM_CRT_CALL(_wopen)
451 __attribute__((__warning__("_wopen(): too many arguments")));
452_CRTIMP int __cdecl __mingw_call__wopen_warn_missing(const wchar_t *, int, ...) __MINGW_ASM_CRT_CALL(_wopen)
453 __attribute__((__warning__("_wopen(..._O_CREAT...): missing argument")));
454
455__mingw_bos_extern_ovr
456int _wopen(const wchar_t * __filename, int __flags, ...)
457{
458 if (__builtin_va_arg_pack_len() > 1)
459 return __mingw_call__wopen_warn_toomany(__filename, __flags, __builtin_va_arg_pack());
460 if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags & _O_CREAT) && (__flags & _O_CREAT))
461 return __mingw_call__wopen_warn_missing(__filename, __flags, 0);
462 if (__builtin_va_arg_pack_len() < 1)
463 return __mingw_call__wopen(__filename, __flags, 0);
464 return __mingw_call__wopen(__filename, __flags, __builtin_va_arg_pack());
465}
466
467_CRTIMP int __cdecl __mingw_call__wsopen(const wchar_t *, int, int, ...) __MINGW_ASM_CRT_CALL(_wsopen);
468_CRTIMP int __cdecl __mingw_call__wsopen_warn_toomany(const wchar_t *, int, int, ...) __MINGW_ASM_CRT_CALL(_wsopen)
469 __attribute__((__warning__("_wsopen(): too many arguments")));
470_CRTIMP int __cdecl __mingw_call__wsopen_warn_missing(const wchar_t *, int, int, ...) __MINGW_ASM_CRT_CALL(_wsopen)
471 __attribute__((__warning__("_wsopen(..._O_CREAT...): missing argument")));
472
473__mingw_bos_extern_ovr
474int _wsopen(const wchar_t * __filename, int __flags, int __share, ...)
475{
476 if (__builtin_va_arg_pack_len() > 1)
477 return __mingw_call__wsopen_warn_toomany(__filename, __flags, __share, __builtin_va_arg_pack());
478 if (__builtin_va_arg_pack_len() < 1 && __builtin_constant_p(__flags & _O_CREAT) && (__flags & _O_CREAT))
479 return __mingw_call__wsopen_warn_missing(__filename, __flags, __share, 0);
480 if (__builtin_va_arg_pack_len() < 1)
481 return __mingw_call__wsopen(__filename, __flags, __share, 0);
482 return __mingw_call__wsopen(__filename, __flags, __share, __builtin_va_arg_pack());
483}
484
485#ifndef NO_OLDNAMES
486__mingw_bos_extern_ovr
487int open(const char * __filename, int __flags, ...)
488{
489 return _open(__filename, __flags, __builtin_va_arg_pack());
490}
491
492__mingw_bos_extern_ovr
493int sopen(const char * __filename, int __flags, int __share, ...)
494{
495 return _sopen(__filename, __flags, __share, __builtin_va_arg_pack());
496}
497#endif
498
499#endif /* __MINGW_FORTIFY_VA_ARG */
500#endif /* __MINGW_FORTIFY_LEVEL > 0 */
501
502#ifdef __cplusplus
503}
504#endif
505
506
507#pragma pack(pop)
508
509#endif /* End _IO_H_ */
510