#ifndef _SYS_UNISTD_H
#define _SYS_UNISTD_H
#include <_ansi.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/signal.h>
#include <sys/resource.h>
#include <sys/syslimits.h>

#define __need_size_t
#include <stddef.h>

#undef __NORETURN /* из-за того, что в нескольких файлах */
#ifdef __GNUC__
#define __NORETURN __attribute__((noreturn))
#else
#define __NORETURN
#endif

#ifdef __cplusplus
extern "C" {
#endif

void	_EXFUN(_exit,(int _status )) __NORETURN;
int     _EXFUN(access,(const char *_path, int mode));
unsigned  _EXFUN(alarm, (unsigned _secs ));
int     _EXFUN(chdir, (const char *_path ));
int     _EXFUN(chmod, (const char *_path, mode_t _mode ));
int     _EXFUN(chown, (const char *_path, uid_t _owner, gid_t _group ));
int     _EXFUN(close, (int _fildes ));
char    _EXFUN(*ctermid, (char *_s ));
char    _EXFUN(*cuserid, (char *_s ));
int     _EXFUN(dup, (int _fildes ));
int     _EXFUN(dup2, (int _fildes, int _fildes2 ));

extern char **environ;

int     _EXFUN(execl, (const char *_path, const char *, ... ));
int     _EXFUN(execle, (const char *_path, const char *, ... ));
int     _EXFUN(execlp, (const char *_file, const char *, ... ));
int     _EXFUN(execv, (const char *_path, char * const _argv[] ));
int     _EXFUN(execve, (const char *_path, char * const _argv[], char * const _envp[] ));
int     _EXFUN(execvp, (const char *_file, char * const _argv[] ));
pid_t   _EXFUN(fork, (void ));
long    _EXFUN(fpathconf, (int _fd, int _name ));
char    _EXFUN(*getcwd, (char *_buf, size_t _size ));
gid_t   _EXFUN(getegid, (void ));
uid_t   _EXFUN(geteuid, (void ));
gid_t   _EXFUN(getgid, (void ));
int     _EXFUN(getgroups, (int _gidsetsize, gid_t _grouplist[] ));
char    _EXFUN(*getlogin, (void ));
pid_t   _EXFUN(getpgrp, (void ));
pid_t   _EXFUN(getpid, (void ));
pid_t   _EXFUN(getppid, (void ));
uid_t   _EXFUN(getuid, (void ));
int     _EXFUN(isatty, (int _fildes ));
int     _EXFUN(select, (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout));
int     _EXFUN(link, (const char *_path1, const char *_path2 ));
off_t   _EXFUN(lseek, (int _fildes, off_t _offset, int _whence ));
long    _EXFUN(pathconf, (char *_path, int _name ));
int     _EXFUN(pause, (void ));
int     _EXFUN(pipe, (int _fildes[2] ));
int     _EXFUN(read, (int _fildes, char *_buf, size_t _nbyte ));
int     _EXFUN(pread, (int _fildes, char *_buf, size_t _nbyte, off_t offset ));
int     _EXFUN(pwrite, (int _fildes, const char *_buf, size_t _nbyte, off_t offset ));
int     _EXFUN(rmdir, (const char *_path ));
int     _EXFUN(setgid, (gid_t _gid ));
int     _EXFUN(setpgid, (pid_t _pid, pid_t _pgid ));
pid_t   _EXFUN(setsid, (void ));
int     _EXFUN(setuid, (uid_t _uid ));
unsigned _EXFUN(sleep, (unsigned int _seconds ));
long    _EXFUN(sysconf, (int _name ));
pid_t   _EXFUN(tcgetpgrp, (int _fildes ));
int     _EXFUN(tcsetpgrp, (int _fildes, pid_t _pgrp_id ));
char    _EXFUN(*ttyname, (int _fildes ));
int     _EXFUN(unlink, (const char *_path ));
int     _EXFUN(write, (int _fildes, const char *_buf, size_t _nbyte ));
void*  _EXFUN(sbrk, (ptrdiff_t incr));
int    _EXFUN(ftruncate, (int fildes, off_t length));
int    _EXFUN(truncate, (const char *path, off_t length));
int    _EXFUN(symlink, (const char *oldpath, const char *newpath));
void*  _EXFUN(mmap, (void *addr, size_t len, int prot, int flags, int fd, off_t offset));
int    _EXFUN(munmap, (void *addr, size_t len));
int    _EXFUN(mprotect, (void *addr, size_t len, int prot));
int    _EXFUN(msync, (void *addr, size_t len, int flags));
int    _EXFUN(fsync, (int fd));
int    _EXFUN(getrlimit, (int resource, struct rlimit *rlim));
int    _EXFUN(setrlimit, (int resource, const struct rlimit *rlim));
long   _EXFUN(sysconf, (int _name));

#define getpagesize()       _PAGE_SIZE


#define	F_OK	                0
#define	R_OK	                4
#define	W_OK	                2
#define	X_OK	                1

#define	SEEK_SET	            0
#define	SEEK_CUR	            1
#define	SEEK_END	            2

#define _POSIX_JOB_CONTROL	    1
#define _POSIX_SAVED_IDS	    1
#define _POSIX_VERSION	        199009L

#define	_SC_ARG_MAX             0
#define	_SC_CHILD_MAX           1
#define	_SC_CLK_TCK             2
#define	_SC_NGROUPS_MAX         3
#define	_SC_OPEN_MAX            4
#define _SC_STREAM_MAX          5
#define	_SC_JOB_CONTROL         6
#define	_SC_SAVED_IDS           7
#define	_SC_VERSION             8
#define	_SC_PAGESIZE            9

#define	_PC_LINK_MAX            0
#define	_PC_MAX_CANON           1
#define	_PC_MAX_INPUT           2
#define	_PC_NAME_MAX            3
#define	_PC_PATH_MAX            4
#define	_PC_PIPE_BUF            5
#define	_PC_CHOWN_RESTRICTED    6
#define	_PC_NO_TRUNC            7
#define	_PC_VDISABLE            8

#ifdef __cplusplus
}
#endif

#endif
