Nucleus
Barry System headers (remove libc dependency) 18495cf (3 years, 2 months ago)
diff --git a/include/nucleus/cpu.h b/include/nucleus/cpu.h
index 2a8c52b..cb41a28 100644
--- a/include/nucleus/cpu.h
+++ b/include/nucleus/cpu.h
@@ -1,8 +1,8 @@
#ifndef _NUCLEUS_CPU_H
#define _NUCLEUS_CPU_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#include <nucleus/types.h>
typedef unsigned int cpu_t;
@@ -41,7 +41,7 @@ extern Processor *cpus[];
extern size_t ncpus;
extern int apic;
#define for_each_cpu(c) for (cpu_t __i_ ## c = 0; ((c) = cpus[__i_ ## c]) && \
- __i_ ## c < ncpus; __i_ ## c++)
+ ((__i_ ## c) < ncpus); (__i_ ## c)++)
extern uintptr_t lapicPtr, ioapicPtr;
#define LAPIC(off) (*((uint32_t *) ((uint32_t) lapicPtr + (off))))
diff --git a/include/io.h b/include/nucleus/io.h
similarity index 100%
rename from include/io.h
rename to include/nucleus/io.h
index e0204fd..1868e77 100644
--- a/include/io.h
+++ b/include/nucleus/io.h
@@ -1,8 +1,8 @@
#ifndef _IO_H
#define _IO_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
/* Read byte from port */
static inline uint8_t
diff --git a/include/nucleus/kernel.h b/include/nucleus/kernel.h
index 50bba3d..2b1bc75 100644
--- a/include/nucleus/kernel.h
+++ b/include/nucleus/kernel.h
@@ -2,9 +2,8 @@
#define _NUCLEUS_KERNEL_H
#include <stdarg.h>
+#include <nucleus/lib.h>
-int vsprintf(char *buf, const char *fmt, va_list args);
-int sprintf(char *buf, const char *fmt, ...);
void dbgprintf(char *str);
void kprintf(char *fmt, ...);
_Noreturn void panic(char *fmt, ...);
diff --git a/include/nucleus/lib.h b/include/nucleus/lib.h
new file mode 100644
index 0000000..a352728
--- /dev/null
+++ b/include/nucleus/lib.h
@@ -0,0 +1,21 @@
+#ifndef _NUCLEUS_LIB_H
+#define _NUCLEUS_LIB_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+int vsprintf(char *buf, const char *fmt, va_list args);
+int sprintf(char *buf, const char *fmt, ...);
+
+void *memset(void *dest, int byte, size_t len);
+int memcmp(void *s1, void *s2, size_t n);
+void *memcpy(void *dest, const void *src, size_t n);
+
+int strcmp(const char *s1, const char *s2);
+int strncmp(const char *s1, const char *s2, size_t n);
+char *strcpy(char *dest, const char *src);
+char *strncpy(char *dest, const char *src, size_t n);
+size_t strlen(const char *str);
+size_t strnlen(const char *str, size_t n);
+
+#endif
diff --git a/include/nucleus/memory.h b/include/nucleus/memory.h
index 595d152..c91e40c 100644
--- a/include/nucleus/memory.h
+++ b/include/nucleus/memory.h
@@ -1,8 +1,8 @@
#ifndef _NUCLEUS_MEMORY_H
#define _NUCLEUS_MEMORY_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#include <sys/mman.h>
#include <nucleus/object.h>
#include <nucleus/types.h>
diff --git a/include/nucleus/object.h b/include/nucleus/object.h
index 70e7bc1..558d00f 100644
--- a/include/nucleus/object.h
+++ b/include/nucleus/object.h
@@ -1,8 +1,8 @@
#ifndef _NUCLEUS_OBJECT_H
#define _NUCLEUS_OBJECT_H
-#include <sys/types.h>
#include <stddef.h>
+#include <sys/types.h>
#include <nucleus/cpu.h>
#include <nucleus/types.h>
diff --git a/include/nucleus/task.h b/include/nucleus/task.h
index 6212be0..f7825a8 100644
--- a/include/nucleus/task.h
+++ b/include/nucleus/task.h
@@ -4,8 +4,8 @@
#include <stdint.h>
#include <sys/types.h>
#include <nucleus/cpu.h>
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/types.h>
#include <nucleus/vfs.h>
@@ -100,6 +100,5 @@ void block_task(enum State reason, ObjectList *list);
void unblock_task(Task *task);
Task *find_task(pid_t tid);
void schedule(void);
-pid_t clone(int flags);
#endif
diff --git a/include/nucleus/vfs.h b/include/nucleus/vfs.h
index 6bdf673..019c006 100644
--- a/include/nucleus/vfs.h
+++ b/include/nucleus/vfs.h
@@ -2,16 +2,13 @@
#define _NUCLEUS_VFS_H
#include <stddef.h>
+#include <sys/dirent.h>
+#include <sys/limits.h>
#include <sys/types.h>
-#include <dirent.h>
-#include <nucleus/object.h>
#include <nucleus/memory.h>
+#include <nucleus/object.h>
#include <nucleus/types.h>
-#define NFILES 32
-#define NAME_MAX 255
-#define PATH_MAX 1024
-
typedef Inode *(*mount_callback_t)(FSType *, int, const char *, void *);
/* Structure for a Super Block */
@@ -93,8 +90,6 @@ extern ObjectType fileType;
void init_vfs(void);
File *create_anonymous_file(void);
void register_fstype(const char *name, mount_callback_t mount);
-int mount(const char *src, const char *target, const char *type,
- unsigned long flags, void *data);
Inode *lookup(const char *path, ObjectList *newcustody);
/* Super Block functions */
diff --git a/include/sys/dirent.h b/include/sys/dirent.h
new file mode 100644
index 0000000..efb6cb6
--- /dev/null
+++ b/include/sys/dirent.h
@@ -0,0 +1,36 @@
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+enum DirType {
+ DT_UNKNOWN,
+ DT_REG,
+ DT_DIR,
+ DT_CHR,
+ DT_BLK,
+ DT_FIFO,
+ DT_SOCK,
+ DT_LNK,
+};
+
+/* Structure for a Directory Entry */
+typedef struct dirent {
+ ino_t d_ino;
+ enum DirType d_type;
+ size_t d_namelen;
+ char d_name[];
+} DirEnt;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+size_t getdents(int fd, void *buf, size_t count);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/errno.h b/include/sys/errno.h
new file mode 100644
index 0000000..ad17fc5
--- /dev/null
+++ b/include/sys/errno.h
@@ -0,0 +1,30 @@
+#ifndef _SYS_ERRNO_H
+#define _SYS_ERRNO_H
+
+enum {
+ ENONE,
+ EPERM,
+ ENOENT,
+ ESRCH,
+ EINVAL,
+ EBADF,
+ ENOEXEC,
+ EMFILE,
+ EFAULT,
+ EISDIR,
+ ENOTDIR,
+ EACCES,
+ ENODEV,
+ EEXIST,
+ ENXIO,
+ ENOTBLK,
+ ENOMEM,
+ ECHILD,
+ ENOTTY,
+ ELOOP,
+ ENAMETOOLONG,
+ EINTR,
+ ERANGE,
+};
+
+#endif
diff --git a/include/sys/exec.h b/include/sys/exec.h
new file mode 100644
index 0000000..c693096
--- /dev/null
+++ b/include/sys/exec.h
@@ -0,0 +1,14 @@
+#ifndef _SYS_EXEC_H
+#define _SYS_EXEC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int execve(const char *file, char *argv[], char *envp[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/fb.h b/include/sys/fb.h
new file mode 100644
index 0000000..f75a75f
--- /dev/null
+++ b/include/sys/fb.h
@@ -0,0 +1,26 @@
+#ifndef _SYS_FB_H
+#define _SYS_FB_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/* ioctl() calls */
+enum FrameBufferIoctls {
+ FBIOGET_VSCREENINFO,
+ FBIOPUT_VSCREENINFO,
+ FBIOGET_FSCREENINFO,
+};
+
+/* Structure for fixed framebuffer info */
+typedef struct FBFixInfo {
+ uintptr_t fbmem;
+ size_t fbmemLen;
+} FBFixInfo;
+
+/* Structure for variable framebuffer info */
+typedef struct FBVarInfo {
+ uint32_t xres, yres;
+ uint32_t bpp;
+} FBVarInfo;
+
+#endif
diff --git a/include/sys/file.h b/include/sys/file.h
new file mode 100644
index 0000000..0a1cdbb
--- /dev/null
+++ b/include/sys/file.h
@@ -0,0 +1,35 @@
+#ifndef _SYS_FILE_H
+#define _SYS_FILE_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#define O_ACCMODE 0003
+#define O_RDONLY 00
+#define O_WRONLY 01
+#define O_RDWR 02
+
+#define O_CREATE 0100
+#define O_TRUNC 0200
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int open(const char *name, int flags, ...); /* mode_t mode */
+int dup(int oldfd);
+int dup2(int oldfd, int newfd);
+int read(int fd, void *buf, size_t count);
+int write(int fd, void *buf, size_t count);
+off_t lseek(int fd, off_t offset, int whence);
+int close(int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/fs.h b/include/sys/fs.h
new file mode 100644
index 0000000..8cd1376
--- /dev/null
+++ b/include/sys/fs.h
@@ -0,0 +1,18 @@
+#ifndef _SYS_FS_H
+#define _SYS_FS_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int chdir(const char *path);
+int chroot(const char *path);
+char *getcwd(char *buf, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
new file mode 100644
index 0000000..9c95275
--- /dev/null
+++ b/include/sys/ioctl.h
@@ -0,0 +1,6 @@
+#ifndef _SYS_IOCTL_H
+#define _SYS_IOCTL_H
+
+int ioctl(int fd, unsigned long request, ...);
+
+#endif
diff --git a/include/sys/ipc.h b/include/sys/ipc.h
new file mode 100644
index 0000000..e81e077
--- /dev/null
+++ b/include/sys/ipc.h
@@ -0,0 +1,38 @@
+#ifndef _SYS_IPC_H
+#define _SYS_IPC_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+/* Processes */
+enum Process {
+ NO_PROCESS,
+ SYSTEM,
+
+ ANY = 0xFFFFFFFF
+};
+
+/* Message encodings */
+typedef union MessageContent MessageContent;
+union MessageContent {
+ /* Generics */
+ char raw[16];
+ void *ptr;
+ uint32_t num;
+} __attribute__((__transparent_union__));
+
+/* Structure for a message */
+typedef struct Message Message;
+struct Message {
+ pid_t from;
+ uint16_t type;
+ MessageContent msg;
+ Message *next;
+} __attribute__((packed));
+
+Message *nb_send_msg(pid_t to, uint16_t type, MessageContent *msg);
+Message *send_msg(pid_t to, uint16_t type, MessageContent *msg);
+pid_t nb_recv_msg(Message *buf, pid_t from);
+pid_t recv_msg(Message *buf, pid_t from);
+
+#endif
diff --git a/include/sys/kbd.h b/include/sys/kbd.h
new file mode 100644
index 0000000..75d2830
--- /dev/null
+++ b/include/sys/kbd.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_KBD_H
+#define _SYS_KBD_H
+
+/* Structure for the keyboard input */
+typedef struct KeyInput {
+ unsigned char key;
+} KeyInput;
+
+#endif
diff --git a/include/sys/limits.h b/include/sys/limits.h
new file mode 100644
index 0000000..b37ecab
--- /dev/null
+++ b/include/sys/limits.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_LIMITS_H
+#define _SYS_LIMITS_H
+
+#define NFILES 32
+
+#define NAME_MAX 255
+#define PATH_MAX 1024
+
+#endif
diff --git a/include/sys/mman.h b/include/sys/mman.h
new file mode 100644
index 0000000..a39a4cf
--- /dev/null
+++ b/include/sys/mman.h
@@ -0,0 +1,35 @@
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+/* Virtual Memory Region Protection */
+enum VMRegionProt {
+ PROT_NONE,
+ PROT_EXEC = (1 << 0),
+ PROT_WRITE = (1 << 1),
+ PROT_READ = (1 << 2),
+};
+
+/* Virtual Memory Region flags */
+enum VMRegionFlag {
+ MAP_SHARED = (1 << 0),
+ MAP_PRIVATE = (1 << 1),
+ MAP_ANONYMOUS = (1 << 2),
+};
+
+#define MAP_ANON MAP_ANONYMOUS
+#define MAP_FAILED ((void *) -1)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/mount.h b/include/sys/mount.h
new file mode 100644
index 0000000..c5508ae
--- /dev/null
+++ b/include/sys/mount.h
@@ -0,0 +1,20 @@
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+
+#define MS_REMOUNT (1 << 0)
+#define MS_BIND (1 << 1)
+#define MS_MOVE (1 << 2)
+#define MS_RDONLY (1 << 3)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mount(const char *src, const char *target, const char *type,
+ unsigned long flags, void *data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/mouse.h b/include/sys/mouse.h
new file mode 100644
index 0000000..698d405
--- /dev/null
+++ b/include/sys/mouse.h
@@ -0,0 +1,5 @@
+#ifndef _SYS_MOUSE_H
+#define _SYS_MOUSE_H
+
+
+#endif
diff --git a/include/sys/param.h b/include/sys/param.h
new file mode 100644
index 0000000..11ca58a
--- /dev/null
+++ b/include/sys/param.h
@@ -0,0 +1,32 @@
+#ifndef _SYS_PARAM_H
+#define _SYS_PARAM_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#define NBBY 8
+
+/* Bit map related macros. */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/* Macros for counting and rounding. */
+#ifndef howmany
+# define howmany(x, y) (((x) + ((y) - 1)) / (y))
+#endif
+#ifdef __GNUC__
+# define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \
+ ? (((x) + (y) - 1) & ~((y) - 1)) \
+ : ((((x) + ((y) - 1)) / (y)) * (y)))
+#else
+# define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+#endif
+#define powerof2(x) ((((x) - 1) & (x)) == 0)
+
+/* Macros for min/max. */
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+#endif
diff --git a/include/sys/sched.h b/include/sys/sched.h
new file mode 100644
index 0000000..6cf7f94
--- /dev/null
+++ b/include/sys/sched.h
@@ -0,0 +1,31 @@
+#ifndef _SYS_SCHED_H
+#define _SYS_SCHED_H
+
+#include <sys/types.h>
+
+/* Flags for clone syscall */
+enum CloneFlag {
+ CLONE_NONE = (0),
+ CLONE_PARENT = (1 << 0),
+ CLONE_THREAD = (1 << 1),
+ CLONE_FILES = (1 << 2),
+ CLONE_FS = (1 << 3),
+ CLONE_VM = (1 << 4),
+ CLONE_SIGHAND = (1 << 5),
+ CLONE_IPC = (1 << 6), // TODO: Add IPC namespace
+};
+
+pid_t getpid(void);
+pid_t clone(int flags);
+_Noreturn void exit(int status);
+
+uid_t getuid(void);
+int setuid(uid_t uid);
+uid_t geteuid(void);
+int seteuid(uid_t euid);
+gid_t getgid(void);
+int setgid(gid_t gid);
+gid_t getegid(void);
+int setegid(gid_t egid);
+
+#endif
diff --git a/include/sys/signal.h b/include/sys/signal.h
new file mode 100644
index 0000000..f80c669
--- /dev/null
+++ b/include/sys/signal.h
@@ -0,0 +1,48 @@
+#ifndef _SYS_SIGNAL_H
+#define _SYS_SIGNAL_H
+
+#include <sys/types.h>
+
+typedef unsigned long int __sigset_t;
+#ifndef sigset_t
+typedef __sigset_t sigset_t;
+#endif
+#ifndef sig_atomic_t
+typedef int sig_atomic_t;
+#endif
+
+typedef void (*sighandler_t)(int);
+
+#define SIG_ERR (sighandler_t) -1
+#define SIG_IGNORE 0
+#define SIG_DFL 1
+#define SIG_BLOCK 2
+#define SIG_UNBLOCK 3
+#define SIG_SETMASK 4
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum Signal {
+ SIGHUP = 1,
+ SIGINT,
+ SIGQUIT,
+ SIGILL,
+ SIGABRT,
+ SIGFPE,
+ SIGKILL,
+ SIGSEGV,
+ SIGPIPE,
+};
+
+int tgkill(pid_t tgid, pid_t tid, int sig);
+int kill(pid_t pid, int sig);
+sighandler_t signal(int signum, sighandler_t handler);
+int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/stat.h b/include/sys/stat.h
new file mode 100644
index 0000000..4be596e
--- /dev/null
+++ b/include/sys/stat.h
@@ -0,0 +1,68 @@
+#ifndef _SYS_STAT_H
+#define _SYS_STAT_H
+
+#include <stddef.h>
+#include <sys/types.h>
+
+#define S_IFMT 0170000
+
+#define S_IFSOCK 0140000
+#define S_IFLNK 0120000
+#define S_IFREG 0100000
+#define S_IFBLK 0060000
+#define S_IFDIR 0040000
+#define S_IFCHR 0020000
+#define S_IFIFO 0010000
+
+#define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
+#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
+#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
+#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
+#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
+#define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
+
+#define S_ISUID 04000
+#define S_ISGID 02000
+#define S_ISVTX 01000
+
+#define S_IRWXU 00700
+#define S_IRUSR 00400
+#define S_IWUSR 00200
+#define S_IXUSR 00100
+
+#define S_IRWXG 00070
+#define S_IRGRP 00040
+#define S_IWGRP 00020
+#define S_IXGRP 00010
+
+#define S_IRWXO 00007
+#define S_IROTH 00004
+#define S_IWOTH 00002
+#define S_IXOTH 00001
+
+/* Structure for a stat() call */
+typedef struct stat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ size_t st_size;
+} Stat;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mkdir(const char *pathname, mode_t mode);
+int mknod(const char *pathname, mode_t mode, dev_t dev);
+int stat(const char *pathname, struct stat *statbuf);
+int fstat(int fd, struct stat *statbuf);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/syscall.h b/include/sys/syscall.h
new file mode 100644
index 0000000..dd5cf96
--- /dev/null
+++ b/include/sys/syscall.h
@@ -0,0 +1,62 @@
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+enum SystemCall {
+ /* Task */
+ SYSCALL_DBGPRINTF,
+ SYSCALL_UNAME,
+ SYSCALL_CLONE,
+ SYSCALL_EXIT,
+ SYSCALL_GETPID,
+ SYSCALL_GETUID,
+ SYSCALL_SETUID,
+ SYSCALL_GETEUID,
+ SYSCALL_SETEUID,
+ SYSCALL_GETGID,
+ SYSCALL_SETGID,
+ SYSCALL_GETEGID,
+ SYSCALL_SETEGID,
+ SYSCALL_EXECVE,
+ SYSCALL_WAITPID,
+ SYSCALL_TIME,
+ SYSCALL_TIMES,
+ SYSCALL_SLEEP,
+
+ /* Files */
+ SYSCALL_OPEN,
+ SYSCALL_CLOSE,
+ SYSCALL_READ,
+ SYSCALL_WRITE,
+ SYSCALL_IOCTL,
+ SYSCALL_LSEEK,
+ SYSCALL_STAT,
+ SYSCALL_FSTAT,
+ SYSCALL_GETDENTS,
+ SYSCALL_MKDIR,
+ SYSCALL_RMDIR,
+ SYSCALL_MKNOD,
+ SYSCALL_RENAME,
+ SYSCALL_DUP,
+ SYSCALL_DUP2,
+ SYSCALL_ISATTY,
+ SYSCALL_PIPE,
+
+ /* File System */
+ SYSCALL_MOUNT,
+ SYSCALL_CHDIR,
+ SYSCALL_CHROOT,
+ SYSCALL_GETCWD,
+
+ /* Memory */
+ SYSCALL_MMAP,
+
+ /* Signals */
+ SYSCALL_TGKILL,
+ SYSCALL_KILL,
+ SYSCALL_SIGNAL,
+ SYSCALL_SIGPROCMASK,
+};
+
+int syscall(int number, ...);
+
+#endif
diff --git a/include/sys/time.h b/include/sys/time.h
new file mode 100644
index 0000000..e528978
--- /dev/null
+++ b/include/sys/time.h
@@ -0,0 +1,11 @@
+#ifndef _SYS_TIME_H
+#define _SYS_TIME_H
+
+#include <sys/types.h>
+
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+
+#endif
diff --git a/include/sys/times.h b/include/sys/times.h
new file mode 100644
index 0000000..8e838fb
--- /dev/null
+++ b/include/sys/times.h
@@ -0,0 +1,18 @@
+#ifndef _SYS_TIMES_H
+#define _SYS_TIMES_H
+
+#include <stdint.h>
+
+typedef uint64_t clock_t;
+
+/* Structure for a times call */
+typedef struct tms {
+ clock_t utime;
+ clock_t stime;
+ clock_t cutime;
+ clock_t cstime;
+} Times;
+
+clock_t times(Times *buf);
+
+#endif
diff --git a/include/sys/types.h b/include/sys/types.h
new file mode 100644
index 0000000..3eb3412
--- /dev/null
+++ b/include/sys/types.h
@@ -0,0 +1,16 @@
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+
+typedef int pid_t;
+typedef unsigned short uid_t;
+typedef unsigned short gid_t;
+typedef unsigned int dev_t;
+typedef int ino_t;
+typedef int off_t;
+typedef int mode_t;
+typedef int nlink_t;
+typedef _Atomic int refcount_t;
+typedef unsigned int time_t;
+typedef unsigned int suseconds_t;
+
+#endif
diff --git a/include/sys/utsname.h b/include/sys/utsname.h
new file mode 100644
index 0000000..a26346c
--- /dev/null
+++ b/include/sys/utsname.h
@@ -0,0 +1,15 @@
+#ifndef _SYS_UTSNAME_H
+#define _SYS_UTSNAME_H
+
+#define UTSNAME_LENGTH 256
+
+struct utsname {
+ char sysname[UTSNAME_LENGTH];
+ char release[UTSNAME_LENGTH];
+ char version[UTSNAME_LENGTH];
+ char machine[UTSNAME_LENGTH];
+};
+
+int uname(struct utsname *buf);
+
+#endif
diff --git a/include/sys/wait.h b/include/sys/wait.h
new file mode 100644
index 0000000..47ff26c
--- /dev/null
+++ b/include/sys/wait.h
@@ -0,0 +1,22 @@
+#ifndef _SYS_INCLUDE_H
+#define _SYS_INCLUDE_H
+
+#include <sys/types.h>
+
+#define WIFEXITED(status) (status & (1 << 31))
+#define WEXITSTATUS(status) (status & 0x0F)
+#define WIFSIGNALED(status) (!(status & (1 << 31)))
+#define WTERMSIG(status) (status & 0xFF)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+pid_t wait(int *wstatus);
+pid_t waitpid(pid_t pid, int *wstatus, int options);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif