diff options
Diffstat (limited to 'include/sys')
| -rw-r--r-- | include/sys/cdefs.h | 7 | ||||
| -rw-r--r-- | include/sys/ioctl.h | 8 | ||||
| -rw-r--r-- | include/sys/ipc.h | 29 | ||||
| -rw-r--r-- | include/sys/mman.h | 34 | ||||
| -rw-r--r-- | include/sys/mount.h | 9 | ||||
| -rw-r--r-- | include/sys/msg.h | 31 | ||||
| -rw-r--r-- | include/sys/param.h | 11 | ||||
| -rw-r--r-- | include/sys/select.h | 19 | ||||
| -rw-r--r-- | include/sys/sem.h | 40 | ||||
| -rw-r--r-- | include/sys/socket.h | 142 | ||||
| -rw-r--r-- | include/sys/stat.h | 66 | ||||
| -rw-r--r-- | include/sys/statvfs.h | 27 | ||||
| -rw-r--r-- | include/sys/time.h | 12 | ||||
| -rw-r--r-- | include/sys/times.h | 15 | ||||
| -rw-r--r-- | include/sys/types.h | 42 | ||||
| -rw-r--r-- | include/sys/uio.h | 15 | ||||
| -rw-r--r-- | include/sys/un.h | 11 | ||||
| -rw-r--r-- | include/sys/utsname.h | 14 | ||||
| -rw-r--r-- | include/sys/wait.h | 45 |
19 files changed, 577 insertions, 0 deletions
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h new file mode 100644 index 00000000..0ef66647 --- /dev/null +++ b/include/sys/cdefs.h @@ -0,0 +1,7 @@ +#ifndef __SYS_CDEFS_H +#define __SYS_CDEFS_H + +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } + +#endif diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h new file mode 100644 index 00000000..c9b872bd --- /dev/null +++ b/include/sys/ioctl.h @@ -0,0 +1,8 @@ +#ifndef __SYS_IOCTL_H +#define __SYS_IOCTL_H + +#define TIOCGWINSZ 0x5413 + +int ioctl(int, int, ...); + +#endif diff --git a/include/sys/ipc.h b/include/sys/ipc.h new file mode 100644 index 00000000..d55af58f --- /dev/null +++ b/include/sys/ipc.h @@ -0,0 +1,29 @@ +#ifndef __SYS_IPC_H +#define __SYS_IPC_H + +#define IPC_CREAT 00001000 +#define IPC_EXCL 00002000 +#define IPC_NOWAIT 00004000 + +#define IPC_PRIVATE ((key_t)0) + +#define IPC_RMID 0 +#define IPC_SET 1 +#define IPC_STAT 2 + +typedef __UINT32_TYPE__ uid_t; +typedef __UINT32_TYPE__ gid_t; +typedef __UINT32_TYPE__ mode_t; +typedef __INT32_TYPE__ key_t; + +struct ipc_perm { + uid_t uid; + gid_t gid; + uid_t cuid; + gid_t cgid; + mode_t mode; +}; + +key_t ftok(const char *, int); + +#endif diff --git a/include/sys/mman.h b/include/sys/mman.h new file mode 100644 index 00000000..3e5dbf96 --- /dev/null +++ b/include/sys/mman.h @@ -0,0 +1,34 @@ +#ifndef __SYS_MMAN_H +#define __SYS_MMAN_H + +typedef __SIZE_TYPE__ size_t; +typedef __INT64_TYPE__ off_t; +typedef __UINT32_TYPE__ mode_t; + +#define PROT_NONE 0 +#define PROT_READ 1 +#define PROT_WRITE 2 +#define PROT_EXEC 4 + +#define MAP_FAILED ((void *)-1) + +#define MAP_FIXED 0x10 +#define MAP_ANON 0x20 +#define MAP_ANONYMOUS MAP_ANON +#define MAP_PRIVATE 0x02 +#define MAP_SHARED 0x01 + +#define MAP_NORESERVE 0x04000 +#define MAP_POPULATE 0x08000 + +#define POSIX_MADV_NORMAL 0 +#define POSIX_MADV_RANDOM 1 +#define POSIX_MADV_SEQUENTIAL 2 +#define POSIX_MADV_WILLNEED 3 +#define POSIX_MADV_DONTNEED 4 + +void *mmap(void *, size_t, int, int, int, off_t); +int munmap(void *, size_t); +int posix_madvise(void *, size_t, int); + +#endif diff --git a/include/sys/mount.h b/include/sys/mount.h new file mode 100644 index 00000000..66207be3 --- /dev/null +++ b/include/sys/mount.h @@ -0,0 +1,9 @@ +#ifndef __SYS_MOUNT_H +#define __SYS_MOUNT_H + +int mount(const char *, const char *, const char *, unsigned long, + const void *); +int umount(const char *); +int umount2(const char *, int); + +#endif diff --git a/include/sys/msg.h b/include/sys/msg.h new file mode 100644 index 00000000..b9a16349 --- /dev/null +++ b/include/sys/msg.h @@ -0,0 +1,31 @@ +#ifndef __SYS_MSG_H +#define __SYS_MSG_H + +#include <sys/ipc.h> + +typedef __INT64_TYPE__ pid_t; +typedef __INT64_TYPE__ ssize_t; +typedef __INT64_TYPE__ time_t; +typedef __SIZE_TYPE__ size_t; +typedef unsigned long msglen_t; +typedef unsigned long msgqnum_t; + +#define MSG_NOERROR 010000 + +struct msqid_ds { + struct ipc_perm msg_perm; + msgqnum_t msg_qnum; + msglen_t msg_qbytes; + pid_t msg_lspid; + pid_t msg_lrpid; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; +}; + +int msgctl(int, int, struct msqid_ds *); +int msgget(key_t, int); +ssize_t msgrcv(int, void *, size_t, long, int); +int msgsnd(int, const void *, size_t, int); + +#endif diff --git a/include/sys/param.h b/include/sys/param.h new file mode 100644 index 00000000..bd5bc0a1 --- /dev/null +++ b/include/sys/param.h @@ -0,0 +1,11 @@ +#ifndef __SYS_PARAM_H +#define __SYS_PARAM_H + +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#define offsetof(s, e) __builtin_offsetof(s, e) + +#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) + +#endif diff --git a/include/sys/select.h b/include/sys/select.h new file mode 100644 index 00000000..44abc2e1 --- /dev/null +++ b/include/sys/select.h @@ -0,0 +1,19 @@ +#ifndef __SYS_SELECT_H +#define __SYS_SELECT_H + +#define __BITS_SELECT_H_ +#include <bits/select.h> +#undef __BITS_SELECT_H_ + +#define __BITS_TIMESPEC_H_ +#include <bits/timespec.h> +#undef __BITS_TIMESPEC_H_ + +typedef __INT32_TYPE__ sigset_t; + +int pselect(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + const struct timespec *restrict, const sigset_t *restrict); +int select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timeval *restrict); + +#endif diff --git a/include/sys/sem.h b/include/sys/sem.h new file mode 100644 index 00000000..2fdaa834 --- /dev/null +++ b/include/sys/sem.h @@ -0,0 +1,40 @@ +#ifndef __SYS_SEM_H +#define __SYS_SEM_H + +#include <sys/ipc.h> + +#define SEM_UNDO 0x1000 +#define GETNCNT 14 +#define GETPID 11 +#define GETVAL 12 +#define GETALL 13 +#define GETZCNT 15 +#define SETVAL 16 +#define SETALL 17 + +typedef __INT64_TYPE__ pid_t; +typedef __SIZE_TYPE__ size_t; +typedef __INT64_TYPE__ time_t; +typedef __UINT32_TYPE__ uid_t; +typedef __UINT32_TYPE__ gid_t; +typedef __UINT32_TYPE__ mode_t; +typedef __INT32_TYPE__ key_t; + +struct semid_ds { + struct ipc_perm sem_perm; + unsigned short sem_nsems; + time_t sem_otime; + time_t sem_ctime; +}; + +struct sembuf { + unsigned short sem_num; + short sem_op; + short sem_flg; +}; + +int semctl(int, int, int, ...); +int semget(key_t, int, int); +int semop(int, struct sembuf *, size_t); + +#endif diff --git a/include/sys/socket.h b/include/sys/socket.h new file mode 100644 index 00000000..d8a48dd0 --- /dev/null +++ b/include/sys/socket.h @@ -0,0 +1,142 @@ +#ifndef __SYS_SOCKET_H +#define __SYS_SOCKET_H + +#define SCM_RIGHTS 0x01 + +#define CMSG_DATA(cmsg) ((void *)(cmsg) + sizeof(struct cmsghdr)) + +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((cmsg)->cmsg_len < sizeof(struct cmsghdr) || \ + (((cmsg)->cmsg_len + sizeof(long) - 1) & \ + ~(long)(sizeof(long) - 1)) + \ + sizeof(struct cmsghdr) >= \ + ((unsigned char *)(mhdr)->msg_control + \ + (mhdr)->msg_controllen) - \ + (unsigned char *)(cmsg) ? \ + 0 : \ + (struct cmsghdr *)((unsigned char *)(cmsg) + \ + __CMSG_LEN(cmsg))) + +#define CMSG_FIRSTHDR(mhdr) \ + ((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : \ + (struct cmsghdr *)0) + +#define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr))) + +#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) + +struct linger { + int l_onoff; + int l_linger; +}; + +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#define SOCK_RAW 3 +#define SOCK_RDM 4 +#define SOCK_SEQPACKET 5 +#define SOCK_DCCP 6 +#define SOCK_PACKET = 10 + +// TODO: fill with fcntl values +#define SOCK_NONBLOCK O_NONBLOCK +#define SOCK_CLOEXEC O_CLOEXEC +#define SOCK_CLOFORK 0 + +#define SO_ACCEPTCONN 30 +#define SO_BROADCAST 6 +#define SO_DEBUG 1 +#define SO_DOMAIN 39 +#define SO_DONTROUTE 5 +#define SO_ERROR 4 +#define SO_KEEPALIVE 9 +#define SO_LINGER 13 +#define SO_OOBINLINE 10 +#define SO_PROTOCOL 38 +#define SO_RCVBUF 8 +#define SO_RCVLOWAT 18 +#define SO_RCVTIMEO 66 +#define SO_SNDBUF 7 +#define SO_SNDLOWAT 19 +#define SO_SNDTIMEO 67 +#define SO_TYPEA 3 +#define SOL_SOCKET 1 + +#define SOMAXCONN 4096 + +#define MSG_CMSG_CLOFORK 0x00000000 +#define MSG_OOB 0x00000001 +#define MSG_PEEK 0x00000002 +#define MSG_DONTROUTE 0x00000004 +#define MSG_CTRUNC 0x00000008 +#define MSG_TRUNC 0x00000020 +#define MSG_EOR 0x00000080 +#define MSG_WAITALL 0x00000100 +#define MSG_NOSIGNAL 0x00004000 +#define MSG_CMSG_CLOEXEC 0x40000000 + +#define AF_UNSPEC 0 +#define AF_UNIX 1 +#define AF_INET 2 +#define AF_INET6 10 + +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 + +typedef __INT32_TYPE__ socklen_t; +typedef __UINT16_TYPE__ sa_family_t; +typedef __SIZE_TYPE__ size_t; +typedef __INT64_TYPE__ ssize_t; + +struct sockaddr { + sa_family_t sa_family; + char sa_data[]; +}; + +struct sockaddr_storage { + sa_family_t ss_family; + char __padding[128 - sizeof(long) - sizeof(sa_family_t)]; + unsigned long __align; +}; + +struct msghdr { + void *msg_name; + socklen_t msg_namelen; + struct iovec *msg_iov; + int msg_iovlen; + void *msg_control; + socklen_t msg_controllen; + int msg_flags; +}; + +struct cmsghdr { + socklen_t cmsg_len; + int cmsg_level; + int cmsg_type; +}; + +int accept(int, struct sockaddr *restrict, socklen_t *restrict); +int accept4(int, struct sockaddr *restrict, socklen_t *restrict, int); +int bind(int, const struct sockaddr *, socklen_t); +int connect(int, const struct sockaddr *, socklen_t); +int getpeername(int, struct sockaddr *restrict, socklen_t *restrict); +int getsockname(int, struct sockaddr *restrict, socklen_t *restrict); +int getsockopt(int, int, int, void *restrict, socklen_t *restrict); +int listen(int, int); +ssize_t recv(int, void *, size_t, int); +ssize_t recvfrom(int, void *restrict, size_t, int, struct sockaddr *restrict, + socklen_t *restrict); +ssize_t recvmsg(int, struct msghdr *, int); +ssize_t send(int, const void *, size_t, int); +ssize_t sendmsg(int, const struct msghdr *, int); +ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, + socklen_t); +int setsockopt(int, int, int, const void *, socklen_t); +int shutdown(int, int); +int sockatmark(int); +int socket(int, int, int); +int socketpair(int, int, int, int[2]); + +#endif diff --git a/include/sys/stat.h b/include/sys/stat.h new file mode 100644 index 00000000..ceb0826f --- /dev/null +++ b/include/sys/stat.h @@ -0,0 +1,66 @@ +#ifndef __SYS_STAT_H +#define __SYS_STAT_H + +#define __BITS_STAT_H_ +#include <bits/stat.h> +#undef __BITS_STAT_H_ + +#define S_IFMT 00170000 +#define S_IFBLK 0060000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_IFREG 0100000 +#define S_IFDIR 0040000 +#define S_IFLNK 0120000 +#define S_IFSOCK 0140000 + +#define S_IRWXU 0000700 +#define S_IRUSR 0000400 +#define S_IWUSR 0000200 +#define S_IXUSR 0000100 +#define S_IRWXG 0000070 +#define S_IRGRP 0000040 +#define S_IWGRP 0000020 +#define S_IXGRP 0000010 +#define S_IRWXO 0000007 +#define S_IROTH 0000004 +#define S_IWOTH 0000002 +#define S_IXOTH 0000001 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) +#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) +#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) +#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) + +#define S_TYPEISMQ(buf) 0 +#define S_TYPEISSEM(buf) 0 +#define S_TYPEISSHM(buf) 0 +#define S_TYPEISTMO(buf) 0 + +#define UTIME_NOW 0x3fffffff +#define UTIME_OMIT 0x3ffffffe + +int chmod(const char *, mode_t); +int fchmod(int, mode_t); +int fchmodat(int, const char *, mode_t, int); +int fstat(int, struct stat *); +int fstatat(int, const char *restrict, struct stat *restrict, int); +int futimens(int, const struct timespec[2]); +int lstat(const char *restrict, struct stat *restrict); +int mkdir(const char *, mode_t); +int mkdirat(int, const char *, mode_t); +int mkfifo(const char *, mode_t); +int mkfifoat(int, const char *, mode_t); +int mknod(const char *, mode_t, dev_t); +int mknodat(int, const char *, mode_t, dev_t); +int stat(const char *restrict, struct stat *restrict); +mode_t umask(mode_t); +int utimensat(int, const char *, const struct timespec[2], int); + +#endif diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h new file mode 100644 index 00000000..ce0ed957 --- /dev/null +++ b/include/sys/statvfs.h @@ -0,0 +1,27 @@ +#ifndef __STATVFS_H +#define __STATVFS_H + +#define ST_RDONLY 1 +#define ST_NOSUID 2 + +typedef __UINT64_TYPE__ fsblkcnt_t; +typedef __UINT64_TYPE__ fsfilcnt_t; + +struct statvfs { + unsigned long f_bsize; + unsigned long f_frsize; + fsblkcnt_t f_blocks; + fsblkcnt_t f_bfree; + fsblkcnt_t f_bavail; + fsfilcnt_t f_files; + fsfilcnt_t f_ffree; + fsfilcnt_t f_favail; + unsigned long f_fsid; + unsigned long f_flag; + unsigned long f_namemax; +}; + +int fstatvfs(int, struct statvfs *); +int statvfs(const char *restrict, struct statvfs *restrict); + +#endif diff --git a/include/sys/time.h b/include/sys/time.h new file mode 100644 index 00000000..5f34e744 --- /dev/null +++ b/include/sys/time.h @@ -0,0 +1,12 @@ +#ifndef __SYS_TIME_H +#define __SYS_TIME_H + +#define __BITS_SELECT_H_ +#include <bits/select.h> +#undef __BITS_SELECT_H_ + +int select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, + struct timeval *restrict); +int utimes(const char *, const struct timeval[2]); + +#endif diff --git a/include/sys/times.h b/include/sys/times.h new file mode 100644 index 00000000..4cc0e184 --- /dev/null +++ b/include/sys/times.h @@ -0,0 +1,15 @@ +#ifndef __SYS_TIMES_H +#define __SYS_TIMES_H + +typedef __INT64_TYPE__ clock_t; + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +clock_t times(struct tms *); + +#endif diff --git a/include/sys/types.h b/include/sys/types.h new file mode 100644 index 00000000..6da69434 --- /dev/null +++ b/include/sys/types.h @@ -0,0 +1,42 @@ +#ifndef __SYS_TYPES_H +#define __SYS_TYPES_H + +typedef __INT64_TYPE__ blkcnt_t; +typedef __INT32_TYPE__ blksize_t; +typedef __INT64_TYPE__ clock_t; +typedef __INT32_TYPE__ clockid_t; +typedef __UINT64_TYPE__ dev_t; +typedef __UINT64_TYPE__ fsblkcnt_t; +typedef __UINT64_TYPE__ fsfilcnt_t; +typedef __UINT32_TYPE__ gid_t; +typedef __UINT32_TYPE__ id_t; +typedef __UINT64_TYPE__ ino_t; +typedef __INT32_TYPE__ key_t; +typedef __UINT32_TYPE__ mode_t; +typedef __UINT32_TYPE__ nlink_t; +typedef __INT64_TYPE__ off_t; +typedef __INT64_TYPE__ pid_t; +typedef __UINT32_TYPE__ reclen_t; +typedef __SIZE_TYPE__ size_t; +typedef __INT64_TYPE__ ssize_t; +typedef __INT64_TYPE__ suseconds_t; +typedef __INT64_TYPE__ time_t; +typedef void *timer_t; +typedef __UINT32_TYPE__ uid_t; + +// TODO: +// pthread_attr_t +// pthread_barrier_t +// pthread_barrierattr_t +// pthread_cond_t +// pthread_condattr_t +// pthread_key_t +// pthread_mutex_t +// pthread_mutexattr_t +// pthread_once_t +// pthread_rwlock_t +// pthread_rwlockattr_t +// pthread_spinlock_t +// pthread_t + +#endif diff --git a/include/sys/uio.h b/include/sys/uio.h new file mode 100644 index 00000000..f14e2328 --- /dev/null +++ b/include/sys/uio.h @@ -0,0 +1,15 @@ +#ifndef __SYS_UIO_H +#define __SYS_UIO_H + +typedef __SIZE_TYPE__ size_t; +typedef __INT64_TYPE__ ssize_t; + +struct iovec { + void *iov_base; + size_t iov_len; +}; + +ssize_t readv(int, const struct iovec *, int); +ssize_t writev(int, const struct iovec *, int); + +#endif diff --git a/include/sys/un.h b/include/sys/un.h new file mode 100644 index 00000000..84e5f523 --- /dev/null +++ b/include/sys/un.h @@ -0,0 +1,11 @@ +#ifndef __SYS_UN_H +#define __SYS_UN_H + +typedef __UINT16_TYPE__ sa_family_t; + +struct sockaddr_un { + sa_family_t sun_family; + char sun_path[108]; +}; + +#endif diff --git a/include/sys/utsname.h b/include/sys/utsname.h new file mode 100644 index 00000000..1539a7b9 --- /dev/null +++ b/include/sys/utsname.h @@ -0,0 +1,14 @@ +#ifndef __SYS_UTSNAME_H +#define __SYS_UTSNAME_H + +struct utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; +}; + +int uname(struct utsname *); + +#endif diff --git a/include/sys/wait.h b/include/sys/wait.h new file mode 100644 index 00000000..bbe8a8fe --- /dev/null +++ b/include/sys/wait.h @@ -0,0 +1,45 @@ +#ifndef __WAIT_H +#define __WAIT_H + +#define WCONTINUED 0x00000008 +#define WNOHANG 0x00000001 +#define WUNTRACED 0x00000002 +#define WCOREDUMP(__s) ((__s) & 0x80) +#define WIFCONTINUED(__s) ((__s) == 0xffff) +#define WIFEXITED(__s) (!WTERMSIG(__s)) +#define WIFSIGNALED(__s) (((s) & 0xffff) - 1U < 0xffu) +#define WIFSTOPPED(__s) ((short)((((__s) & 0xffff) * 0x10001U) >> 8) > 0x7f00) +#define WSTOPSIG(__s) WEXITSTATUS(__s) +#define WTERMSIG(__s) ((__s) & 0x7f) + +#define WEXITED +#define WNOWAIT +#define WSTOPPED + +typedef __UINT32_TYPE__ id_t; +typedef __INT64_TYPE__ pid_t; +typedef __UINT32_TYPE__ uid_t; + +union sigval { + int sival_int; + void *sival_ptr; +}; + +typedef struct { + int si_signo; + int si_code; + int si_errno; + pid_t si_pid; + uid_t si_uid; + void *si_addr; + int si_status; + union sigval si_value; +} siginfo_t; + +typedef enum { P_ALL = 0, P_PID = 1, P_PGID = 2 } idtype_t; + +pid_t wait(int *); +int waitid(idtype_t, id_t, siginfo_t *, int); +pid_t waitpid(pid_t, int *, int); + +#endif |
