diff options
author | Mattias Andrée <maandree@kth.se> | 2023-12-03 19:23:35 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-12-03 19:23:35 +0100 |
commit | c131f122778c62f920a99bbf854ced4a37ee8b03 (patch) | |
tree | 14c933f98f4d64dffb0a594bc40dd5121c6c5a8e /libsyscalls_get_syscall_errors.c | |
download | libsyscalls-c131f122778c62f920a99bbf854ced4a37ee8b03.tar.gz libsyscalls-c131f122778c62f920a99bbf854ced4a37ee8b03.tar.bz2 libsyscalls-c131f122778c62f920a99bbf854ced4a37ee8b03.tar.xz |
First commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libsyscalls_get_syscall_errors.c')
-rw-r--r-- | libsyscalls_get_syscall_errors.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libsyscalls_get_syscall_errors.c b/libsyscalls_get_syscall_errors.c new file mode 100644 index 0000000..14b1e05 --- /dev/null +++ b/libsyscalls_get_syscall_errors.c @@ -0,0 +1,32 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +#include "generated/errors.c" + +enum libsyscalls_error +libsyscalls_get_syscall_errors(enum libsyscalls_os os, enum libsyscalls_arch arch, + const struct libsyscalls_named_number **errors_out, size_t *num_errors_out) +{ + const struct libsyscalls_named_number *discard_errors; + size_t discard_num_errors; + + if (!errors_out) errors_out = &discard_errors; + if (!num_errors_out) num_errors_out = &discard_num_errors; + +#define CASE(UPPERCASE, LOWERCASE)\ + case LIBSYSCALLS_OS_##UPPERCASE:\ + return get_##LOWERCASE##_syscall_errors(arch, errors_out, num_errors_out) + + switch ((int)os) { + LIST_OSES(CASE, ;); + + /* if OS is known but does not have named error numbers, + * get_##LOWERCASE##_syscall_errors shall return LIBSYSCALLS_E_NOERRORS; */ + + default: + return LIBSYSCALLS_E_OSNOSUP; + } + +#undef CASE +} |