/* Generated by gen_xl_errno.pl */
#include <errno.h>
#include "xl_errno.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))

static const int arch_to_generic_table[] = {
	[0] = 0,
	[EPERM] = -1,
	[ENOENT] = -2,
	[ESRCH] = -3,
	[EINTR] = -4,
	[EIO] = -5,
	[ENXIO] = -6,
	[E2BIG] = -7,
	[ENOEXEC] = -8,
	[EBADF] = -9,
	[ECHILD] = -10,
	[EAGAIN] = -11,
	[ENOMEM] = -12,
	[EACCES] = -13,
	[EFAULT] = -14,
	[ENOTBLK] = -15,
	[EBUSY] = -16,
	[EEXIST] = -17,
	[EXDEV] = -18,
	[ENODEV] = -19,
	[ENOTDIR] = -20,
	[EISDIR] = -21,
	[EINVAL] = -22,
	[ENFILE] = -23,
	[EMFILE] = -24,
	[ENOTTY] = -25,
	[ETXTBSY] = -26,
	[EFBIG] = -27,
	[ENOSPC] = -28,
	[ESPIPE] = -29,
	[EROFS] = -30,
	[EMLINK] = -31,
	[EPIPE] = -32,
	[EDOM] = -33,
	[ERANGE] = -34,
	[EDEADLK] = -35,
	[ENAMETOOLONG] = -36,
	[ENOLCK] = -37,
	[ENOSYS] = -38,
	[ENOTEMPTY] = -39,
	[ELOOP] = -40,
	[ENOMSG] = -42,
	[EIDRM] = -43,
	[ECHRNG] = -44,
	[EL2NSYNC] = -45,
	[EL3HLT] = -46,
	[EL3RST] = -47,
	[ELNRNG] = -48,
	[EUNATCH] = -49,
	[ENOCSI] = -50,
	[EL2HLT] = -51,
	[EBADE] = -52,
	[EBADR] = -53,
	[EXFULL] = -54,
	[ENOANO] = -55,
	[EBADRQC] = -56,
	[EBADSLT] = -57,
	[EBFONT] = -59,
	[ENOSTR] = -60,
	[ENODATA] = -61,
	[ETIME] = -62,
	[ENOSR] = -63,
	[ENONET] = -64,
	[ENOPKG] = -65,
	[EREMOTE] = -66,
	[ENOLINK] = -67,
	[EADV] = -68,
	[ESRMNT] = -69,
	[ECOMM] = -70,
	[EPROTO] = -71,
	[EMULTIHOP] = -72,
	[EDOTDOT] = -73,
	[EBADMSG] = -74,
	[EOVERFLOW] = -75,
	[ENOTUNIQ] = -76,
	[EBADFD] = -77,
	[EREMCHG] = -78,
	[ELIBACC] = -79,
	[ELIBBAD] = -80,
	[ELIBSCN] = -81,
	[ELIBMAX] = -82,
	[ELIBEXEC] = -83,
	[EILSEQ] = -84,
	[ERESTART] = -85,
	[ESTRPIPE] = -86,
	[EUSERS] = -87,
	[ENOTSOCK] = -88,
	[EDESTADDRREQ] = -89,
	[EMSGSIZE] = -90,
	[EPROTOTYPE] = -91,
	[ENOPROTOOPT] = -92,
	[EPROTONOSUPPORT] = -93,
	[ESOCKTNOSUPPORT] = -94,
	[EOPNOTSUPP] = -95,
	[EPFNOSUPPORT] = -96,
	[EAFNOSUPPORT] = -97,
	[EADDRINUSE] = -98,
	[EADDRNOTAVAIL] = -99,
	[ENETDOWN] = -100,
	[ENETUNREACH] = -101,
	[ENETRESET] = -102,
	[ECONNABORTED] = -103,
	[ECONNRESET] = -104,
	[ENOBUFS] = -105,
	[EISCONN] = -106,
	[ENOTCONN] = -107,
	[ESHUTDOWN] = -108,
	[ETOOMANYREFS] = -109,
	[ETIMEDOUT] = -110,
	[ECONNREFUSED] = -111,
	[EHOSTDOWN] = -112,
	[EHOSTUNREACH] = -113,
	[EALREADY] = -114,
	[EINPROGRESS] = -115,
	[ESTALE] = -116,
	[EUCLEAN] = -117,
	[ENOTNAM] = -118,
	[ENAVAIL] = -119,
	[EISNAM] = -120,
	[EREMOTEIO] = -121,
	[EDQUOT] = -122,
	[ENOMEDIUM] = -123,
	[EMEDIUMTYPE] = -124,
	[ECANCELED] = -125,
	[ENOKEY] = -126,
	[EKEYEXPIRED] = -127,
	[EKEYREVOKED] = -128,
	[EKEYREJECTED] = -129,
	[EOWNERDEAD] = -130,
	[ENOTRECOVERABLE] = -131,
};

