io.h 19 KB

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