summaryrefslogtreecommitdiffstats
path: root/libsyscalls_get_syscall_errors.c
blob: 9ec7e05f3b4089256fdba8f2120b231d67eccdec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* 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, int *are_signed_out)
{
	const struct libsyscalls_named_number *discard_errors;
	size_t discard_num_errors;
	int discard_are_signed;

	if (!errors_out)     errors_out     = &discard_errors;
	if (!num_errors_out) num_errors_out = &discard_num_errors;
	if (!are_signed_out) are_signed_out = &discard_are_signed;

#define CASE(UPPERCASE, LOWERCASE)\
	case LIBSYSCALLS_OS_##UPPERCASE:\
		return get_##LOWERCASE##_syscall_errors(arch, errors_out, num_errors_out, are_signed_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	
}