| #ifndef _UNISTD_H |
| #define _UNISTD_H |
| |
| #define _IO_H_ |
| |
| #include <sys/types.h> |
| |
| /* |
| * Attributes of files as returned by _findfirst et al. |
| */ |
| #define _A_NORMAL 0x00000000 |
| #define _A_RDONLY 0x00000001 |
| #define _A_HIDDEN 0x00000002 |
| #define _A_SYSTEM 0x00000004 |
| #define _A_VOLID 0x00000008 |
| #define _A_SUBDIR 0x00000010 |
| #define _A_ARCH 0x00000020 |
| |
| |
| #ifndef RC_INVOKED |
| |
| #ifndef _INTPTR_T_DEFINED |
| #define _INTPTR_T_DEFINED |
| #ifdef _WIN64 |
| typedef __int64 intptr_t; |
| #else |
| typedef int intptr_t; |
| #endif |
| #endif |
| |
| #ifndef _FSIZE_T_DEFINED |
| typedef unsigned long _fsize_t; |
| #define _FSIZE_T_DEFINED |
| #endif |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW chdir(const char *); |
| _CRTIMP char *__cdecl __MINGW_NOTHROW getcwd(char *, int); |
| _CRTIMP char *__cdecl __MINGW_NOTHROW mktemp(char *); |
| //_CRTIMP int __cdecl __MINGW_NOTHROW chmod(const char *, mode_t); |
| |
| #ifdef __MSVCRT__ |
| _CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int); |
| _CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int); |
| |
| #ifndef __NO_MINGW_LFS |
| __CRT_INLINE off64_t lseek64 (int, off64_t, int); |
| __CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence) { |
| return _lseeki64(fd, (__int64) offset, whence); |
| } |
| #endif |
| |
| #endif /* __MSVCRT__ */ |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* Not RC_INVOKED */ |
| |
| /* TODO: Maximum number of open handles has not been tested, I just set |
| * it the same as FOPEN_MAX. */ |
| #define HANDLE_MAX FOPEN_MAX |
| |
| /* Some defines for _access nAccessMode (MS doesn't define them, but |
| * it doesn't seem to hurt to add them). */ |
| #define F_OK 0 /* Check for file existence */ |
| /* Well maybe it does hurt. On newer versions of MSVCRT, an access mode |
| of 1 causes invalid parameter error. */ |
| #define X_OK 1 /* Execute permission, Always OK */ |
| #define W_OK 2 /* Check for write permission */ |
| #define R_OK 4 /* Check for read permission */ |
| |
| #ifndef RC_INVOKED |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW access(const char*, int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW chsize(int, long); |
| _CRTIMP int __cdecl __MINGW_NOTHROW close(int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW commit(int); |
| |
| /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80), |
| * the "owner write permission" bit (on FAT). */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW creat(const char *, mode_t); |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW dup (int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW dup2 (int, int); |
| _CRTIMP long __cdecl __MINGW_NOTHROW filelength (int); |
| _CRTIMP long __cdecl __MINGW_NOTHROW get_osfhandle (int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW isatty (int); |
| |
| /* In a very odd turn of events this function is excluded from those |
| * files which define _STREAM_COMPAT. This is required in order to |
| * build GNU libio because of a conflict with _eof in streambuf.h |
| * line 107. Actually I might just be able to change the name of |
| * the enum member in streambuf.h... we'll see. TODO */ |
| #ifndef _STREAM_COMPAT |
| _CRTIMP int __cdecl __MINGW_NOTHROW _eof (int); |
| #endif |
| |
| /* LK_... locking commands defined in sys/locking.h. */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW _locking(int, int, long); |
| |
| _CRTIMP long __cdecl __MINGW_NOTHROW lseek(int, off_t, int); |
| |
| /* Optional third argument is unsigned unPermissions. */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW open(const char *, int, ...); |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW _open_osfhandle (long, int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW pipe(int *, unsigned int, int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW read(int, void *, unsigned int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _setmode(int, int); |
| /* MS puts remove & rename (but not wide versions) in io.h as well |
| as in stdio.h. */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW remove(const char *); |
| _CRTIMP int __cdecl __MINGW_NOTHROW rename(const char *, const char *); |
| |
| /* SH_... flags for nShFlags defined in share.h |
| * Optional fourth argument is unsigned unPermissions */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW _sopen(const char *, int, int, ...); |
| |
| _CRTIMP long __cdecl __MINGW_NOTHROW _tell(int); |
| /* Should umask be in sys/stat.h and/or sys/types.h instead? */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW umask(int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW unlink(const char *); |
| _CRTIMP int __cdecl __MINGW_NOTHROW write(int, const void *, unsigned int); |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* Not RC_INVOKED */ |
| |
| #include <process.h> |
| |
| #define __UNISTD_GETOPT__ |
| #include <getopt.h> |
| #undef __UNISTD_GETOPT__ |
| |
| /* These are also defined in stdio.h. */ |
| #ifndef SEEK_SET |
| #define SEEK_SET 0 |
| #endif |
| |
| #ifndef SEEK_CUR |
| #define SEEK_CUR 1 |
| #endif |
| |
| #ifndef SEEK_END |
| #define SEEK_END 2 |
| #endif |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| |
| /* This is defined as a real library function to allow autoconf |
| to verify its existence. */ |
| int ftruncate(int, off_t); |
| __CRT_INLINE int ftruncate(int __fd, off_t __length) |
| { |
| return chsize(__fd, __length); |
| } |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* _UNISTD_H */ |