enum {
	O_ACCMODE	= 0003,
	O_RDONLY	= 00,
	O_WRONLY	= 01,
	O_RDWR		= 02,
	O_CREAT		= 0100,
	O_EXCL		= 0200,
	O_NOCTTY	= 0400,
	O_TRUNC		= 01000,
	O_APPEND	= 02000,
	O_NONBLOCK	= 04000,
	O_NDELAY	= 04000,
	O_SYNC		= 010000,
	FASYNC		= 020000,
};

enum {
	FD_CLOEXEC = 1,
};

enum {
	F_DUPFD		= 0,
	F_GETFD,
	F_SETFD,
	F_GETFL,
	F_SETFL,
	F_GETLK,
	F_SETLK,
	F_SETLKW,
	F_SETOWN,
	F_GETOWN,
	F_GETSIG,
	F_GETLK64	= 12,
	F_SETLK64	= 13,
};

enum {
	S_IFMT			= 0170000,
	S_IFSOCK		= 0140000,
	S_IFLNK			= 0120000,
	S_IFREG			= 0100000,
	S_IFBLK			= 0060000,
	S_IFDIR			= 0040000,
	S_IFCHR			= 0020000,
	S_IFIFO			= 0010000,
	S_ISUID			= 0004000,
	S_ISGID			= 0002000,
	S_ISVTX			= 0001000,
};

enum {
	PROT_READ		= 0x01,
	PROT_WRITE		= 0x02,
	PROT_EXEC		= 0x04,
	PROT_SEM		= 0x08,
	PROT_NONE		= 0x00,
	PROT_GROWSDOWN	= 0x01000000,
	PROT_GROWSUP	= 0x02000000,
	MAP_SHARED		= 0x01,
	MAP_PRIVATE		= 0x02,
	MAP_TYPE		= 0x0f,
	MAP_FIXED		= 0x10,
	MAP_ANONYMOUS	= 0x20,

	MREMAP_MAYMOVE	= 1,
	MREMAP_FIXED	= 2,
};

enum {
	CLONE_VM				= 0x00000100,
	CLONE_FS				= 0x00000200,
	CLONE_FILES				= 0x00000400,
	CLONE_SIGHAND			= 0x00000800,
	CLONE_PTRACE			= 0x00002000,
	CLONE_VFORK				= 0x00004000,
	CLONE_PARENT			= 0x00008000,
	CLONE_THREAD			= 0x00010000,
	CLONE_NEWNS				= 0x00020000,
	CLONE_SYSVSEM			= 0x00040000,
	CLONE_SETTLS			= 0x00080000,
	CLONE_PARENT_SETTID		= 0x00100000,
	CLONE_CHILD_CLEARTID	= 0x00200000,
	CLONE_DETACHED			= 0x00400000,
	CLONE_UNTRACED			= 0x00800000,
	CLONE_CHILD_SETTID		= 0x01000000,
	CLONE_STOPPED			= 0x02000000,
};

enum {
	EPERM			= 1,
	ENOENT			= 2,
	ESRCH			= 3,
	EINTR			= 4,
	EIO				= 5,
	ENXIO			= 6,
	E2BIG			= 7,
	ENOEXEC			= 8,
	EBADF			= 9,
	ECHILD			= 10,
	EAGAIN			= 11,
	ENOMEM			= 12,
	EACCES			= 13,
	EFAULT			= 14,
	ENOTBLK			= 15,
	EBUSY			= 16,
	EEXIST			= 17,
	EXDEV			= 18,
	ENODEV			= 19,
	ENOTDIR			= 20,
	EISDIR			= 21,
	EINVAL			= 22,
	ENFILE			= 23,
	EMFILE			= 24,
	ENOTTY			= 25,
	ETXTBSY			= 26,
	EFBIG			= 27,
	ENOSPC			= 28,
	ESPIPE			= 29,
	EROFS			= 30,
	EMLINK			= 31,
	EPIPE			= 32,
	EDOM			= 33,
	ERANGE			= 34,
	EDEADLK			= 35,
	ENAMETOOLONG	= 36,
	ENOLCK			= 37,
	ENOSYS			= 38,
	ENOTEMPTY		= 39,
	ELOOP			= 40,
	ENOMSG			= 42,
	EIDRM			= 43,
	ECHRNG			= 44,
	EL2NSYNC		= 45,
	EL3HLT			= 46,
	EL3RST			= 47,
	ELNRNG			= 48,
	EUNATCH			= 49,
	ENOCSI			= 50,
	EL2HLT			= 51,
	EBADE			= 52,
	EBADR			= 53,
	EXFULL			= 54,
	ENOANO			= 55,
	EBADRQC			= 56,
	EBADSLT			= 57,
	EBFONT			= 59,
	ENOSTR			= 60,
	ENODATA			= 61,
	ETIME			= 62,
	ENOSR			= 63,
	ENONET			= 64,
	ENOPKG			= 65,
	EREMOTE			= 66,
	ENOLINK			= 67,
	EADV			= 68,
	ESRMNT			= 69,
	ECOMM			= 70,
	EPROTO			= 71,
	EMULTIHOP		= 72,
	EDOTDOT			= 73,
	EBADMSG			= 74,
	EOVERFLOW		= 75,
	ENOTUNIQ		= 76,
	EBADFD			= 77,
	EREMCHG			= 78,
	ELIBACC			= 79,
	ELIBBAD			= 80,
	ELIBSCN			= 81,
	ELIBMAX			= 82,
	ELIBEXEC		= 83,
	EILSEQ			= 84,
	ERESTART		= 85,
	ESTRPIPE		= 86,
	EUSERS			= 87,
	ENOTSOCK		= 88,
	EDESTADDRREQ	= 89,
	EMSGSIZE		= 90,
	EPROTOTYPE		= 91,
	ENOPROTOOPT		= 92,
	EPROTONOSUPPORT	= 93,
	ESOCKTNOSUPPORT	= 94,
	EOPNOTSUPP		= 95,
	EPFNOSUPPORT	= 96,
	EAFNOSUPPORT	= 97,
	EADDRINUSE		= 98,
	EADDRNOTAVAIL	= 99,
	ENETDOWN		= 100,
	ENETUNREACH		= 101,
	ENETRESET		= 102,
	ECONNABORTED	= 103,
	ECONNRESET		= 104,
	ENOBUFS			= 105,
	EISCONN			= 106,
	ENOTCONN		= 107,
	ESHUTDOWN		= 108,
	ETOOMANYREFS	= 109,
	ETIMEDOUT		= 110,
	ECONNREFUSED	= 111,
	EHOSTDOWN		= 112,
	EHOSTUNREACH	= 113,
	EALREADY		= 114,
	EINPROGRESS		= 115,
	ESTALE			= 116,
	EUCLEAN			= 117,
	ENOTNAM			= 118,
	ENAVAIL			= 119,
	EISNAM			= 120,
	EREMOTEIO		= 121,
	EDQUOT			= 122,
	ENOMEDIUM		= 123,
	EMEDIUMTYPE		= 124,
	EMAX			= 125,
};

#define EWOULDBLOCK	EAGAIN
#define EDEADLOCK	EDEADLK
#define ENOATTR		ENODATA

enum {
	POLLIN			= (1<<0),
	POLLPRI			= (1<<1),
	POLLOUT			= (1<<2),
	POLLERR			= (1<<3),
	POLLHUP			= (1<<4),
	POLLNVAL		= (1<<5),
	POLLRDNORM		= (1<<6),
	POLLRDBAND		= (1<<7),
	POLLWRNORM		= (1<<8),
	POLLWRBAND		= (1<<9),
	POLLMSG			= (1<<10),
	POLLREMOVE		= (1<<11),
	POLLRDHUP		= 0x2000,
	EPOLLONESHOT	= (1<<30),
	EPOLLET			= (1<<31),
};

enum {
	SIGHUP		= 1,
	SIGINT		= 2,
	SIGQUIT		= 3,
	SIGILL		= 4,
	SIGTRAP		= 5,
	SIGABRT		= 6,
	SIGIOT		= 6,
	SIGBUS		= 7,
	SIGFPE		= 8,
	SIGKILL		= 9,
	SIGUSR1		= 10,
	SIGSEGV		= 11,
	SIGUSR2		= 12,
	SIGPIPE		= 13,
	SIGALRM		= 14,
	SIGTERM		= 15,
	SIGSTKFLT	= 16,
	SIGCHLD		= 17,
	SIGCONT		= 18,
	SIGSTOP		= 19,
	SIGTSTP		= 20,
	SIGTTIN		= 21,
	SIGTTOU		= 22,
	SIGURG		= 23,
	SIGXCPU		= 24,
	SIGXFSZ		= 25,
	SIGVTALRM	= 26,
	SIGPROF		= 27,
	SIGWINCH	= 28,
	SIGIO		= 29,
	SIGPOLL		= 29,
	SIGLOST		= 29,
	SIGPWR		= 30,
	SIGSYS		= 31,

	SIGRT1		= 32,
	SIGRT2		= 33,
	SIGRT3		= 34,
	SIGRT4		= 35,
	SIGRT5		= 36,
	SIGRT6		= 37,
	SIGRT7		= 38,
	SIGRT8		= 39,

	SIGMAX		= 40,
};

enum {
	SI_USER			= 0,
	SI_QUEUE		= -1,
	SI_TIMER		= -2,
	SI_MESGQ		= -3,
	SI_ASYNCIO		= -4,
	SI_SIGIO		= -5,
	SI_TKILL		= -6,
	SI_DETHREAD		= -7,
};

enum {
	ILL_ILLOPC		= 1,
	ILL_ILLOPN,
	ILL_ILLADR,
	ILL_ILLTRP,
	ILL_PROVOPC,
	ILL_PRVREG,
	ILL_COPROC,
	ILL_BADSTK,
};

enum {
	FPE_INTDIV		= 1,
	FPE_INTOVF,
	FPE_FLTDIV,
	FPE_FLTOVF,
	FPE_FLTUND,
	FPE_FLTRES,
	FPE_FLTINV,
	FPE_FLTSUB, 
};

enum {
	WNOHANG	=0x00000001,
	WUNTRACED	=0x00000002,
	WSTOPPED	=0x00000002,
	WEXITED		=0x00000004,
	WCONTINUED	=0x00000008,
	WNOWAIT	=0x01000000,
	WNOTHREAD	=0x20000000,
	WALL		=0x40000000,
	WCLONE		=0x80000000,
};

struct linux_timeval
{
	long	tv_sec;
	long	tv_usec;
};

struct linux_timespec
{
	long	tv_sec;
	long	tv_nsec;
};

struct linux_user_desc {
 	uint  entry_number;
	ulong base_addr;
	uint  limit;
	uint  seg_32bit:1;
	int  contents:2;
	uint  read_exec_only:1;
	uint  limit_in_pages:1;
	uint  seg_not_present:1;
	uint  useable:1;
};
