diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-01-26 22:41:05 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-01-26 22:41:05 -0500 |
| commit | 8c6d4505329f94446084ca93eae10cd796d79a8d (patch) | |
| tree | c00c6a990c81bd771ebcac72b38fd3ce2382c42e /nonstd/__linux.h | |
new framework for building sources after gitlab migration
Diffstat (limited to 'nonstd/__linux.h')
| -rw-r--r-- | nonstd/__linux.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/nonstd/__linux.h b/nonstd/__linux.h new file mode 100644 index 00000000..4684b17f --- /dev/null +++ b/nonstd/__linux.h @@ -0,0 +1,36 @@ +#include <stdarg.h> +#include <stddef.h> +#include <errno.h> +#include <string.h> + +#ifndef ENOSYS +#define ENOSYS 62 +#endif + +extern long __syscall_x86_64(long, ...); +#define __linux_syscall __syscall_x86_64 +#define __syscall __linux_syscall + +static long __syscall_lookup(const char *call) +{ + const char *__syscalls[] = { + [0] = "read", + [1] = "write", + [2] = "open", + [3] = "close", + [4] = "stat", + [5] = "fstat", + [6] = "lstat", + [9] = "mmap", + [60] = "exit", + [201] = "time", + }; + + size_t i; + for (i = 0; i < sizeof(__syscalls) / sizeof(__syscalls[0]); i++) { + if (__syscalls[i] && !strcmp(__syscalls[i], call)) { + return i; + } + } + return -1; +} |
