Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libsysdecode/errno.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static int bsd_to_linux_errno[ELAST + 1] = { | ||||
-100,-101,-102,-103,-104,-105,-106,-107,-108,-109, | -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, | ||||
-110,-111, -40, -36,-112,-113, -39, -11, -87,-122, | -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, | ||||
-116, -66, -6, -6, -6, -6, -6, -37, -38, -9, | -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, | ||||
-6, -6, -43, -42, -75,-125, -84, -61, -16, -74, | -6, -6, -43, -42, -75,-125, -84, -61, -16, -74, | ||||
-72, -67, -71 | -72, -67, -71 | ||||
}; | }; | ||||
#endif | #endif | ||||
#if defined(__aarch64__) || defined(__amd64__) | |||||
#include <contrib/cloudabi/cloudabi_types_common.h> | #include <contrib/cloudabi/cloudabi_types_common.h> | ||||
static const int cloudabi_errno_table[] = { | static const int cloudabi_errno_table[] = { | ||||
[CLOUDABI_E2BIG] = E2BIG, | [CLOUDABI_E2BIG] = E2BIG, | ||||
[CLOUDABI_EACCES] = EACCES, | [CLOUDABI_EACCES] = EACCES, | ||||
[CLOUDABI_EADDRINUSE] = EADDRINUSE, | [CLOUDABI_EADDRINUSE] = EADDRINUSE, | ||||
[CLOUDABI_EADDRNOTAVAIL] = EADDRNOTAVAIL, | [CLOUDABI_EADDRNOTAVAIL] = EADDRNOTAVAIL, | ||||
[CLOUDABI_EAFNOSUPPORT] = EAFNOSUPPORT, | [CLOUDABI_EAFNOSUPPORT] = EAFNOSUPPORT, | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | static const int cloudabi_errno_table[] = { | ||||
[CLOUDABI_ESPIPE] = ESPIPE, | [CLOUDABI_ESPIPE] = ESPIPE, | ||||
[CLOUDABI_ESRCH] = ESRCH, | [CLOUDABI_ESRCH] = ESRCH, | ||||
[CLOUDABI_ESTALE] = ESTALE, | [CLOUDABI_ESTALE] = ESTALE, | ||||
[CLOUDABI_ETIMEDOUT] = ETIMEDOUT, | [CLOUDABI_ETIMEDOUT] = ETIMEDOUT, | ||||
[CLOUDABI_ETXTBSY] = ETXTBSY, | [CLOUDABI_ETXTBSY] = ETXTBSY, | ||||
[CLOUDABI_EXDEV] = EXDEV, | [CLOUDABI_EXDEV] = EXDEV, | ||||
[CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE, | [CLOUDABI_ENOTCAPABLE] = ENOTCAPABLE, | ||||
}; | }; | ||||
#endif | |||||
int | int | ||||
sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error) | sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi, int error) | ||||
{ | { | ||||
switch (abi) { | switch (abi) { | ||||
case SYSDECODE_ABI_FREEBSD: | case SYSDECODE_ABI_FREEBSD: | ||||
case SYSDECODE_ABI_FREEBSD32: | case SYSDECODE_ABI_FREEBSD32: | ||||
Show All 9 Lines | case SYSDECODE_ABI_LINUX32: { | ||||
*/ | */ | ||||
for (i = 0; i < nitems(bsd_to_linux_errno); i++) { | for (i = 0; i < nitems(bsd_to_linux_errno); i++) { | ||||
if (error == bsd_to_linux_errno[i]) | if (error == bsd_to_linux_errno[i]) | ||||
return (i); | return (i); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
#endif | #endif | ||||
#if defined(__aarch64__) || defined(__amd64__) | case SYSDECODE_ABI_CLOUDABI32: | ||||
case SYSDECODE_ABI_CLOUDABI64: | case SYSDECODE_ABI_CLOUDABI64: | ||||
if (error >= 0 && | if (error >= 0 && | ||||
(unsigned int)error < nitems(cloudabi_errno_table)) | (unsigned int)error < nitems(cloudabi_errno_table)) | ||||
return (cloudabi_errno_table[error]); | return (cloudabi_errno_table[error]); | ||||
break; | break; | ||||
#endif | |||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
return (INT_MAX); | return (INT_MAX); | ||||
} | } | ||||
int | int | ||||
sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi, int error) | sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi, int error) | ||||
{ | { | ||||
switch (abi) { | switch (abi) { | ||||
case SYSDECODE_ABI_FREEBSD: | case SYSDECODE_ABI_FREEBSD: | ||||
case SYSDECODE_ABI_FREEBSD32: | case SYSDECODE_ABI_FREEBSD32: | ||||
return (error); | return (error); | ||||
#if defined(__i386__) || defined(__amd64__) | #if defined(__i386__) || defined(__amd64__) | ||||
case SYSDECODE_ABI_LINUX: | case SYSDECODE_ABI_LINUX: | ||||
case SYSDECODE_ABI_LINUX32: | case SYSDECODE_ABI_LINUX32: | ||||
if (error >= 0 && error <= ELAST) | if (error >= 0 && error <= ELAST) | ||||
return (bsd_to_linux_errno[error]); | return (bsd_to_linux_errno[error]); | ||||
break; | break; | ||||
#endif | #endif | ||||
#if defined(__aarch64__) || defined(__amd64__) | case SYSDECODE_ABI_CLOUDABI32: | ||||
case SYSDECODE_ABI_CLOUDABI64: { | case SYSDECODE_ABI_CLOUDABI64: { | ||||
unsigned int i; | unsigned int i; | ||||
for (i = 0; i < nitems(cloudabi_errno_table); i++) { | for (i = 0; i < nitems(cloudabi_errno_table); i++) { | ||||
if (error == cloudabi_errno_table[i]) | if (error == cloudabi_errno_table[i]) | ||||
return (i); | return (i); | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
#endif | |||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
return (INT_MAX); | return (INT_MAX); | ||||
} | } | ||||