#ifndef _WIN32
<unistd.h>
<sys/mman.h>
<regex.h>
<sys/time.h>
<sys/types.h>
#else
<stdio.h>
<winsock.h>
#include "winregex\rxposix.h"
#endif
<sys/types.h>
<fcntl.h>
<errno.h>


; unistd.h:
#ifndef _WIN32
i F_OK R_OK W_OK X_OK
i STDIN_FILENO STDOUT_FILENO STDERR_FILENO
#else
J F_OK=:0
J R_OK=:4
J W_OK=:2
J X_OK=:1
#endif
i SEEK_CUR SEEK_END SEEK_SET
; Defining NULL is problematic in various ways.
; Most notably, it's unclear whether it should be boxed or not.

; fcntl:
i O_APPEND O_CREAT O_EXCL O_RDONLY O_RDWR O_TRUNC O_WRONLY

#ifndef _WIN32
i O_ACCMODE O_NOCTTY O_NONBLOCK 
i FD_CLOEXEC
i F_DUPFD F_GETFD F_SETFD F_GETFL F_SETFL
i F_SETLK F_SETLKW F_GETLK F_UNLCK F_WRLCK
st struct flock
f	l_len
f	l_pid
f	l_start
f	l_type
f	l_whence

; mmap:
i PROT_READ PROT_WRITE PROT_EXEC PROT_NONE
i MAP_SHARED MAP_PRIVATE MAP_FIXED
#endif

; Regex stuff:
i REG_EXTENDED REG_ICASE REG_NOSUB REG_NEWLINE

st regex_t
f	re_nsub
st regmatch_t
f	rm_so
f	rm_eo

; select(2) support.
; This is beyond posix.1, but the following definitions are pretty
; universal now.  Linux apparently requires some special treatment.
#ifdef linux
#define fds_bits __fds_bits
#endif

#ifndef _WIN32
st fd_set
f	fds_bits
#endif
i FD_SETSIZE
st struct timeval
f	tv_sec
f	tv_usec

; POSIX error constants:
i E2BIG		EFAULT		ENFILE		ENOTTY
i EACCES	EFBIG		ENODEV		ENXIO
i EAGAIN	ENOENT		EPERM
i EBADF		EINTR		ENOEXEC		EPIPE
i EINVAL	ENOLCK		ERANGE
i EBUSY		EIO		ENOMEM		EROFS
i EISDIR	ENOSPC		ESPIPE
i ECHILD	EMFILE		ENOSYS		ESRCH
i EDEADLK	EMLINK		ENOTDIR
i EDOM		ENOTEMPTY	EXDEV
i EEXIST	ENAMETOOLONG

#ifndef _WIN32
i EINPROGRESS ECANCELED ETIMEDOUT EMSGSIZE ENOTSUP
#endif