aboutsummaryrefslogtreecommitdiff
path: root/lib/include/syscalls.h
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-04-28 23:08:45 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-04-28 23:08:45 +0200
commitd367355eb4c3569d422034b69737d8dc7022e13e (patch)
treef9f6768228235f4712466d65edeb0b745d904833 /lib/include/syscalls.h
parentcf97ecd5b52c2f7a8953fd1674742d46fd15418a (diff)
parentfc137e7d0263a0fe908ca1a150e34a9c8b9902d4 (diff)
downloaddynld-d367355eb4c3569d422034b69737d8dc7022e13e.tar.gz
dynld-d367355eb4c3569d422034b69737d8dc7022e13e.zip
Merge branch 'dev04'
Diffstat (limited to 'lib/include/syscalls.h')
-rw-r--r--lib/include/syscalls.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/include/syscalls.h b/lib/include/syscalls.h
new file mode 100644
index 0000000..7808e98
--- /dev/null
+++ b/lib/include/syscalls.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2021 Johannes Stoelp
+
+#pragma once
+
+#include <stddef.h> // size_t
+#include <sys/types.h> // ssize_t, off_t, ...
+
+extern int dynld_errno;
+
+// Syscall definitions taken from corresponding man pages, eg
+// open(2)
+// read(2)
+// ...
+
+#define O_RDONLY 00
+int open(const char* path, int flags);
+int close(int fd);
+
+#define F_OK 0
+#define R_OK 4
+int access(const char* path, int mode);
+
+ssize_t write(int fd, const void* buf, size_t count);
+ssize_t read(int fd, void* buf, size_t count);
+ssize_t pread(int fd, void* buf, size_t count, off_t offset);
+
+// mmap - prot:
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+#define PROT_EXEC 0x4
+// mmap - flags:
+#define MAP_PRIVATE 0x2
+#define MAP_ANONYMOUS 0x20
+#define MAP_FIXED 0x10
+// mmap - ret:
+#define MAP_FAILED ((void*)-1)
+void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t offset);
+int munmap(void* addr, size_t length);
+
+void _exit(int status);