hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/sysroot/usr/include
diff options
context:
space:
mode:
Diffstat (limited to 'sysroot/usr/include')
-rw-r--r--sysroot/usr/include/fcntl.h12
-rw-r--r--sysroot/usr/include/stddef.h9
-rw-r--r--sysroot/usr/include/stdint.h10
-rw-r--r--sysroot/usr/include/stdio.h15
-rw-r--r--sysroot/usr/include/stdlib.h17
-rw-r--r--sysroot/usr/include/string.h17
-rw-r--r--sysroot/usr/include/sys/syscall.h34
-rw-r--r--sysroot/usr/include/unistd.h18
8 files changed, 132 insertions, 0 deletions
diff --git a/sysroot/usr/include/fcntl.h b/sysroot/usr/include/fcntl.h
new file mode 100644
index 0000000..4c9dc07
--- /dev/null
+++ b/sysroot/usr/include/fcntl.h
@@ -0,0 +1,12 @@
+#ifndef _FCNTL_H
+#define _FCNTL_H
+
+#define O_RDONLY 0
+#define O_WRONLY 1
+#define O_CREAT 0x40
+#define O_TRUNC 0x200
+#define O_APPEND 0x400
+
+int open(const char* path, int flags);
+
+#endif
diff --git a/sysroot/usr/include/stddef.h b/sysroot/usr/include/stddef.h
new file mode 100644
index 0000000..0fe5f56
--- /dev/null
+++ b/sysroot/usr/include/stddef.h
@@ -0,0 +1,9 @@
+#ifndef _STDDEF_H
+#define _STDDEF_H
+
+typedef unsigned long size_t;
+typedef long ptrdiff_t;
+
+#define NULL ((void*)0)
+
+#endif
diff --git a/sysroot/usr/include/stdint.h b/sysroot/usr/include/stdint.h
new file mode 100644
index 0000000..d3da3d2
--- /dev/null
+++ b/sysroot/usr/include/stdint.h
@@ -0,0 +1,10 @@
+#ifndef _STDINT_H
+#define _STDINT_H
+
+typedef unsigned char uint8_t; typedef signed char int8_t;
+typedef unsigned short uint16_t; typedef short int16_t;
+typedef unsigned int uint32_t; typedef int int32_t;
+typedef unsigned long uint64_t; typedef long int64_t;
+typedef unsigned long uintptr_t; typedef long intptr_t;
+
+#endif
diff --git a/sysroot/usr/include/stdio.h b/sysroot/usr/include/stdio.h
new file mode 100644
index 0000000..9f6929e
--- /dev/null
+++ b/sysroot/usr/include/stdio.h
@@ -0,0 +1,15 @@
+#ifndef _STDIO_H
+#define _STDIO_H
+
+#define EOF (-1)
+
+int putchar(int character);
+int getchar(void);
+int puts(const char* string);
+int printf(const char* format, ...);
+
+// revel only, not part of stdc
+// read a line from stdin -> returns length
+int readline(char* buffer, int max_length);
+
+#endif
diff --git a/sysroot/usr/include/stdlib.h b/sysroot/usr/include/stdlib.h
new file mode 100644
index 0000000..7950258
--- /dev/null
+++ b/sysroot/usr/include/stdlib.h
@@ -0,0 +1,17 @@
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#include <stddef.h>
+
+void* malloc(size_t length);
+void free(void* pointer);
+void* calloc(size_t count, size_t size);
+void* realloc(void* pointer, size_t length);
+
+void exit(int code) __attribute__((noreturn));
+
+int atoi(const char* string);
+long atol(const char* string);
+int abs(int value);
+
+#endif
diff --git a/sysroot/usr/include/string.h b/sysroot/usr/include/string.h
new file mode 100644
index 0000000..2177ad6
--- /dev/null
+++ b/sysroot/usr/include/string.h
@@ -0,0 +1,17 @@
+#ifndef _STRING_H
+#define _STRING_H
+
+#include <stddef.h>
+
+size_t strlen(const char* string);
+int strcmp(const char* a, const char* b);
+int strncmp(const char* a, const char* b, size_t length);
+char* strcpy(char* destination, const char* source);
+char* strncpy(char* destination, const char* source, size_t length);
+
+void* memcpy(void* destination, const void* source, size_t length);
+void* memmove(void* destination, const void* source, size_t length);
+void* memset(void* destination, int value, size_t length);
+int memcmp(const void* a, const void* b, size_t length);
+
+#endif
diff --git a/sysroot/usr/include/sys/syscall.h b/sysroot/usr/include/sys/syscall.h
new file mode 100644
index 0000000..4a23a53
--- /dev/null
+++ b/sysroot/usr/include/sys/syscall.h
@@ -0,0 +1,34 @@
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+#define SYS_exit 0
+#define SYS_write 1
+#define SYS_read 2
+#define SYS_open 7
+#define SYS_close 8
+#define SYS_lseek 9
+#define SYS_brk 10
+#define SYS_sbrk 11
+
+static inline long __syscall1(long number, long a1)
+{
+ long result;
+ __asm__ volatile("int $0x80" : "=a"(result) : "a"(number), "D"(a1) : "memory");
+ return result;
+}
+
+static inline long __syscall2(long number, long a1, long a2)
+{
+ long result;
+ __asm__ volatile("int $0x80" : "=a"(result) : "a"(number), "D"(a1), "S"(a2) : "memory");
+ return result;
+}
+
+static inline long __syscall3(long number, long a1, long a2, long a3)
+{
+ long result;
+ __asm__ volatile("int $0x80" : "=a"(result) : "a"(number), "D"(a1), "S"(a2), "d"(a3) : "memory");
+ return result;
+}
+
+#endif
diff --git a/sysroot/usr/include/unistd.h b/sysroot/usr/include/unistd.h
new file mode 100644
index 0000000..f5a67ab
--- /dev/null
+++ b/sysroot/usr/include/unistd.h
@@ -0,0 +1,18 @@
+#ifndef _UNISTD_H
+#define _UNISTD_H
+
+#include <stddef.h>
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+long read(int fd, void* buffer, size_t length);
+long write(int fd, const void* buffer, size_t length);
+int close(int fd);
+long lseek(int fd, long offset, int whence);
+
+void* sbrk(long increment);
+int brk(void* address);
+
+#endif