BarryServer : Git

All the code for all my projects
// BarryServer : Git / OrionLibC / commit / 03048a95d88cc7a78171393371f5c22a0250a014 / include

// Related

OrionLibC

Barry Importing existing Orion LibC 03048a9 (2 years, 2 months ago)
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
new file mode 100644
index 0000000..4de8dc6
--- /dev/null
+++ b/include/arpa/inet.h
@@ -0,0 +1,15 @@
+#ifndef _ARPA_INET_H
+#define _ARPA_INET_H
+
+typedef struct InAddr {
+	uint32_t addr;
+} InAddr;
+
+typedef struct SockAddrIn {
+	int16_t family;
+	uint16_t port;
+	InAddr inAddr;
+	char zero[8];
+} SockAddrIn;
+
+#endif
diff --git a/include/ctype.h b/include/ctype.h
new file mode 100644
index 0000000..262a90d
--- /dev/null
+++ b/include/ctype.h
@@ -0,0 +1,6 @@
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+
+
+#endif
diff --git a/include/dirent.h b/include/dirent.h
new file mode 100644
index 0000000..abdad04
--- /dev/null
+++ b/include/dirent.h
@@ -0,0 +1,36 @@
+#ifndef _DIRENT_H
+#define _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 ino;
+	enum DirType type;
+	size_t namelen;
+	char 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/errno.h b/include/errno.h
new file mode 100644
index 0000000..b47e18c
--- /dev/null
+++ b/include/errno.h
@@ -0,0 +1,28 @@
+#ifndef _ERRNO_H
+#define _ERRNO_H
+
+enum {
+	ENONE,
+	EPERM,
+	ENOENT,
+	ESRCH,
+	EINVAL,
+	EBADF,
+	ENOEXEC,
+	EMFILE,
+	EFAULT,
+	EISDIR,
+	ENOTDIR,
+	EACCES,
+	ENODEV,
+	EEXIST,
+	ENXIO,
+	ENOTBLK,
+	ENOMEM,
+	ECHILD,
+	ENOTTY,
+};
+
+extern int errno;
+
+#endif
diff --git a/include/fcntl.h b/include/fcntl.h
new file mode 100644
index 0000000..5274e33
--- /dev/null
+++ b/include/fcntl.h
@@ -0,0 +1,25 @@
+#ifndef _FCNTL_H
+#define _FCNTL_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
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int open(const char *name, int flags, ...); /* mode_t mode */
+int create(const char *name, mode_t mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/grp.h b/include/grp.h
new file mode 100644
index 0000000..a6e07d6
--- /dev/null
+++ b/include/grp.h
@@ -0,0 +1,14 @@
+#ifndef _GRP_H
+#define _GRP_H
+
+/* Structure of a group entry */
+typedef struct group {
+	char *name;
+	gid_t gid;
+	char **members;
+} Group;
+
+Group *getgrname(const char *name);
+Group *getgrgid(gid_t gid);
+
+#endif
diff --git a/include/inttypes.h b/include/inttypes.h
new file mode 100644
index 0000000..855bf37
--- /dev/null
+++ b/include/inttypes.h
@@ -0,0 +1,13 @@
+#ifndef _INTTYPES_H
+#define _INTTYPES_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* Structure for the imaxdiv() function */
+typedef struct {
+	__extension__ long long int quot;
+	__extension__ long long int rem;
+} imaxdiv_t;
+
+#endif
diff --git a/include/limits.h b/include/limits.h
new file mode 100644
index 0000000..d165525
--- /dev/null
+++ b/include/limits.h
@@ -0,0 +1,6 @@
+#ifndef _LIMITS_H
+#define _LIMITS_H
+
+#include <sys/limits.h>
+
+#endif
diff --git a/include/pwd.h b/include/pwd.h
new file mode 100644
index 0000000..df872d4
--- /dev/null
+++ b/include/pwd.h
@@ -0,0 +1,20 @@
+#ifndef _PWD_H
+#define _PWD_H
+
+#include <sys/types.h>
+
+/* Structure of a password entry */
+typedef struct passwd {
+	char *username;
+	char *password;
+	uid_t uid;
+	gid_t gid;
+	char *info;
+	char *homedir;
+	char *shell;
+} Passwd;
+
+Passwd *getpwname(const char *username);
+Passwd *getpwuid(uid_t uid);
+
+#endif
diff --git a/include/setjmp.h b/include/setjmp.h
new file mode 100644
index 0000000..ded0ecd
--- /dev/null
+++ b/include/setjmp.h
@@ -0,0 +1,19 @@
+#ifndef _SETJMP_H
+#define _SETJMP_H
+
+#include <signal.h>
+
+#define setjmp __builtin_setjmp
+#define longjmp __builtin_longjmp
+
+typedef int __jmp_buf[6];
+
+struct __jmp_buf_tag {
+	__jmp_buf __jmpbuf;
+	int __saved;
+	__sigset_t __mask;
+};
+
+typedef struct __jmp_buf_tag jmp_buf[1];
+
+#endif
diff --git a/include/signal.h b/include/signal.h
new file mode 100644
index 0000000..3999125
--- /dev/null
+++ b/include/signal.h
@@ -0,0 +1,39 @@
+#ifndef _SIGNAL_H
+#define _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
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum Signals {
+	SIGHUP = 1,
+	SIGINT,
+	SIGQUIT,
+	SIGILL,
+	SIGABRT,
+	SIGFPE,
+	SIGKILL,
+	SIGSEGV,
+	SIGPIPE,
+	
+};
+
+void (*signal(int sig, void (*func)(int)))(int);
+int tgkill(pid_t tgid, pid_t tid, int sig);
+int kill(pid_t pid, int sig);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/stdio.h b/include/stdio.h
new file mode 100644
index 0000000..b38bba5
--- /dev/null
+++ b/include/stdio.h
@@ -0,0 +1,66 @@
+#ifndef _STDIO_H
+#define _STDIO_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+#define EOF ((int) -1)
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+typedef struct {
+	size_t count;
+	char *buf, *ptr;
+	int flags;
+	int fd;
+} FILE;
+
+enum FILEFlags {
+	FILE_READ  =  1,
+	FILE_WRITE =  2,
+	FILE_UNBUF =  4,
+	FILE_EOF   = 10,
+	FILE_ERR   = 20,
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+#define stdin stdin
+#define stdout stdout
+#define stderr stderr
+
+int fclose(FILE *);
+int fflush(FILE *);
+FILE *fopen(const char *, const char *);
+int fprintf(FILE *, const char *, ...);
+size_t fread(void *, size_t, size_t, FILE *);
+int fseek(FILE *, long, int);
+long ftell(FILE *);
+size_t fwrite(const void *, size_t, size_t, FILE *);
+void setbuf(FILE *stream, char *buf);
+int vfprintf(FILE *stream, const char *fmt, va_list);
+int sprintf(char *buf, const char *fmt, ...);
+void dbgprintf(char *fmt, ...);
+void dbgputs(char *str);
+int printf(const char *fmt, ...);
+void perror(const char *s);
+int getc(FILE *stream);
+int getchar(void);
+int puts(const char *s);
+int putc(int c, FILE *stream);
+int putchar(int c);
+
+int rename(const char *oldpath, const char *newpath);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..b1265c2
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,25 @@
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_Noreturn void abort(void);
+int atexit(void (*)(void));
+int atoi(const char *);
+void free(void *);
+char *getenv(const char *);
+void *malloc(size_t);
+void *calloc(size_t, size_t);
+_Noreturn void exit(int status);
+int abs(int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/string.h b/include/string.h
new file mode 100644
index 0000000..470b759
--- /dev/null
+++ b/include/string.h
@@ -0,0 +1,26 @@
+#ifndef _STRING_H
+#define _STRING_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int memcmp(void *s1, void *s2, size_t n);
+void *memcpy(void *dest, const void *src, size_t len);
+void *memset(void *dest, int byte, size_t len);
+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 maxlen);
+char *strcat(char *dest, const char *src);
+char *strchr(char *s, int c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/sys/fb.h b/include/sys/fb.h
new file mode 100644
index 0000000..b56497e
--- /dev/null
+++ b/include/sys/fb.h
@@ -0,0 +1,26 @@
+#ifndef _SYS_FB_H
+#define _SYS_FB_H
+
+#include <stdint.h>
+#include <stddef.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/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/limits.h b/include/sys/limits.h
new file mode 100644
index 0000000..835e765
--- /dev/null
+++ b/include/sys/limits.h
@@ -0,0 +1,9 @@
+#ifndef _SYS_LIMITS_H
+#define _SYS_LIMITS_H
+
+#define NAME_MAX 255
+#define PATH_MAX 1024
+
+#define HOST_NAME_MAX 64
+
+#endif
diff --git a/include/sys/mman.h b/include/sys/mman.h
new file mode 100644
index 0000000..0e9518e
--- /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,
+	MAP_PRIVATE = (1 << 0),
+	MAP_ANONYMOUS = (1 << 1),
+};
+
+#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/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..fe17753
--- /dev/null
+++ b/include/sys/sched.h
@@ -0,0 +1,19 @@
+#ifndef _SYS_SCHED_H
+#define _SYS_SCHED_H
+
+#include <sys/types.h>
+
+/* Flags for clone syscall */
+enum CloneFlag {
+	CLONE_NONE   = (1 << 0),
+	CLONE_PARENT = (1 << 1),
+	CLONE_THREAD = (1 << 2),
+	CLONE_FILES  = (1 << 3),
+	CLONE_FS     = (1 << 4),
+	CLONE_VM     = (1 << 5),
+	CLONE_IPC    = (1 << 6), // TODO: Add IPC namespace
+};
+
+pid_t clone(int flags);
+
+#endif
diff --git a/include/sys/stat.h b/include/sys/stat.h
new file mode 100644
index 0000000..b83cf2d
--- /dev/null
+++ b/include/sys/stat.h
@@ -0,0 +1,67 @@
+#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 {
+	ino_t inode;
+	mode_t mode;
+	nlink_t nlink;
+	uid_t uid;
+	gid_t gid;
+	size_t 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..d732c59
--- /dev/null
+++ b/include/sys/syscall.h
@@ -0,0 +1,60 @@
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+enum SystemCall {
+	/* Tasking */
+	SYSCALL_DBGPRINTF,
+	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_TGKILL,
+	SYSCALL_KILL,
+	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,
+
+	/* File System */
+	SYSCALL_MOUNT,
+	SYSCALL_CHDIR,
+	SYSCALL_CHROOT,
+	SYSCALL_GETCWD,
+
+	/* Memory */
+	SYSCALL_MMAP,
+
+	/* Messaging */
+	SYSCALL_NB_SEND_MSG,
+	SYSCALL_SEND_MSG,
+	SYSCALL_NB_RECV_MSG,
+	SYSCALL_RECV_MSG,
+};
+
+#endif
diff --git a/include/sys/times.h b/include/sys/times.h
new file mode 100644
index 0000000..70d57f0
--- /dev/null
+++ b/include/sys/times.h
@@ -0,0 +1,18 @@
+#ifndef _SYS_TIMES_H
+#define _SYS_TIMES_H
+
+#include <time.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..f8d727a
--- /dev/null
+++ b/include/sys/types.h
@@ -0,0 +1,14 @@
+#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 int refcount_t;
+
+#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
diff --git a/include/termios.h b/include/termios.h
new file mode 100644
index 0000000..259695b
--- /dev/null
+++ b/include/termios.h
@@ -0,0 +1,33 @@
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
+
+/* ioctl() calls */
+enum TTYIoctls {
+	TCGETS,
+	TCSETS,
+	TCGWINSZ,
+};
+
+enum TTYLineDiscipline {
+	ISIG = (1 << 0),
+	ICANON = (1 << 1),
+	ECHO = (1 << 2),
+};
+
+typedef unsigned int tcflag_t;
+
+/* Terminal I/O Settings */
+typedef struct Termios {
+	tcflag_t iflag;
+	tcflag_t oflag;
+	tcflag_t cflag;
+	tcflag_t lflag;
+} Termios;
+
+/* Terminal Window Size */
+typedef struct Winsize {
+	unsigned short rows, cols;
+	unsigned short xres, yres;
+} Winsize;
+
+#endif
diff --git a/include/time.h b/include/time.h
new file mode 100644
index 0000000..24dee55
--- /dev/null
+++ b/include/time.h
@@ -0,0 +1,11 @@
+#ifndef _TIME_H
+#define _TIME_H
+
+#include <stdint.h>
+
+typedef uint32_t time_t;
+
+int sleep(uint32_t ms);
+time_t time(time_t *tloc);
+
+#endif
diff --git a/include/unistd.h b/include/unistd.h
new file mode 100644
index 0000000..c250e84
--- /dev/null
+++ b/include/unistd.h
@@ -0,0 +1,46 @@
+#ifndef _UNISTD_H
+#define _UNISTD_H
+
+#include <sys/types.h>
+#include <stddef.h>
+
+typedef int intptr_t;
+
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int execv(const char *, char *[]);
+int execve(const char *, char *[], char *[]);
+int execvp(const char *, char *[]);
+pid_t fork(void);
+pid_t getpid(void);
+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);
+int isatty(int fd);
+int close(int fd);
+int dup(int oldfd);
+int dup2(int oldfd, int newfd);
+size_t read(int fd, void *buf, size_t count);
+size_t write(int fd, void *buf, size_t count);
+off_t lseek(int fd, off_t offset, int whence);
+int rmdir(const char *pathname);
+int chroot(const char *path);
+int chdir(const char *path);
+char *getcwd(char *buf, size_t size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif