codegen: a small improvement in do_bswap and do_brev
[ajla.git] / error.inc
blob0e415eef42b0f5914191af0bb6f0f912f27bb121
1 /*
2  * Copyright (C) 2024 Mikulas Patocka
3  *
4  * This file is part of Ajla.
5  *
6  * Ajla is free software: you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation, either version 3 of the License, or (at your option) any later
9  * version.
10  *
11  * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13  * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * Ajla. If not, see <https://www.gnu.org/licenses/>.
17  */
19 static const char * const error_codes[] = {
20         "Unknown error",
21         "Out of memory",
22         "Allocation size overflow",
23         "Integer is too large",
24         "Number doesn't fit",
25         "Invalid operation",
26         "Operation not supported",
27         "Negative index",
28         "Index out of range",
29         "Option doesn't match",
30         "Record field not initialized",
31         "Array entry not initialized",
32         "Not found",
33         "Non-absolute path",
34         "Abort",
35         "Floating-point NaN",
36         "Floating-point infinity",
37         "System returned invalid data",
38         "Compiler error",
39         "Optimizer error",
40         "System error",
41         "Syscall error",
42         "OS/2 error",
43         "OS/2 socket error",
44         "Win32 error",
45         "Gethostbyname error",
46         "Getaddrinfo error",
47         "Subprocess error",
48         "Library not found",
49         "Symbol not found",
50         "Exit",
51         "User error",
52         "User error 2",
53         "User error 3",
56 static const char * const system_error_codes[] = {
57         "Operation not permitted",
58         "No such file or directory",
59         "No such process",
60         "Interrupted system call",
61         "I/O error",
62         "No such device or address",
63         "Argument list too long",
64         "Exec format error",
65         "Bad file number",
66         "No child processes",
67         "Try again",
68         "Out of memory",
69         "Permission denied",
70         "Bad address",
71         "Block device required",
72         "Device or resource busy",
73         "File exists",
74         "Cross-device link",
75         "No such device",
76         "Not a directory",
77         "Is a directory",
78         "Invalid argument",
79         "File table overflow",
80         "Too many open files",
81         "Not a typewriter",
82         "Text file busy",
83         "File too large",
84         "No space left on device",
85         "Illegal seek",
86         "Read-only file system",
87         "Too many links",
88         "Broken pipe",
89         "Math argument out of domain of func",
90         "Math result not representable",
91         "Resource deadlock would occur",
92         "File name too long",
93         "No record locks available",
94         "Invalid system call number",
95         "Directory not empty",
96         "Too many symbolic links encountered",
97         "No message of desired type",
98         "Identifier removed",
99         "Channel number out of range",
100         "Level 2 not synchronized",
101         "Level 3 halted",
102         "Level 3 reset",
103         "Link number out of range",
104         "Protocol driver not attached",
105         "No CSI structure available",
106         "Level 2 halted",
107         "Invalid exchange",
108         "Invalid request descriptor",
109         "Exchange full",
110         "No anode",
111         "Invalid request code",
112         "Invalid slot",
113         "Bad font file format",
114         "Device not a stream",
115         "No data available",
116         "Timer expired",
117         "Out of streams resources",
118         "Machine is not on the network",
119         "Package not installed",
120         "Object is remote",
121         "Link has been severed",
122         "Advertise error",
123         "Srmount error",
124         "Communication error on send",
125         "Protocol error",
126         "Multihop attempted",
127         "RFS specific error",
128         "Not a data message",
129         "Value too large for defined data type",
130         "Name not unique on network",
131         "File descriptor in bad state",
132         "Remote address changed",
133         "Can not access a needed shared library",
134         "Accessing a corrupted shared library",
135         ".lib section in a.out corrupted",
136         "Attempting to link in too many shared libraries",
137         "Cannot exec a shared library directly",
138         "Illegal byte sequence",
139         "Interrupted system call should be restarted",
140         "Streams pipe error",
141         "Too many users",
142         "Socket operation on non-socket",
143         "Destination address required",
144         "Message too long",
145         "Protocol wrong type for socket",
146         "Protocol not available",
147         "Protocol not supported",
148         "Socket type not supported",
149         "Operation not supported on transport endpoint",
150         "Protocol family not supported",
151         "Address family not supported by protocol",
152         "Address already in use",
153         "Cannot assign requested address",
154         "Network is down",
155         "Network is unreachable",
156         "Network dropped connection because of reset",
157         "Software caused connection abort",
158         "Connection reset by peer",
159         "No buffer space available",
160         "Transport endpoint is already connected",
161         "Transport endpoint is not connected",
162         "Cannot send after transport endpoint shutdown",
163         "Too many references: cannot splice",
164         "Connection timed out",
165         "Connection refused",
166         "Host is down",
167         "No route to host",
168         "Operation already in progress",
169         "Operation now in progress",
170         "Stale file handle",
171         "Structure needs cleaning",
172         "Not a XENIX named type file",
173         "No XENIX semaphores available",
174         "Is a named type file",
175         "Remote I/O error",
176         "Quota exceeded",
177         "No medium found",
178         "Wrong medium type",
179         "Operation Canceled",
180         "Required key not available",
181         "Key has expired",
182         "Key has been revoked",
183         "Key was rejected by service",
184         "Owner died",
185         "State not recoverable",
186         "Operation not possible due to RF-kill",
187         "Memory page has hardware error",
190 static const char attr_cold *error_ajla_decode(int error)
192         if (likely(error >= AJLA_ERROR_BASE) && likely(error < AJLA_ERROR_N))
193                 return error_codes[error - AJLA_ERROR_BASE];
194         return NULL;
197 void attr_cold trace(const char attr_unused *m, ...)
199 #ifdef DEBUG_TRACE
200         va_list l;
201         va_start(l, m);
202         trace_v(m, l);
203         va_end(l);
204 #endif
207 void attr_cold stderr_msg(const char *m, ...)
209         va_list l;
210         va_start(l, m);
211         stderr_msg_v(m, l);
212         va_end(l);
215 void attr_cold debug(const char *m, ...)
217         va_list l;
218         va_start(l, m);
219         debug_v(m, l);
220         va_end(l);
223 void attr_cold warning(const char *m, ...)
225         va_list l;
226         va_start(l, m);
227         warning_v(m, l);
228         va_end(l);
231 attr_noreturn attr_cold fatal(const char *m, ...)
233         va_list l;
234         va_start(l, m);
235         fatal_v(m, l);
236         va_end(l);
239 attr_noreturn attr_cold internal(const char *position, const char *m, ...)
241         va_list l;
242         va_start(l, m);
243         internal_v(position, m, l);
244         va_end(l);
247 void attr_cold attr_printf(3,4) fatal_mayfail(ajla_error_t e, ajla_error_t *mayfail, const char *m, ...)
249         if (mayfail == MEM_DONT_TRY_TO_FREE)
250                 return;
251         if (unlikely(!mayfail)) {
252                 va_list l;
253                 va_start(l, m);
254                 fatal_v(m, l);
255                 va_end(l);
256                 return;
257         }
258         *mayfail = e;
261 void attr_cold attr_printf(3,4) fatal_warning_mayfail(ajla_error_t e, ajla_error_t *mayfail, const char *m, ...)
263         if (unlikely(!mayfail)) {
264                 va_list l;
265                 va_start(l, m);
266                 fatal_v(m, l);
267                 va_end(l);
268                 return;
269         } else {
270                 va_list l;
271                 va_start(l, m);
272                 warning_v(m, l);
273                 va_end(l);
274                 if (mayfail != MEM_DONT_TRY_TO_FREE)
275                         *mayfail = e;
276         }
279 struct system_error_table_entry {
280         int errn;
281         int sys_error;
284 static const struct system_error_table_entry errno_to_system_error[] = {
285 #ifdef EPERM
286         { EPERM,                SYSTEM_ERROR_EPERM },
287 #endif
288 #ifdef ENOENT
289         { ENOENT,               SYSTEM_ERROR_ENOENT },
290 #endif
291 #ifdef ESRCH
292         { ESRCH,                SYSTEM_ERROR_ESRCH },
293 #endif
294 #ifdef EINTR
295         { EINTR,                SYSTEM_ERROR_EINTR },
296 #endif
297 #ifdef EIO
298         { EIO,                  SYSTEM_ERROR_EIO },
299 #endif
300 #ifdef ENXIO
301         { ENXIO,                SYSTEM_ERROR_ENXIO },
302 #endif
303 #ifdef E2BIG
304         { E2BIG,                SYSTEM_ERROR_E2BIG },
305 #endif
306 #ifdef ENOEXEC
307         { ENOEXEC,              SYSTEM_ERROR_ENOEXEC },
308 #endif
309 #ifdef EBADF
310         { EBADF,                SYSTEM_ERROR_EBADF },
311 #endif
312 #ifdef ECHILD
313         { ECHILD,               SYSTEM_ERROR_ECHILD },
314 #endif
315 #ifdef EAGAIN
316         { EAGAIN,               SYSTEM_ERROR_EAGAIN },
317 #endif
318 #ifdef ENOMEM
319         { ENOMEM,               SYSTEM_ERROR_ENOMEM },
320 #endif
321 #ifdef EACCES
322         { EACCES,               SYSTEM_ERROR_EACCES },
323 #endif
324 #ifdef EFAULT
325         { EFAULT,               SYSTEM_ERROR_EFAULT },
326 #endif
327 #ifdef ENOTBLK
328         { ENOTBLK,              SYSTEM_ERROR_ENOTBLK },
329 #endif
330 #ifdef EBUSY
331         { EBUSY,                SYSTEM_ERROR_EBUSY },
332 #endif
333 #ifdef EEXIST
334         { EEXIST,               SYSTEM_ERROR_EEXIST },
335 #endif
336 #ifdef EXDEV
337         { EXDEV,                SYSTEM_ERROR_EXDEV },
338 #endif
339 #ifdef ENODEV
340         { ENODEV,               SYSTEM_ERROR_ENODEV },
341 #endif
342 #ifdef ENOTDIR
343         { ENOTDIR,              SYSTEM_ERROR_ENOTDIR },
344 #endif
345 #ifdef EISDIR
346         { EISDIR,               SYSTEM_ERROR_EISDIR },
347 #endif
348 #ifdef EINVAL
349         { EINVAL,               SYSTEM_ERROR_EINVAL },
350 #endif
351 #ifdef ENFILE
352         { ENFILE,               SYSTEM_ERROR_ENFILE },
353 #endif
354 #ifdef EMFILE
355         { EMFILE,               SYSTEM_ERROR_EMFILE },
356 #endif
357 #ifdef ENOTTY
358         { ENOTTY,               SYSTEM_ERROR_ENOTTY },
359 #endif
360 #ifdef ETXTBSY
361         { ETXTBSY,              SYSTEM_ERROR_ETXTBSY },
362 #endif
363 #ifdef EFBIG
364         { EFBIG,                SYSTEM_ERROR_EFBIG },
365 #endif
366 #ifdef ENOSPC
367         { ENOSPC,               SYSTEM_ERROR_ENOSPC },
368 #endif
369 #ifdef ESPIPE
370         { ESPIPE,               SYSTEM_ERROR_ESPIPE },
371 #endif
372 #ifdef EROFS
373         { EROFS,                SYSTEM_ERROR_EROFS },
374 #endif
375 #ifdef EMLINK
376         { EMLINK,               SYSTEM_ERROR_EMLINK },
377 #endif
378 #ifdef EPIPE
379         { EPIPE,                SYSTEM_ERROR_EPIPE },
380 #endif
381 #ifdef EDOM
382         { EDOM,                 SYSTEM_ERROR_EDOM },
383 #endif
384 #ifdef ERANGE
385         { ERANGE,               SYSTEM_ERROR_ERANGE },
386 #endif
387 #ifdef EDEADLK
388         { EDEADLK,              SYSTEM_ERROR_EDEADLK },
389 #endif
390 #ifdef ENAMETOOLONG
391         { ENAMETOOLONG,         SYSTEM_ERROR_ENAMETOOLONG },
392 #endif
393 #ifdef ENOLCK
394         { ENOLCK,               SYSTEM_ERROR_ENOLCK },
395 #endif
396 #ifdef ENOSYS
397         { ENOSYS,               SYSTEM_ERROR_ENOSYS },
398 #endif
399 #ifdef ENOTEMPTY
400         { ENOTEMPTY,            SYSTEM_ERROR_ENOTEMPTY },
401 #endif
402 #ifdef ELOOP
403         { ELOOP,                SYSTEM_ERROR_ELOOP },
404 #endif
405 #ifdef EWOULDBLOCK
406         { EWOULDBLOCK,          SYSTEM_ERROR_EAGAIN },
407 #endif
408 #ifdef ENOMSG
409         { ENOMSG,               SYSTEM_ERROR_ENOMSG },
410 #endif
411 #ifdef EIDRM
412         { EIDRM,                SYSTEM_ERROR_EIDRM },
413 #endif
414 #ifdef ECHRNG
415         { ECHRNG,               SYSTEM_ERROR_ECHRNG },
416 #endif
417 #ifdef EL2NSYNC
418         { EL2NSYNC,             SYSTEM_ERROR_EL2NSYNC },
419 #endif
420 #ifdef EL3HLT
421         { EL3HLT,               SYSTEM_ERROR_EL3HLT },
422 #endif
423 #ifdef EL3RST
424         { EL3RST,               SYSTEM_ERROR_EL3RST },
425 #endif
426 #ifdef ELNRNG
427         { ELNRNG,               SYSTEM_ERROR_ELNRNG },
428 #endif
429 #ifdef EUNATCH
430         { EUNATCH,              SYSTEM_ERROR_EUNATCH },
431 #endif
432 #ifdef ENOCSI
433         { ENOCSI,               SYSTEM_ERROR_ENOCSI },
434 #endif
435 #ifdef EL2HLT
436         { EL2HLT,               SYSTEM_ERROR_EL2HLT },
437 #endif
438 #ifdef EBADE
439         { EBADE,                SYSTEM_ERROR_EBADE },
440 #endif
441 #ifdef EBADR
442         { EBADR,                SYSTEM_ERROR_EBADR },
443 #endif
444 #ifdef EXFULL
445         { EXFULL,               SYSTEM_ERROR_EXFULL },
446 #endif
447 #ifdef ENOANO
448         { ENOANO,               SYSTEM_ERROR_ENOANO },
449 #endif
450 #ifdef EBADRQC
451         { EBADRQC,              SYSTEM_ERROR_EBADRQC },
452 #endif
453 #ifdef EBADSLT
454         { EBADSLT,              SYSTEM_ERROR_EBADSLT },
455 #endif
456 #ifdef EDEADLOCK
457         { EDEADLOCK,            SYSTEM_ERROR_EDEADLK },
458 #endif
459 #ifdef EBFONT
460         { EBFONT,               SYSTEM_ERROR_EBFONT },
461 #endif
462 #ifdef ENOSTR
463         { ENOSTR,               SYSTEM_ERROR_ENOSTR },
464 #endif
465 #ifdef ENODATA
466         { ENODATA,              SYSTEM_ERROR_ENODATA },
467 #endif
468 #ifdef ETIME
469         { ETIME,                SYSTEM_ERROR_ETIME },
470 #endif
471 #ifdef ENOSR
472         { ENOSR,                SYSTEM_ERROR_ENOSR },
473 #endif
474 #ifdef ENONET
475         { ENONET,               SYSTEM_ERROR_ENONET },
476 #endif
477 #ifdef ENOPKG
478         { ENOPKG,               SYSTEM_ERROR_ENOPKG },
479 #endif
480 #ifdef EREMOTE
481         { EREMOTE,              SYSTEM_ERROR_EREMOTE },
482 #endif
483 #ifdef ENOLINK
484         { ENOLINK,              SYSTEM_ERROR_ENOLINK },
485 #endif
486 #ifdef EADV
487         { EADV,                 SYSTEM_ERROR_EADV },
488 #endif
489 #ifdef ESRMNT
490         { ESRMNT,               SYSTEM_ERROR_ESRMNT },
491 #endif
492 #ifdef ECOMM
493         { ECOMM,                SYSTEM_ERROR_ECOMM },
494 #endif
495 #ifdef EPROTO
496         { EPROTO,               SYSTEM_ERROR_EPROTO },
497 #endif
498 #ifdef EMULTIHOP
499         { EMULTIHOP,            SYSTEM_ERROR_EMULTIHOP },
500 #endif
501 #ifdef EDOTDOT
502         { EDOTDOT,              SYSTEM_ERROR_EDOTDOT },
503 #endif
504 #ifdef EBADMSG
505         { EBADMSG,              SYSTEM_ERROR_EBADMSG },
506 #endif
507 #ifdef EOVERFLOW
508         { EOVERFLOW,            SYSTEM_ERROR_EOVERFLOW },
509 #endif
510 #ifdef ENOTUNIQ
511         { ENOTUNIQ,             SYSTEM_ERROR_ENOTUNIQ },
512 #endif
513 #ifdef EBADFD
514         { EBADFD,               SYSTEM_ERROR_EBADFD },
515 #endif
516 #ifdef EREMCHG
517         { EREMCHG,              SYSTEM_ERROR_EREMCHG },
518 #endif
519 #ifdef ELIBACC
520         { ELIBACC,              SYSTEM_ERROR_ELIBACC },
521 #endif
522 #ifdef ELIBBAD
523         { ELIBBAD,              SYSTEM_ERROR_ELIBBAD },
524 #endif
525 #ifdef ELIBSCN
526         { ELIBSCN,              SYSTEM_ERROR_ELIBSCN },
527 #endif
528 #ifdef ELIBMAX
529         { ELIBMAX,              SYSTEM_ERROR_ELIBMAX },
530 #endif
531 #ifdef ELIBEXEC
532         { ELIBEXEC,             SYSTEM_ERROR_ELIBEXEC },
533 #endif
534 #ifdef EILSEQ
535         { EILSEQ,               SYSTEM_ERROR_EILSEQ },
536 #endif
537 #ifdef ERESTART
538         { ERESTART,             SYSTEM_ERROR_ERESTART },
539 #endif
540 #ifdef ESTRPIPE
541         { ESTRPIPE,             SYSTEM_ERROR_ESTRPIPE },
542 #endif
543 #ifdef EUSERS
544         { EUSERS,               SYSTEM_ERROR_EUSERS },
545 #endif
546 #ifdef ENOTSOCK
547         { ENOTSOCK,             SYSTEM_ERROR_ENOTSOCK },
548 #endif
549 #ifdef EDESTADDRREQ
550         { EDESTADDRREQ,         SYSTEM_ERROR_EDESTADDRREQ },
551 #endif
552 #ifdef EMSGSIZE
553         { EMSGSIZE,             SYSTEM_ERROR_EMSGSIZE },
554 #endif
555 #ifdef EPROTOTYPE
556         { EPROTOTYPE,           SYSTEM_ERROR_EPROTOTYPE },
557 #endif
558 #ifdef ENOPROTOOPT
559         { ENOPROTOOPT,          SYSTEM_ERROR_ENOPROTOOPT },
560 #endif
561 #ifdef EPROTONOSUPPORT
562         { EPROTONOSUPPORT,      SYSTEM_ERROR_EPROTONOSUPPORT },
563 #endif
564 #ifdef ESOCKTNOSUPPORT
565         { ESOCKTNOSUPPORT,      SYSTEM_ERROR_ESOCKTNOSUPPORT },
566 #endif
567 #ifdef EOPNOTSUPP
568         { EOPNOTSUPP,           SYSTEM_ERROR_EOPNOTSUPP },
569 #endif
570 #ifdef EPFNOSUPPORT
571         { EPFNOSUPPORT,         SYSTEM_ERROR_EPFNOSUPPORT },
572 #endif
573 #ifdef EAFNOSUPPORT
574         { EAFNOSUPPORT,         SYSTEM_ERROR_EAFNOSUPPORT },
575 #endif
576 #ifdef EADDRINUSE
577         { EADDRINUSE,           SYSTEM_ERROR_EADDRINUSE },
578 #endif
579 #ifdef EADDRNOTAVAIL
580         { EADDRNOTAVAIL,        SYSTEM_ERROR_EADDRNOTAVAIL },
581 #endif
582 #ifdef ENETDOWN
583         { ENETDOWN,             SYSTEM_ERROR_ENETDOWN },
584 #endif
585 #ifdef ENETUNREACH
586         { ENETUNREACH,          SYSTEM_ERROR_ENETUNREACH },
587 #endif
588 #ifdef ENETRESET
589         { ENETRESET,            SYSTEM_ERROR_ENETRESET },
590 #endif
591 #ifdef ECONNABORTED
592         { ECONNABORTED,         SYSTEM_ERROR_ECONNABORTED },
593 #endif
594 #ifdef ECONNRESET
595         { ECONNRESET,           SYSTEM_ERROR_ECONNRESET },
596 #endif
597 #ifdef ENOBUFS
598         { ENOBUFS,              SYSTEM_ERROR_ENOBUFS },
599 #endif
600 #ifdef EISCONN
601         { EISCONN,              SYSTEM_ERROR_EISCONN },
602 #endif
603 #ifdef ENOTCONN
604         { ENOTCONN,             SYSTEM_ERROR_ENOTCONN },
605 #endif
606 #ifdef ESHUTDOWN
607         { ESHUTDOWN,            SYSTEM_ERROR_ESHUTDOWN },
608 #endif
609 #ifdef ETOOMANYREFS
610         { ETOOMANYREFS,         SYSTEM_ERROR_ETOOMANYREFS },
611 #endif
612 #ifdef ETIMEDOUT
613         { ETIMEDOUT,            SYSTEM_ERROR_ETIMEDOUT },
614 #endif
615 #ifdef ECONNREFUSED
616         { ECONNREFUSED,         SYSTEM_ERROR_ECONNREFUSED },
617 #endif
618 #ifdef EHOSTDOWN
619         { EHOSTDOWN,            SYSTEM_ERROR_EHOSTDOWN },
620 #endif
621 #ifdef EHOSTUNREACH
622         { EHOSTUNREACH,         SYSTEM_ERROR_EHOSTUNREACH },
623 #endif
624 #ifdef EALREADY
625         { EALREADY,             SYSTEM_ERROR_EALREADY },
626 #endif
627 #ifdef EINPROGRESS
628         { EINPROGRESS,          SYSTEM_ERROR_EINPROGRESS },
629 #endif
630 #ifdef ESTALE
631         { ESTALE,               SYSTEM_ERROR_ESTALE },
632 #endif
633 #ifdef EUCLEAN
634         { EUCLEAN,              SYSTEM_ERROR_EUCLEAN },
635 #endif
636 #ifdef ENOTNAM
637         { ENOTNAM,              SYSTEM_ERROR_ENOTNAM },
638 #endif
639 #ifdef ENAVAIL
640         { ENAVAIL,              SYSTEM_ERROR_ENAVAIL },
641 #endif
642 #ifdef EISNAM
643         { EISNAM,               SYSTEM_ERROR_EISNAM },
644 #endif
645 #ifdef EREMOTEIO
646         { EREMOTEIO,            SYSTEM_ERROR_EREMOTEIO },
647 #endif
648 #ifdef EDQUOT
649         { EDQUOT,               SYSTEM_ERROR_EDQUOT },
650 #endif
651 #ifdef ENOMEDIUM
652         { ENOMEDIUM,            SYSTEM_ERROR_ENOMEDIUM },
653 #endif
654 #ifdef EMEDIUMTYPE
655         { EMEDIUMTYPE,          SYSTEM_ERROR_EMEDIUMTYPE },
656 #endif
657 #ifdef ECANCELED
658         { ECANCELED,            SYSTEM_ERROR_ECANCELED },
659 #endif
660 #ifdef ENOKEY
661         { ENOKEY,               SYSTEM_ERROR_ENOKEY },
662 #endif
663 #ifdef EKEYEXPIRED
664         { EKEYEXPIRED,          SYSTEM_ERROR_EKEYEXPIRED },
665 #endif
666 #ifdef EKEYREVOKED
667         { EKEYREVOKED,          SYSTEM_ERROR_EKEYREVOKED },
668 #endif
669 #ifdef EKEYREJECTED
670         { EKEYREJECTED,         SYSTEM_ERROR_EKEYREJECTED },
671 #endif
672 #ifdef EOWNERDEAD
673         { EOWNERDEAD,           SYSTEM_ERROR_EOWNERDEAD },
674 #endif
675 #ifdef ENOTRECOVERABLE
676         { ENOTRECOVERABLE,      SYSTEM_ERROR_ENOTRECOVERABLE },
677 #endif
678 #ifdef ERFKILL
679         { ERFKILL,              SYSTEM_ERROR_ERFKILL },
680 #endif
681 #ifdef EHWPOISON
682         { EHWPOISON,            SYSTEM_ERROR_EHWPOISON },
683 #endif
686 ajla_error_t error_from_errno(int ec, int errn)
688         size_t i;
689         for (i = 0; i < n_array_elements(errno_to_system_error); i++) {
690                 if (unlikely(errn == errno_to_system_error[i].errn))
691                         return error_ajla_aux(ec, AJLA_ERROR_SYSTEM, errno_to_system_error[i].sys_error);
692         }
693         return error_ajla_aux(ec, AJLA_ERROR_ERRNO, errn);