static const int generic_to_arch_table[] = {
	[0] = 0,
	[1] = -EPERM,
	[2] = -ENOENT,
	[3] = -ESRCH,
	[4] = -EINTR,
	[5] = -EIO,
	[6] = -ENXIO,
	[7] = -E2BIG,
	[8] = -ENOEXEC,
	[9] = -EBADF,
	[10] = -ECHILD,
	[11] = -EAGAIN,
	[12] = -ENOMEM,
	[13] = -EACCES,
	[14] = -EFAULT,
	[15] = -ENOTBLK,
	[16] = -EBUSY,
	[17] = -EEXIST,
	[18] = -EXDEV,
	[19] = -ENODEV,
	[20] = -ENOTDIR,
	[21] = -EISDIR,
	[22] = -EINVAL,
	[23] = -ENFILE,
	[24] = -EMFILE,
	[25] = -ENOTTY,
	[26] = -ETXTBSY,
	[27] = -EFBIG,
	[28] = -ENOSPC,
	[29] = -ESPIPE,
	[30] = -EROFS,
	[31] = -EMLINK,
	[32] = -EPIPE,
	[33] = -EDOM,
	[34] = -ERANGE,
	[35] = -EDEADLK,
	[36] = -ENAMETOOLONG,
	[37] = -ENOLCK,
	[38] = -ENOSYS,
	[39] = -ENOTEMPTY,
	[40] = -ELOOP,
	[42] = -ENOMSG,
	[43] = -EIDRM,
	[44] = -ECHRNG,
	[45] = -EL2NSYNC,
	[46] = -EL3HLT,
	[47] = -EL3RST,
	[48] = -ELNRNG,
	[49] = -EUNATCH,
	[50] = -ENOCSI,
	[51] = -EL2HLT,
	[52] = -EBADE,
	[53] = -EBADR,
	[54] = -EXFULL,
	[55] = -ENOANO,
	[56] = -EBADRQC,
	[57] = -EBADSLT,
	[59] = -EBFONT,
	[60] = -ENOSTR,
	[61] = -ENODATA,
	[62] = -ETIME,
	[63] = -ENOSR,
	[64] = -ENONET,
	[65] = -ENOPKG,
	[66] = -EREMOTE,
	[67] = -ENOLINK,
	[68] = -EADV,
	[69] = -ESRMNT,
	[70] = -ECOMM,
	[71] = -EPROTO,
	[72] = -EMULTIHOP,
	[73] = -EDOTDOT,
	[74] = -EBADMSG,
	[75] = -EOVERFLOW,
	[76] = -ENOTUNIQ,
	[77] = -EBADFD,
	[78] = -EREMCHG,
	[79] = -ELIBACC,
	[80] = -ELIBBAD,
	[81] = -ELIBSCN,
	[82] = -ELIBMAX,
	[83] = -ELIBEXEC,
	[84] = -EILSEQ,
	[85] = -ERESTART,
	[86] = -ESTRPIPE,
	[87] = -EUSERS,
	[88] = -ENOTSOCK,
	[89] = -EDESTADDRREQ,
	[90] = -EMSGSIZE,
	[91] = -EPROTOTYPE,
	[92] = -ENOPROTOOPT,
	[93] = -EPROTONOSUPPORT,
	[94] = -ESOCKTNOSUPPORT,
	[95] = -EOPNOTSUPP,
	[96] = -EPFNOSUPPORT,
	[97] = -EAFNOSUPPORT,
	[98] = -EADDRINUSE,
	[99] = -EADDRNOTAVAIL,
	[100] = -ENETDOWN,
	[101] = -ENETUNREACH,
	[102] = -ENETRESET,
	[103] = -ECONNABORTED,
	[104] = -ECONNRESET,
	[105] = -ENOBUFS,
	[106] = -EISCONN,
	[107] = -ENOTCONN,
	[108] = -ESHUTDOWN,
	[109] = -ETOOMANYREFS,
	[110] = -ETIMEDOUT,
	[111] = -ECONNREFUSED,
	[112] = -EHOSTDOWN,
	[113] = -EHOSTUNREACH,
	[114] = -EALREADY,
	[115] = -EINPROGRESS,
	[116] = -ESTALE,
	[117] = -EUCLEAN,
	[118] = -ENOTNAM,
	[119] = -ENAVAIL,
	[120] = -EISNAM,
	[121] = -EREMOTEIO,
	[122] = -EDQUOT,
	[123] = -ENOMEDIUM,
	[124] = -EMEDIUMTYPE,
	[125] = -ECANCELED,
	[126] = -ENOKEY,
	[127] = -EKEYEXPIRED,
	[128] = -EKEYREVOKED,
	[129] = -EKEYREJECTED,
	[130] = -EOWNERDEAD,
	[131] = -ENOTRECOVERABLE,
};

/* x is always negative or zero */
int generic_errno(int x)
{
	if (x < -ARRAY_SIZE(arch_to_generic_table))
		return x;
	else
		return arch_to_generic_table[-x];
}

/* x is always negative or zero */
int arch_errno(int x)
{
	if (x < -ARRAY_SIZE(generic_to_arch_table))
		return x;
	else
		return generic_to_arch_table[-x];
}