This is a simple, auxiliary module: It iterates through all valid errno values defined by a platform.
2025-02-18 Bruno Haible <br...@clisp.org> errno-iter: New module. * lib/errno-iter.h: New file. * lib/errno-iter.c: New file, based on lib/strerrorname_np.c. * modules/errno-iter: New file.
>From 1108ef767c53e20b75e6b5df770f5791299ce048 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Tue, 18 Feb 2025 12:11:29 +0100 Subject: [PATCH] errno-iter: New module. * lib/errno-iter.h: New file. * lib/errno-iter.c: New file, based on lib/strerrorname_np.c. * modules/errno-iter: New file. --- ChangeLog | 7 + lib/errno-iter.c | 1345 ++++++++++++++++++++++++++++++++++++++++++++ lib/errno-iter.h | 43 ++ modules/errno-iter | 22 + 4 files changed, 1417 insertions(+) create mode 100644 lib/errno-iter.c create mode 100644 lib/errno-iter.h create mode 100644 modules/errno-iter diff --git a/ChangeLog b/ChangeLog index fd7b76b910..b63eff9a35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-02-18 Bruno Haible <br...@clisp.org> + + errno-iter: New module. + * lib/errno-iter.h: New file. + * lib/errno-iter.c: New file, based on lib/strerrorname_np.c. + * modules/errno-iter: New file. + 2025-02-18 Bruno Haible <br...@clisp.org> at-init: Add tests. diff --git a/lib/errno-iter.c b/lib/errno-iter.c new file mode 100644 index 0000000000..618a7871a5 --- /dev/null +++ b/lib/errno-iter.c @@ -0,0 +1,1345 @@ +/* Iteration over all valid error numbers. + Copyright (C) 2020-2025 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2025. */ + +#include <config.h> + +/* Specification. */ +#include "errno-iter.h" + +#include <errno.h> + +void +errno_iterate (errno_iterate_callback_fn callback, void *data) +{ + /* Keep this list in sync with strerrorname_np.c ! */ + + /* Error codes specified by ISO C. */ + if (callback (data, EDOM)) return; + if (callback (data, EILSEQ)) return; + if (callback (data, ERANGE)) return; + + /* Error codes specified by POSIX. + <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/errno.h.html> */ + #if defined E2BIG + if (callback (data, E2BIG)) return; + #endif + #if defined EACCES + if (callback (data, EACCES)) return; + #endif + #if defined EADDRINUSE + if (callback (data, EADDRINUSE)) return; + #endif + #if defined EADDRNOTAVAIL + if (callback (data, EADDRNOTAVAIL)) return; + #endif + #if defined EAFNOSUPPORT + if (callback (data, EAFNOSUPPORT)) return; + #endif + #if defined EAGAIN + if (callback (data, EAGAIN)) return; + #endif + #if defined EALREADY + if (callback (data, EALREADY)) return; + #endif + #if defined EBADF + if (callback (data, EBADF)) return; + #endif + #if defined EBADMSG + if (callback (data, EBADMSG)) return; + #endif + #if defined EBUSY + if (callback (data, EBUSY)) return; + #endif + #if defined ECANCELED + if (callback (data, ECANCELED)) return; + #endif + #if defined ECHILD + if (callback (data, ECHILD)) return; + #endif + #if defined ECONNABORTED + if (callback (data, ECONNABORTED)) return; + #endif + #if defined ECONNREFUSED + if (callback (data, ECONNREFUSED)) return; + #endif + #if defined ECONNRESET + if (callback (data, ECONNRESET)) return; + #endif + #if defined EDEADLK + if (callback (data, EDEADLK)) return; + #endif + #if defined EDESTADDRREQ + if (callback (data, EDESTADDRREQ)) return; + #endif + #if defined EDQUOT + if (callback (data, EDQUOT)) return; + #endif + #if defined EEXIST + if (callback (data, EEXIST)) return; + #endif + #if defined EFAULT + if (callback (data, EFAULT)) return; + #endif + #if defined EFBIG + if (callback (data, EFBIG)) return; + #endif + #if defined EHOSTUNREACH + if (callback (data, EHOSTUNREACH)) return; + #endif + #if defined EIDRM + if (callback (data, EIDRM)) return; + #endif + #if defined EINPROGRESS + if (callback (data, EINPROGRESS)) return; + #endif + #if defined EINTR + if (callback (data, EINTR)) return; + #endif + #if defined EINVAL + if (callback (data, EINVAL)) return; + #endif + #if defined EIO + if (callback (data, EIO)) return; + #endif + #if defined EISCONN + if (callback (data, EISCONN)) return; + #endif + #if defined EISDIR + if (callback (data, EISDIR)) return; + #endif + #if defined ELOOP + if (callback (data, ELOOP)) return; + #endif + #if defined EMFILE + if (callback (data, EMFILE)) return; + #endif + #if defined EMLINK + if (callback (data, EMLINK)) return; + #endif + #if defined EMSGSIZE + if (callback (data, EMSGSIZE)) return; + #endif + #if defined EMULTIHOP + if (callback (data, EMULTIHOP)) return; + #endif + #if defined ENAMETOOLONG + if (callback (data, ENAMETOOLONG)) return; + #endif + #if defined ENETDOWN + if (callback (data, ENETDOWN)) return; + #endif + #if defined ENETRESET + if (callback (data, ENETRESET)) return; + #endif + #if defined ENETUNREACH + if (callback (data, ENETUNREACH)) return; + #endif + #if defined ENFILE + if (callback (data, ENFILE)) return; + #endif + #if defined ENOBUFS + if (callback (data, ENOBUFS)) return; + #endif + #if defined ENODATA + if (callback (data, ENODATA)) return; + #endif + #if defined ENODEV + if (callback (data, ENODEV)) return; + #endif + #if defined ENOENT + if (callback (data, ENOENT)) return; + #endif + #if defined ENOEXEC + if (callback (data, ENOEXEC)) return; + #endif + #if defined ENOLCK + if (callback (data, ENOLCK)) return; + #endif + #if defined ENOLINK + if (callback (data, ENOLINK)) return; + #endif + #if defined ENOMEM + if (callback (data, ENOMEM)) return; + #endif + #if defined ENOMSG + if (callback (data, ENOMSG)) return; + #endif + #if defined ENOPROTOOPT + if (callback (data, ENOPROTOOPT)) return; + #endif + #if defined ENOSPC + if (callback (data, ENOSPC)) return; + #endif + #if defined ENOSR + if (callback (data, ENOSR)) return; + #endif + #if defined ENOSTR + if (callback (data, ENOSTR)) return; + #endif + #if defined ENOSYS + if (callback (data, ENOSYS)) return; + #endif + #if defined ENOTCONN + if (callback (data, ENOTCONN)) return; + #endif + #if defined ENOTDIR + if (callback (data, ENOTDIR)) return; + #endif + #if defined ENOTEMPTY && ENOTEMPTY != EEXIST + if (callback (data, ENOTEMPTY)) return; + #endif + #if defined ENOTRECOVERABLE + if (callback (data, ENOTRECOVERABLE)) return; + #endif + #if defined ENOTSOCK + if (callback (data, ENOTSOCK)) return; + #endif + #if defined ENOTSUP && ENOTSUP != EOPNOTSUPP + if (callback (data, ENOTSUP)) return; + #endif + #if defined ENOTTY + if (callback (data, ENOTTY)) return; + #endif + #if defined ENXIO + if (callback (data, ENXIO)) return; + #endif + #if defined EOPNOTSUPP + if (callback (data, EOPNOTSUPP)) return; + #endif + #if defined EOVERFLOW + if (callback (data, EOVERFLOW)) return; + #endif + #if defined EOWNERDEAD + if (callback (data, EOWNERDEAD)) return; + #endif + #if defined EPERM + if (callback (data, EPERM)) return; + #endif + #if defined EPIPE + if (callback (data, EPIPE)) return; + #endif + #if defined EPROTO + if (callback (data, EPROTO)) return; + #endif + #if defined EPROTONOSUPPORT + if (callback (data, EPROTONOSUPPORT)) return; + #endif + #if defined EPROTOTYPE + if (callback (data, EPROTOTYPE)) return; + #endif + #if defined EROFS + if (callback (data, EROFS)) return; + #endif + #if defined ESOCKTNOSUPPORT + if (callback (data, ESOCKTNOSUPPORT)) return; + #endif + #if defined ESPIPE + if (callback (data, ESPIPE)) return; + #endif + #if defined ESRCH + if (callback (data, ESRCH)) return; + #endif + #if defined ESTALE + if (callback (data, ESTALE)) return; + #endif + #if defined ETIME + if (callback (data, ETIME)) return; + #endif + #if defined ETIMEDOUT + if (callback (data, ETIMEDOUT)) return; + #endif + #if defined ETXTBSY + if (callback (data, ETXTBSY)) return; + #endif + #if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN + if (callback (data, EWOULDBLOCK)) return; + #endif + #if defined EXDEV + if (callback (data, EXDEV)) return; + #endif + + /* Other error codes on other systems. */ + /* Solaris */ + #if defined EADI + if (callback (data, EADI)) return; + #endif + /* Linux, HP-UX, IRIX, Solaris, Cygwin */ + #if defined EADV + if (callback (data, EADV)) return; + #endif + /* OSF/1 */ + #if defined EAIO + if (callback (data, EAIO)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */ + #if defined EAUTH + if (callback (data, EAUTH)) return; + #endif + /* GNU/Hurd */ + #if defined EBACKGROUND + if (callback (data, EBACKGROUND)) return; + #endif + /* Mac OS X */ + #if defined EBADARCH + if (callback (data, EBADARCH)) return; + #endif + /* Minix */ + #if defined EBADCALL + if (callback (data, EBADCALL)) return; + #endif + /* Minix */ + #if defined EBADCPU + if (callback (data, EBADCPU)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EBADE && EBADE != ECKSUM + if (callback (data, EBADE)) return; + #endif + /* Minix */ + #if defined EBADEPT + if (callback (data, EBADEPT)) return; + #endif + /* Mac OS X */ + #if defined EBADEXEC + if (callback (data, EBADEXEC)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EBADFD + if (callback (data, EBADFD)) return; + #endif + /* IRIX */ + #if defined EBADFILT + if (callback (data, EBADFILT)) return; + #endif + /* Minix */ + #if defined EBADIOCTL + if (callback (data, EBADIOCTL)) return; + #endif + /* Mac OS X */ + #if defined EBADMACHO + if (callback (data, EBADMACHO)) return; + #endif + /* Minix */ + #if defined EBADMODE + if (callback (data, EBADMODE)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EBADR && EBADR != EFRAGS + if (callback (data, EBADR)) return; + #endif + /* Minix */ + #if defined EBADREQUEST + if (callback (data, EBADREQUEST)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, OSF/1, Minix */ + #if defined EBADRPC + if (callback (data, EBADRPC)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EBADRQC + if (callback (data, EBADRQC)) return; + #endif + /* IRIX */ + #if defined EBADRSPEC + if (callback (data, EBADRSPEC)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EBADSLT + if (callback (data, EBADSLT)) return; + #endif + /* IRIX */ + #if defined EBADTSPEC + if (callback (data, EBADTSPEC)) return; + #endif + /* HP-UX */ + #if defined EBADVER + if (callback (data, EBADVER)) return; + #endif + /* IRIX */ + #if defined EBDHDL + if (callback (data, EBDHDL)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EBFONT + if (callback (data, EBFONT)) return; + #endif + /* IRIX */ + #if defined EBUFSIZE + if (callback (data, EBUFSIZE)) return; + #endif + /* Minix */ + #if defined ECALLDENIED + if (callback (data, ECALLDENIED)) return; + #endif + /* IRIX */ + #if defined ECANTEXTENT + if (callback (data, ECANTEXTENT)) return; + #endif + /* FreeBSD */ + #if defined ECAPMODE + if (callback (data, ECAPMODE)) return; + #endif + /* Cygwin */ + #if defined ECASECLASH + if (callback (data, ECASECLASH)) return; + #endif + /* IRIX */ + #if defined ECELLDOWN + if (callback (data, ECELLDOWN)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined ECHRNG + if (callback (data, ECHRNG)) return; + #endif + /* IRIX */ + #if defined ECKPT + if (callback (data, ECKPT)) return; + #endif + /* Solaris */ + #if defined ECKSUM + if (callback (data, ECKSUM)) return; + #endif + /* IRIX */ + #if defined ECLOCKCPU + if (callback (data, ECLOCKCPU)) return; + #endif + /* OSF/1 */ + #if defined ECLONEME && ECLONEME != ERESTART + if (callback (data, ECLONEME)) return; + #endif + /* Linux, HP-UX, IRIX, Solaris, Cygwin */ + #if defined ECOMM + if (callback (data, ECOMM)) return; + #endif + /* HP-UX */ + #if defined ECONFIG + if (callback (data, ECONFIG)) return; + #endif + /* IRIX */ + #if defined ECONTROLLER + if (callback (data, ECONTROLLER)) return; + #endif + /* AIX */ + #if defined ECORRUPT + if (callback (data, ECORRUPT)) return; + #endif + /* GNU/Hurd */ + #if defined ED + if (callback (data, ED)) return; + #endif + /* Minix */ + #if defined EDEADEPT + if (callback (data, EDEADEPT)) return; + #endif + /* IRIX, Solaris, Cygwin */ + #if defined EDEADLOCK && EDEADLOCK != EDEADLK + if (callback (data, EDEADLOCK)) return; + #endif + /* Minix */ + #if defined EDEADSRCDST + if (callback (data, EDEADSRCDST)) return; + #endif + /* IRIX */ + #if defined EDELAY + if (callback (data, EDELAY)) return; + #endif + /* IRIX */ + #if defined EDESTROYED + if (callback (data, EDESTROYED)) return; + #endif + /* Mac OS X */ + #if defined EDEVERR + if (callback (data, EDEVERR)) return; + #endif + /* GNU/Hurd */ + #if defined EDIED + if (callback (data, EDIED)) return; + #endif + /* IRIX */ + #if defined EDIRCORRUPTED && EDIRCORRUPTED != EFSCORRUPTED + if (callback (data, EDIRCORRUPTED)) return; + #endif + /* FreeBSD */ + #if defined EDIRIOCTL + if (callback (data, EDIRIOCTL)) return; + #endif + /* OSF/1 */ + #if defined EDIRTY + if (callback (data, EDIRTY)) return; + #endif + /* IRIX */ + #if defined EDISJOINT + if (callback (data, EDISJOINT)) return; + #endif + /* AIX */ + #if defined EDIST + if (callback (data, EDIST)) return; + #endif + /* Minix */ + #if defined EDONTREPLY + if (callback (data, EDONTREPLY)) return; + #endif + /* FreeBSD */ + #if defined EDOOFUS && EDOOFUS != EINVAL + if (callback (data, EDOOFUS)) return; + #endif + /* Linux, HP-UX, Cygwin */ + #if defined EDOTDOT + if (callback (data, EDOTDOT)) return; + #endif + /* OSF/1 */ + #if defined EDUPPKG + if (callback (data, EDUPPKG)) return; + #endif + /* GNU/Hurd */ + #if defined ED_ALREADY_OPEN + if (callback (data, ED_ALREADY_OPEN)) return; + #endif + /* GNU/Hurd */ + #if defined ED_DEVICE_DOWN + if (callback (data, ED_DEVICE_DOWN)) return; + #endif + /* GNU/Hurd */ + #if defined ED_INVALID_OPERATION + if (callback (data, ED_INVALID_OPERATION)) return; + #endif + /* GNU/Hurd */ + #if defined ED_INVALID_RECNUM + if (callback (data, ED_INVALID_RECNUM)) return; + #endif + /* GNU/Hurd */ + #if defined ED_INVALID_SIZE + if (callback (data, ED_INVALID_SIZE)) return; + #endif + /* GNU/Hurd */ + #if defined ED_IO_ERROR + if (callback (data, ED_IO_ERROR)) return; + #endif + /* GNU/Hurd */ + #if defined ED_NO_MEMORY + if (callback (data, ED_NO_MEMORY)) return; + #endif + /* GNU/Hurd */ + #if defined ED_NO_SUCH_DEVICE + if (callback (data, ED_NO_SUCH_DEVICE)) return; + #endif + /* GNU/Hurd */ + #if defined ED_READ_ONLY + if (callback (data, ED_READ_ONLY)) return; + #endif + /* GNU/Hurd */ + #if defined ED_WOULD_BLOCK + if (callback (data, ED_WOULD_BLOCK)) return; + #endif + /* IRIX */ + #if defined EEMPTY + if (callback (data, EEMPTY)) return; + #endif + /* OSF/1 */ + #if defined EEMULATE + if (callback (data, EEMULATE)) return; + #endif + /* IRIX */ + #if defined EENDOFMINOR + if (callback (data, EENDOFMINOR)) return; + #endif + /* IRIX */ + #if defined EENQUEUED + if (callback (data, EENQUEUED)) return; + #endif + /* OSF/1 */ + #if defined EFAIL + if (callback (data, EFAIL)) return; + #endif + /* AIX */ + #if defined EFORMAT + if (callback (data, EFORMAT)) return; + #endif + /* Haiku */ + #if defined EFPOS + if (callback (data, EFPOS)) return; + #endif + /* Solaris */ + #if defined EFRAGS + if (callback (data, EFRAGS)) return; + #endif + /* IRIX */ + #if defined EFSCORRUPTED + if (callback (data, EFSCORRUPTED)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, OSF/1, Minix, Cygwin */ + #if defined EFTYPE + if (callback (data, EFTYPE)) return; + #endif + /* Minix */ + #if defined EGENERIC + if (callback (data, EGENERIC)) return; + #endif + /* GNU/Hurd */ + #if defined EGRATUITOUS + if (callback (data, EGRATUITOUS)) return; + #endif + /* GNU/Hurd */ + #if defined EGREGIOUS + if (callback (data, EGREGIOUS)) return; + #endif + /* IRIX */ + #if defined EGROUPLOOP + if (callback (data, EGROUPLOOP)) return; + #endif + /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Haiku, Cygwin */ + #if defined EHOSTDOWN + if (callback (data, EHOSTDOWN)) return; + #endif + /* Linux */ + #if defined EHWPOISON + if (callback (data, EHWPOISON)) return; + #endif + /* GNU/Hurd */ + #if defined EIEIO + if (callback (data, EIEIO)) return; + #endif + /* IRIX */ + #if defined EINIT + if (callback (data, EINIT)) return; + #endif + /* OSF/1 */ + #if defined EINPROG + if (callback (data, EINPROG)) return; + #endif + /* IRIX */ + #if defined EINVALMODE + if (callback (data, EINVALMODE)) return; + #endif + /* IRIX */ + #if defined EINVALSTATE + if (callback (data, EINVALSTATE)) return; + #endif + /* IRIX */ + #if defined EINVALTIME + if (callback (data, EINVALTIME)) return; + #endif + /* IRIX */ + #if defined EIORESID + if (callback (data, EIORESID)) return; + #endif + /* OpenBSD */ + #if defined EIPSEC + if (callback (data, EIPSEC)) return; + #endif + /* Linux, IRIX */ + #if defined EISNAM + if (callback (data, EISNAM)) return; + #endif + /* IRIX */ + #if defined EJOINED + if (callback (data, EJOINED)) return; + #endif + /* FreeBSD, OSF/1 */ + #if defined EJUSTRETURN + if (callback (data, EJUSTRETURN)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_ABORTED + if (callback (data, EKERN_ABORTED)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_FAILURE + if (callback (data, EKERN_FAILURE)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INTERRUPTED + if (callback (data, EKERN_INTERRUPTED)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_ADDRESS + if (callback (data, EKERN_INVALID_ADDRESS)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_ARGUMENT + if (callback (data, EKERN_INVALID_ARGUMENT)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_CAPABILITY + if (callback (data, EKERN_INVALID_CAPABILITY)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_HOST + if (callback (data, EKERN_INVALID_HOST)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_NAME + if (callback (data, EKERN_INVALID_NAME)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_RIGHT + if (callback (data, EKERN_INVALID_RIGHT)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_TASK + if (callback (data, EKERN_INVALID_TASK)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_INVALID_VALUE + if (callback (data, EKERN_INVALID_VALUE)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_MEMORY_ERROR + if (callback (data, EKERN_MEMORY_ERROR)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_MEMORY_FAILURE + if (callback (data, EKERN_MEMORY_FAILURE)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_MEMORY_PRESENT + if (callback (data, EKERN_MEMORY_PRESENT)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_NAME_EXISTS + if (callback (data, EKERN_NAME_EXISTS)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_NOT_IN_SET + if (callback (data, EKERN_NOT_IN_SET)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_NOT_RECEIVER + if (callback (data, EKERN_NOT_RECEIVER)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_NO_ACCESS + if (callback (data, EKERN_NO_ACCESS)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_NO_SPACE + if (callback (data, EKERN_NO_SPACE)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_PROTECTION_FAILURE + if (callback (data, EKERN_PROTECTION_FAILURE)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_RESOURCE_SHORTAGE + if (callback (data, EKERN_RESOURCE_SHORTAGE)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_RIGHT_EXISTS + if (callback (data, EKERN_RIGHT_EXISTS)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_TERMINATED + if (callback (data, EKERN_TERMINATED)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_TIMEDOUT + if (callback (data, EKERN_TIMEDOUT)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_UREFS_OVERFLOW + if (callback (data, EKERN_UREFS_OVERFLOW)) return; + #endif + /* GNU/Hurd */ + #if defined EKERN_WRITE_PROTECTION_FAILURE + if (callback (data, EKERN_WRITE_PROTECTION_FAILURE)) return; + #endif + /* Linux */ + #if defined EKEYEXPIRED + if (callback (data, EKEYEXPIRED)) return; + #endif + /* Linux */ + #if defined EKEYREJECTED + if (callback (data, EKEYREJECTED)) return; + #endif + /* Linux */ + #if defined EKEYREVOKED + if (callback (data, EKEYREVOKED)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined EL2HLT + if (callback (data, EL2HLT)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined EL2NSYNC + if (callback (data, EL2NSYNC)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined EL3HLT + if (callback (data, EL3HLT)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined EL3RST + if (callback (data, EL3RST)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */ + #if defined ELAST && 0 + if (callback (data, ELAST)) return; + #endif + /* Cygwin */ + #if defined ELBIN + if (callback (data, ELBIN)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ELIBACC + if (callback (data, ELIBACC)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ELIBBAD + if (callback (data, ELIBBAD)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ELIBEXEC + if (callback (data, ELIBEXEC)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ELIBMAX + if (callback (data, ELIBMAX)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ELIBSCN + if (callback (data, ELIBSCN)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined ELNRNG + if (callback (data, ELNRNG)) return; + #endif + /* Minix */ + #if defined ELOCKED + if (callback (data, ELOCKED)) return; + #endif + /* Solaris */ + #if defined ELOCKUNMAPPED + if (callback (data, ELOCKUNMAPPED)) return; + #endif + /* IRIX */ + #if defined ELOGINLIM + if (callback (data, ELOGINLIM)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_BODY_ERROR + if (callback (data, EMACH_RCV_BODY_ERROR)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_HEADER_ERROR + if (callback (data, EMACH_RCV_HEADER_ERROR)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_INTERRUPTED + if (callback (data, EMACH_RCV_INTERRUPTED)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_INVALID_DATA + if (callback (data, EMACH_RCV_INVALID_DATA)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_INVALID_NAME + if (callback (data, EMACH_RCV_INVALID_NAME)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_INVALID_NOTIFY + if (callback (data, EMACH_RCV_INVALID_NOTIFY)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_IN_PROGRESS + if (callback (data, EMACH_RCV_IN_PROGRESS)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_IN_SET + if (callback (data, EMACH_RCV_IN_SET)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_PORT_CHANGED + if (callback (data, EMACH_RCV_PORT_CHANGED)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_PORT_DIED + if (callback (data, EMACH_RCV_PORT_DIED)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_TIMED_OUT + if (callback (data, EMACH_RCV_TIMED_OUT)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_RCV_TOO_LARGE + if (callback (data, EMACH_RCV_TOO_LARGE)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INTERRUPTED + if (callback (data, EMACH_SEND_INTERRUPTED)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_DATA + if (callback (data, EMACH_SEND_INVALID_DATA)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_DEST + if (callback (data, EMACH_SEND_INVALID_DEST)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_HEADER + if (callback (data, EMACH_SEND_INVALID_HEADER)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_MEMORY + if (callback (data, EMACH_SEND_INVALID_MEMORY)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_NOTIFY + if (callback (data, EMACH_SEND_INVALID_NOTIFY)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_REPLY + if (callback (data, EMACH_SEND_INVALID_REPLY)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_RIGHT + if (callback (data, EMACH_SEND_INVALID_RIGHT)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_INVALID_TYPE + if (callback (data, EMACH_SEND_INVALID_TYPE)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_IN_PROGRESS + if (callback (data, EMACH_SEND_IN_PROGRESS)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_MSG_TOO_SMALL + if (callback (data, EMACH_SEND_MSG_TOO_SMALL)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_NOTIFY_IN_PROGRESS + if (callback (data, EMACH_SEND_NOTIFY_IN_PROGRESS)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_NO_BUFFER + if (callback (data, EMACH_SEND_NO_BUFFER)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_NO_NOTIFY + if (callback (data, EMACH_SEND_NO_NOTIFY)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_TIMED_OUT + if (callback (data, EMACH_SEND_TIMED_OUT)) return; + #endif + /* GNU/Hurd */ + #if defined EMACH_SEND_WILL_NOTIFY + if (callback (data, EMACH_SEND_WILL_NOTIFY)) return; + #endif + /* AIX, OSF/1 */ + #if defined EMEDIA + if (callback (data, EMEDIA)) return; + #endif + /* Linux, OpenBSD */ + #if defined EMEDIUMTYPE + if (callback (data, EMEDIUMTYPE)) return; + #endif + /* IRIX */ + #if defined EMEMRETRY + if (callback (data, EMEMRETRY)) return; + #endif + /* IRIX */ + #if defined EMIGRATED + if (callback (data, EMIGRATED)) return; + #endif + /* IRIX */ + #if defined EMIGRATING + if (callback (data, EMIGRATING)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_ARRAY_TOO_LARGE + if (callback (data, EMIG_ARRAY_TOO_LARGE)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_BAD_ARGUMENTS + if (callback (data, EMIG_BAD_ARGUMENTS)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_BAD_ID + if (callback (data, EMIG_BAD_ID)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_DESTROY_REQUEST + if (callback (data, EMIG_DESTROY_REQUEST)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_EXCEPTION + if (callback (data, EMIG_EXCEPTION)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_NO_REPLY + if (callback (data, EMIG_NO_REPLY)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_REMOTE_ERROR + if (callback (data, EMIG_REMOTE_ERROR)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_REPLY_MISMATCH + if (callback (data, EMIG_REPLY_MISMATCH)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_SERVER_DIED + if (callback (data, EMIG_SERVER_DIED)) return; + #endif + /* GNU/Hurd */ + #if defined EMIG_TYPE_ERROR + if (callback (data, EMIG_TYPE_ERROR)) return; + #endif + /* OSF/1 */ + #if defined EMTIMERS + if (callback (data, EMTIMERS)) return; + #endif + /* IRIX */ + #if defined EMUSTRUN + if (callback (data, EMUSTRUN)) return; + #endif + /* Linux, IRIX */ + #if defined ENAVAIL + if (callback (data, ENAVAIL)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix */ + #if defined ENEEDAUTH + if (callback (data, ENEEDAUTH)) return; + #endif + /* IRIX */ + #if defined ENFSREMOTE + if (callback (data, ENFSREMOTE)) return; + #endif + /* Cygwin */ + #if defined ENMFILE + if (callback (data, ENMFILE)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ENOANO && ENOANO != ENOKEY + if (callback (data, ENOANO)) return; + #endif + /* IRIX */ + #if defined ENOATTACH + if (callback (data, ENOATTACH)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, IRIX, Minix */ + #if defined ENOATTR + if (callback (data, ENOATTR)) return; + #endif + /* IRIX */ + #if defined ENOBWD + if (callback (data, ENOBWD)) return; + #endif + /* MirBSD */ + #if defined ENOCOFFEE + if (callback (data, ENOCOFFEE)) return; + #endif + /* Minix */ + #if defined ENOCONN + if (callback (data, ENOCONN)) return; + #endif + /* AIX */ + #if defined ENOCONNECT + if (callback (data, ENOCONNECT)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined ENOCSI + if (callback (data, ENOCSI)) return; + #endif + /* IRIX */ + #if defined ENOEXIST + if (callback (data, ENOEXIST)) return; + #endif + /* IRIX */ + #if defined ENOINTRGROUP + if (callback (data, ENOINTRGROUP)) return; + #endif + /* FreeBSD */ + #if defined ENOIOCTL + if (callback (data, ENOIOCTL)) return; + #endif + /* Linux */ + #if defined ENOKEY + if (callback (data, ENOKEY)) return; + #endif + /* IRIX */ + #if defined ENOLIMFILE + if (callback (data, ENOLIMFILE)) return; + #endif + /* HP-UX */ + #if defined ENOLOAD + if (callback (data, ENOLOAD)) return; + #endif + /* IRIX */ + #if defined ENOLOGIN + if (callback (data, ENOLOGIN)) return; + #endif + /* HP-UX */ + #if defined ENOMATCH + if (callback (data, ENOMATCH)) return; + #endif + /* Linux, OpenBSD, Cygwin */ + #if defined ENOMEDIUM + if (callback (data, ENOMEDIUM)) return; + #endif + /* IRIX */ + #if defined ENOMESSAGE + if (callback (data, ENOMESSAGE)) return; + #endif + /* Linux, HP-UX, IRIX, Solaris, Cygwin */ + #if defined ENONET + if (callback (data, ENONET)) return; + #endif + /* Linux, HP-UX, IRIX, OSF/1, Solaris, Cygwin */ + #if defined ENOPKG + if (callback (data, ENOPKG)) return; + #endif + /* Mac OS X */ + #if defined ENOPOLICY + if (callback (data, ENOPOLICY)) return; + #endif + /* IRIX */ + #if defined ENOPROC + if (callback (data, ENOPROC)) return; + #endif + /* HP-UX */ + #if defined ENOREG + if (callback (data, ENOREG)) return; + #endif + /* IRIX */ + #if defined ENOSERVICE + if (callback (data, ENOSERVICE)) return; + #endif + /* Cygwin */ + #if defined ENOSHARE + if (callback (data, ENOSHARE)) return; + #endif + /* Linux, HP-UX, OSF/1 */ + #if defined ENOSYM + if (callback (data, ENOSYM)) return; + #endif + /* Solaris */ + #if defined ENOTACTIVE + if (callback (data, ENOTACTIVE)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Cygwin */ + #if defined ENOTBLK + if (callback (data, ENOTBLK)) return; + #endif + /* FreeBSD */ + #if defined ENOTCAPABLE + if (callback (data, ENOTCAPABLE)) return; + #endif + /* IRIX */ + #if defined ENOTCONTROLLER + if (callback (data, ENOTCONTROLLER)) return; + #endif + /* IRIX */ + #if defined ENOTENQUEUED + if (callback (data, ENOTENQUEUED)) return; + #endif + /* IRIX */ + #if defined ENOTJOINED + if (callback (data, ENOTJOINED)) return; + #endif + /* Linux, IRIX */ + #if defined ENOTNAM + if (callback (data, ENOTNAM)) return; + #endif + /* AIX, Minix */ + #if defined ENOTREADY + if (callback (data, ENOTREADY)) return; + #endif + /* AIX */ + #if defined ENOTRUST + if (callback (data, ENOTRUST)) return; + #endif + /* IRIX */ + #if defined ENOTSTOPPED + if (callback (data, ENOTSTOPPED)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ENOTUNIQ + if (callback (data, ENOTUNIQ)) return; + #endif + /* HP-UX */ + #if defined ENOUNLD + if (callback (data, ENOUNLD)) return; + #endif + /* HP-UX */ + #if defined ENOUNREG + if (callback (data, ENOUNREG)) return; + #endif + /* Minix */ + #if defined ENOURG + if (callback (data, ENOURG)) return; + #endif + /* native Windows */ + #if defined EOTHER + if (callback (data, EOTHER)) return; + #endif + /* Minix */ + #if defined EPACKSIZE + if (callback (data, EPACKSIZE)) return; + #endif + /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Haiku, Cygwin */ + #if defined EPFNOSUPPORT + if (callback (data, EPFNOSUPPORT)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, IRIX, OSF/1, Minix, Cygwin */ + #if defined EPROCLIM + if (callback (data, EPROCLIM)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, OSF/1, Minix */ + #if defined EPROCUNAVAIL + if (callback (data, EPROCUNAVAIL)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, OSF/1, Minix */ + #if defined EPROGMISMATCH + if (callback (data, EPROGMISMATCH)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, OSF/1, Minix */ + #if defined EPROGUNAVAIL + if (callback (data, EPROGUNAVAIL)) return; + #endif + /* Mac OS X */ + #if defined EPWROFF + if (callback (data, EPWROFF)) return; + #endif + /* Mac OS X */ + #if defined EQFULL + if (callback (data, EQFULL)) return; + #endif + /* HP-UX */ + #if defined ERELOC + if (callback (data, ERELOC)) return; + #endif + /* OSF/1 */ + #if defined ERELOCATED + if (callback (data, ERELOCATED)) return; + #endif + /* FreeBSD */ + #if defined ERELOOKUP + if (callback (data, ERELOOKUP)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EREMCHG + if (callback (data, EREMCHG)) return; + #endif + /* IRIX */ + #if defined EREMDEV + if (callback (data, EREMDEV)) return; + #endif + /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Haiku, Cygwin */ + #if defined EREMOTE + if (callback (data, EREMOTE)) return; + #endif + /* Linux, IRIX */ + #if defined EREMOTEIO + if (callback (data, EREMOTEIO)) return; + #endif + /* Linux, HP-UX */ + #if defined EREMOTERELEASE + if (callback (data, EREMOTERELEASE)) return; + #endif + /* Linux, FreeBSD, AIX, IRIX, OSF/1, Solaris, Minix */ + #if defined ERESTART + if (callback (data, ERESTART)) return; + #endif + /* Linux */ + #if defined ERFKILL + if (callback (data, ERFKILL)) return; + #endif + /* Mac OS X, FreeBSD, NetBSD, OpenBSD, OSF/1, Minix */ + #if defined ERPCMISMATCH + if (callback (data, ERPCMISMATCH)) return; + #endif + /* AIX */ + #if defined ESAD + if (callback (data, ESAD)) return; + #endif + /* Mac OS X */ + #if defined ESHLIBVERS + if (callback (data, ESHLIBVERS)) return; + #endif + /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Haiku, Cygwin */ + #if defined ESHUTDOWN + if (callback (data, ESHUTDOWN)) return; + #endif + /* Haiku */ + #if defined ESIGPARM + if (callback (data, ESIGPARM)) return; + #endif + /* AIX, OSF/1 */ + #if defined ESOFT + if (callback (data, ESOFT)) return; + #endif + /* Linux, HP-UX, IRIX, Solaris, Cygwin */ + #if defined ESRMNT + if (callback (data, ESRMNT)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined ESTRPIPE + if (callback (data, ESTRPIPE)) return; + #endif + /* OSF/1 */ + #if defined ESUCCESS + if (callback (data, ESUCCESS)) return; + #endif + /* AIX */ + #if defined ESYSERROR + if (callback (data, ESYSERROR)) return; + #endif + /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Cygwin */ + #if defined ETOOMANYREFS + if (callback (data, ETOOMANYREFS)) return; + #endif + /* Minix */ + #if defined ETRAPDENIED + if (callback (data, ETRAPDENIED)) return; + #endif + /* Linux, IRIX */ + #if defined EUCLEAN + if (callback (data, EUCLEAN)) return; + #endif + /* Linux, AIX, HP-UX, IRIX, Solaris, Cygwin */ + #if defined EUNATCH + if (callback (data, EUNATCH)) return; + #endif + /* Minix */ + #if defined EURG + if (callback (data, EURG)) return; + #endif + /* Linux, Mac OS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, IRIX, OSF/1, Solaris, Minix, Cygwin */ + #if defined EUSERS + if (callback (data, EUSERS)) return; + #endif + /* OSF/1 */ + #if defined EVERSION + if (callback (data, EVERSION)) return; + #endif + /* IRIX */ + #if defined EWRONGFS + if (callback (data, EWRONGFS)) return; + #endif + /* AIX */ + #if defined EWRPROTECT + if (callback (data, EWRPROTECT)) return; + #endif + /* Linux, IRIX, Solaris, Cygwin */ + #if defined EXFULL + if (callback (data, EXFULL)) return; + #endif +} diff --git a/lib/errno-iter.h b/lib/errno-iter.h new file mode 100644 index 0000000000..97d7fb4ade --- /dev/null +++ b/lib/errno-iter.h @@ -0,0 +1,43 @@ +/* Iteration over all valid error numbers. + Copyright (C) 2025 Free Software Foundation, Inc. + + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2025. */ + +#ifndef _ERRNO_ITER_H +#define _ERRNO_ITER_H + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef int (*errno_iterate_callback_fn) (void *data, int err); + +/* Iterate over the all valid error numbers defined by the system. + The callback is called once for every valid error number, with the + following arguments: + - DATA is the same argument as passed to errno_iterate. + - ERR is the error number. + If the callback returns 0, the iteration continues. If it returns 1, + the iteration terminates prematurely. */ +extern void errno_iterate (errno_iterate_callback_fn callback, void *data); + + +#ifdef __cplusplus +} +#endif + +#endif /* _ERRNO_ITER_H */ diff --git a/modules/errno-iter b/modules/errno-iter new file mode 100644 index 0000000000..ffe24e9b59 --- /dev/null +++ b/modules/errno-iter @@ -0,0 +1,22 @@ +Description: +Iteration over all valid error numbers. + +Files: +lib/errno-iter.h +lib/errno-iter.c + +Depends-on: + +configure.ac: + +Makefile.am: +lib_SOURCES += errno-iter.c + +Include: +"errno-iter.h" + +License: +LGPLv2+ + +Maintainer: +all -- 2.43.0