summaryrefslogtreecommitdiffstats
path: root/linux/errors.c
blob: d8a0e7f7a9972a5b312bc96c82553b4c305424e0 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* See LICENSE file for copyright and license details. */

/* This file is included from ../libsyscalls_get_syscall_errors.c */


#include "../generated/linux-errors.h"

static enum libsyscalls_error
get_linux_syscall_errors(enum libsyscalls_arch arch, const struct libsyscalls_named_number **errs_out, size_t *nerrs_out)
{
#define CASE(ARCH)\
	*errs_out = linux_errors_for_##ARCH;\
	*nerrs_out = sizeof(linux_errors_for_##ARCH) / sizeof(*linux_errors_for_##ARCH);\
	goto out

	switch ((int)arch) {
	case LIBSYSCALLS_ARCH_ALPHA:
#ifdef LIST_LINUX_ERRORS_FOR_ALPHA
		CASE(alpha);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_AMD64:
	case LIBSYSCALLS_ARCH_AMD64_X32:
	case LIBSYSCALLS_ARCH_I386:
#ifdef LIST_LINUX_ERRORS_FOR_X86
		CASE(x86);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_ARM_OABI:
	case LIBSYSCALLS_ARCH_ARM_EABI:
#ifdef LIST_LINUX_ERRORS_FOR_ARM
		CASE(arm);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_IA64:
#ifdef LIST_LINUX_ERRORS_FOR_IA64
		CASE(ia64);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_M68K:
#ifdef LIST_LINUX_ERRORS_FOR_M68K
		CASE(m68k);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_MICROBLAZE:
#ifdef LIST_LINUX_ERRORS_FOR_MICROBLAZE
		CASE(microblaze);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_MIPS_O32:
	case LIBSYSCALLS_ARCH_MIPS_N32:
	case LIBSYSCALLS_ARCH_MIPS_N64:
#ifdef LIST_LINUX_ERRORS_FOR_MIPS
		CASE(mips);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_PARISC_32:
	case LIBSYSCALLS_ARCH_PARISC_64:
#ifdef LIST_LINUX_ERRORS_FOR_PARISC
		CASE(parisc);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_POWERPC_32:
	case LIBSYSCALLS_ARCH_POWERPC_64:
	case LIBSYSCALLS_ARCH_POWERPC_NOSPU:
	case LIBSYSCALLS_ARCH_POWERPC_SPU:
#ifdef LIST_LINUX_ERRORS_FOR_POWERPC
		CASE(powerpc);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_S390_32:
	case LIBSYSCALLS_ARCH_S390_64:
#ifdef LIST_LINUX_ERRORS_FOR_S390
		CASE(s390);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_SH:
#ifdef LIST_LINUX_ERRORS_FOR_SH
		CASE(sh);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_SPARC_32:
	case LIBSYSCALLS_ARCH_SPARC_64:
#ifdef LIST_LINUX_ERRORS_FOR_SPARC
		CASE(sparc);
#else
		break;
#endif

	case LIBSYSCALLS_ARCH_XTENSA:
#ifdef LIST_LINUX_ERRORS_FOR_XTENSA
		CASE(xtensa);
#else
		break;
#endif

	default:
		return LIBSYSCALLS_E_ARCHNOSUP;
	}

	*errs_out = linux_errors_for_generic;
	*nerrs_out = sizeof(linux_errors_for_generic) / sizeof(*linux_errors_for_generic);

out:
	return LIBSYSCALLS_E_OK;

#undef CASE
}