Raymond Toy pushed to branch issue-446-use-cc-to-get-errno at cmucl / cmucl Commits: 7ef852b9 by Raymond Toy at 2025-11-03T13:33:13-08:00 Use awk script to get errno values Use an awk script in create-errno.sh to find the errno values and print them out. (Script from @cshapiro, slightly modified by me with some comments.) Update errno-template.lisp to remove the `def-unix-error` stuff since we can just use a plain `defconstant`. Don't need `export`s anymore because the UNIX package is guaranteed to export all the correct errno symbols since the export list is determined from the errno list. Regenerate errno-linux.lisp. Update errno-default.lisp to replace `def-unix-error` with `defconstant` since `def-unix-error` no longer exists. - - - - - 4 changed files: - bin/create-errno.sh - bin/errno-default.lisp - bin/errno-linux.lisp - bin/errno-template.lisp Changes: ===================================== bin/create-errno.sh ===================================== @@ -91,9 +91,30 @@ find_errno () # values in different orders. echo '#include <errno.h>' | cpp -dM - | - grep "#define[ \t]\{1,\}E[A-Z0-9]\{1,\}" | - sed 's/#define \(.*\) \(.*\)$/(def-unix-error \1 \2)/' | - sort -nr -k 3 + awk "BEGIN { + max = 0 +} +/* Pattern is '#define Efoo number' */ +/^#define[ \t]+(E[A-Z0-9]+)[ \t]+([0-9]+)/ { + errno[\$3] = \$2 + max = (\$3 > max) ? \$3 : max +} +/* Pattern is '#define Efoo Ealias' */ +/^#define[ \t]+(E[A-Z0-9]+)[ \t]+(E[A-Z0-9]+)/ { + alias[\$3] = \$2 +} +END { + /* Print out each errno and print the alias right after the actual value */ + for (i = 0; i <= max; i++) { + if (i in errno) { + printf \"(defconstant %s %d)\n\", errno[i], i + if (errno[i] in alias) { + printf \"(defconstant %s %s)\n\", alias[errno[i]], errno[i] + } + } + } +}" + } if [ "$UPDATE" = "yes" ]; then ===================================== bin/errno-default.lisp ===================================== @@ -1,94 +1,94 @@ ;;; Default errno values. These are used only if we could not ;;; auto-generate these forms. -(def-unix-error EPERM 1) -(def-unix-error ENOENT 2) -(def-unix-error ESRCH 3) -(def-unix-error EINTR 4) -(def-unix-error EIO 5) -(def-unix-error ENXIO 6) -(def-unix-error E2BIG 7) -(def-unix-error ENOEXEC 8) -(def-unix-error EBADF 9) -(def-unix-error ECHILD 10) -#+bsd(def-unix-error EDEADLK 11) -#-bsd(def-unix-error EAGAIN 11 #-linux) -(def-unix-error ENOMEM 12) -(def-unix-error EACCES 13) -(def-unix-error EFAULT 14) -(def-unix-error ENOTBLK 15) -(def-unix-error EBUSY 16) -(def-unix-error EEXIST 17) -(def-unix-error EXDEV 18) -(def-unix-error ENODEV 19) -(def-unix-error ENOTDIR 20) -(def-unix-error EISDIR 21) -(def-unix-error EINVAL 22) -(def-unix-error ENFILE 23) -(def-unix-error EMFILE 24) -(def-unix-error ENOTTY 25) -(def-unix-error ETXTBSY 26) -(def-unix-error EFBIG 27) -(def-unix-error ENOSPC 28) -(def-unix-error ESPIPE 29) -(def-unix-error EROFS 30) -(def-unix-error EMLINK 31) -(def-unix-error EPIPE 32) +(defconstant EPERM 1) +(defconstant ENOENT 2) +(defconstant ESRCH 3) +(defconstant EINTR 4) +(defconstant EIO 5) +(defconstant ENXIO 6) +(defconstant E2BIG 7) +(defconstant ENOEXEC 8) +(defconstant EBADF 9) +(defconstant ECHILD 10) +#+bsd(defconstant EDEADLK 11) +#-bsd(defconstant EAGAIN 11 #-linux) +(defconstant ENOMEM 12) +(defconstant EACCES 13) +(defconstant EFAULT 14) +(defconstant ENOTBLK 15) +(defconstant EBUSY 16) +(defconstant EEXIST 17) +(defconstant EXDEV 18) +(defconstant ENODEV 19) +(defconstant ENOTDIR 20) +(defconstant EISDIR 21) +(defconstant EINVAL 22) +(defconstant ENFILE 23) +(defconstant EMFILE 24) +(defconstant ENOTTY 25) +(defconstant ETXTBSY 26) +(defconstant EFBIG 27) +(defconstant ENOSPC 28) +(defconstant ESPIPE 29) +(defconstant EROFS 30) +(defconstant EMLINK 31) +(defconstant EPIPE 32) ;;; ;;; Math -(def-unix-error EDOM 33) -(def-unix-error ERANGE 34 #-linux) +(defconstant EDOM 33) +(defconstant ERANGE 34 #-linux) ;;; non-blocking and interrupt i/o -(def-unix-error EWOULDBLOCK 35) -#-bsd(def-unix-error EDEADLK 35 _N"Operation would block") ; Ditto -#+bsd(def-unix-error EAGAIN 35) -(def-unix-error EINPROGRESS 36) -(def-unix-error EALREADY 37) +(defconstant EWOULDBLOCK 35) +#-bsd(defconstant EDEADLK 35 _N"Operation would block") ; Ditto +#+bsd(defconstant EAGAIN 35) +(defconstant EINPROGRESS 36) +(defconstant EALREADY 37) ;;; ;;; ipc/network software -(def-unix-error ENOTSOCK 38) -(def-unix-error EDESTADDRREQ 39) -(def-unix-error EMSGSIZE 40) -(def-unix-error EPROTOTYPE 41) -(def-unix-error ENOPROTOOPT 42) -(def-unix-error EPROTONOSUPPORT 43) -(def-unix-error ESOCKTNOSUPPORT 44) -(def-unix-error EOPNOTSUPP 45) -(def-unix-error EPFNOSUPPORT 46) -(def-unix-error EAFNOSUPPORT 47) -(def-unix-error EADDRINUSE 48) -(def-unix-error EADDRNOTAVAIL 49) +(defconstant ENOTSOCK 38) +(defconstant EDESTADDRREQ 39) +(defconstant EMSGSIZE 40) +(defconstant EPROTOTYPE 41) +(defconstant ENOPROTOOPT 42) +(defconstant EPROTONOSUPPORT 43) +(defconstant ESOCKTNOSUPPORT 44) +(defconstant EOPNOTSUPP 45) +(defconstant EPFNOSUPPORT 46) +(defconstant EAFNOSUPPORT 47) +(defconstant EADDRINUSE 48) +(defconstant EADDRNOTAVAIL 49) ;;; ;;; operational errors -(def-unix-error ENETDOWN 50) -(def-unix-error ENETUNREACH 51) -(def-unix-error ENETRESET 52) -(def-unix-error ECONNABORTED 53) -(def-unix-error ECONNRESET 54) -(def-unix-error ENOBUFS 55) -(def-unix-error EISCONN 56) -(def-unix-error ENOTCONN 57) -(def-unix-error ESHUTDOWN 58) -(def-unix-error ETOOMANYREFS 59) -(def-unix-error ETIMEDOUT 60) -(def-unix-error ECONNREFUSED 61) +(defconstant ENETDOWN 50) +(defconstant ENETUNREACH 51) +(defconstant ENETRESET 52) +(defconstant ECONNABORTED 53) +(defconstant ECONNRESET 54) +(defconstant ENOBUFS 55) +(defconstant EISCONN 56) +(defconstant ENOTCONN 57) +(defconstant ESHUTDOWN 58) +(defconstant ETOOMANYREFS 59) +(defconstant ETIMEDOUT 60) +(defconstant ECONNREFUSED 61) ;;; -(def-unix-error ELOOP 62) -(def-unix-error ENAMETOOLONG 63) +(defconstant ELOOP 62) +(defconstant ENAMETOOLONG 63) ;;; -(def-unix-error EHOSTDOWN 64) -(def-unix-error EHOSTUNREACH 65) -(def-unix-error ENOTEMPTY 66) +(defconstant EHOSTDOWN 64) +(defconstant EHOSTUNREACH 65) +(defconstant ENOTEMPTY 66) ;;; ;;; quotas & resource -(def-unix-error EPROCLIM 67) -(def-unix-error EUSERS 68) -(def-unix-error EDQUOT 69) +(defconstant EPROCLIM 67) +(defconstant EUSERS 68) +(defconstant EDQUOT 69) ;;; ;;; CMU RFS -(def-unix-error ELOCAL 126) -(def-unix-error EREMOTE 127) +(defconstant ELOCAL 126) +(defconstant EREMOTE 127) ;;; ;;; VICE -(def-unix-error EVICEERR 70) -(def-unix-error EVICEOP 71) +(defconstant EVICEERR 70) +(defconstant EVICEOP 71) ===================================== bin/errno-linux.lisp ===================================== @@ -1,134 +1,134 @@ -(def-unix-error EHWPOISON 133) -(def-unix-error ERFKILL 132) -(def-unix-error ENOTRECOVERABLE 131) -(def-unix-error EOWNERDEAD 130) -(def-unix-error EKEYREJECTED 129) -(def-unix-error EKEYREVOKED 128) -(def-unix-error EKEYEXPIRED 127) -(def-unix-error ENOKEY 126) -(def-unix-error ECANCELED 125) -(def-unix-error EMEDIUMTYPE 124) -(def-unix-error ENOMEDIUM 123) -(def-unix-error EDQUOT 122) -(def-unix-error EREMOTEIO 121) -(def-unix-error EISNAM 120) -(def-unix-error ENAVAIL 119) -(def-unix-error ENOTNAM 118) -(def-unix-error EUCLEAN 117) -(def-unix-error ESTALE 116) -(def-unix-error EINPROGRESS 115) -(def-unix-error EALREADY 114) -(def-unix-error EHOSTUNREACH 113) -(def-unix-error EHOSTDOWN 112) -(def-unix-error ECONNREFUSED 111) -(def-unix-error ETIMEDOUT 110) -(def-unix-error ETOOMANYREFS 109) -(def-unix-error ESHUTDOWN 108) -(def-unix-error ENOTCONN 107) -(def-unix-error EISCONN 106) -(def-unix-error ENOBUFS 105) -(def-unix-error ECONNRESET 104) -(def-unix-error ECONNABORTED 103) -(def-unix-error ENETRESET 102) -(def-unix-error ENETUNREACH 101) -(def-unix-error ENETDOWN 100) -(def-unix-error EADDRNOTAVAIL 99) -(def-unix-error EADDRINUSE 98) -(def-unix-error EAFNOSUPPORT 97) -(def-unix-error EPFNOSUPPORT 96) -(def-unix-error EOPNOTSUPP 95) -(def-unix-error ESOCKTNOSUPPORT 94) -(def-unix-error EPROTONOSUPPORT 93) -(def-unix-error ENOPROTOOPT 92) -(def-unix-error EPROTOTYPE 91) -(def-unix-error EMSGSIZE 90) -(def-unix-error EDESTADDRREQ 89) -(def-unix-error ENOTSOCK 88) -(def-unix-error EUSERS 87) -(def-unix-error ESTRPIPE 86) -(def-unix-error ERESTART 85) -(def-unix-error EILSEQ 84) -(def-unix-error ELIBEXEC 83) -(def-unix-error ELIBMAX 82) -(def-unix-error ELIBSCN 81) -(def-unix-error ELIBBAD 80) -(def-unix-error ELIBACC 79) -(def-unix-error EREMCHG 78) -(def-unix-error EBADFD 77) -(def-unix-error ENOTUNIQ 76) -(def-unix-error EOVERFLOW 75) -(def-unix-error EBADMSG 74) -(def-unix-error EDOTDOT 73) -(def-unix-error EMULTIHOP 72) -(def-unix-error EPROTO 71) -(def-unix-error ECOMM 70) -(def-unix-error ESRMNT 69) -(def-unix-error EADV 68) -(def-unix-error ENOLINK 67) -(def-unix-error EREMOTE 66) -(def-unix-error ENOPKG 65) -(def-unix-error ENONET 64) -(def-unix-error ENOSR 63) -(def-unix-error ETIME 62) -(def-unix-error ENODATA 61) -(def-unix-error ENOSTR 60) -(def-unix-error EBFONT 59) -(def-unix-error EBADSLT 57) -(def-unix-error EBADRQC 56) -(def-unix-error ENOANO 55) -(def-unix-error EXFULL 54) -(def-unix-error EBADR 53) -(def-unix-error EBADE 52) -(def-unix-error EL2HLT 51) -(def-unix-error ENOCSI 50) -(def-unix-error EUNATCH 49) -(def-unix-error ELNRNG 48) -(def-unix-error EL3RST 47) -(def-unix-error EL3HLT 46) -(def-unix-error EL2NSYNC 45) -(def-unix-error ECHRNG 44) -(def-unix-error EIDRM 43) -(def-unix-error ENOMSG 42) -(def-unix-error ELOOP 40) -(def-unix-error ENOTEMPTY 39) -(def-unix-error ENOSYS 38) -(def-unix-error ENOLCK 37) -(def-unix-error ENAMETOOLONG 36) -(def-unix-error EDEADLK 35) -(def-unix-error ERANGE 34) -(def-unix-error EDOM 33) -(def-unix-error EPIPE 32) -(def-unix-error EMLINK 31) -(def-unix-error EROFS 30) -(def-unix-error ESPIPE 29) -(def-unix-error ENOSPC 28) -(def-unix-error EFBIG 27) -(def-unix-error ETXTBSY 26) -(def-unix-error ENOTTY 25) -(def-unix-error EMFILE 24) -(def-unix-error ENFILE 23) -(def-unix-error EINVAL 22) -(def-unix-error EISDIR 21) -(def-unix-error ENOTDIR 20) -(def-unix-error ENODEV 19) -(def-unix-error EXDEV 18) -(def-unix-error EEXIST 17) -(def-unix-error EBUSY 16) -(def-unix-error ENOTBLK 15) -(def-unix-error EFAULT 14) -(def-unix-error EACCES 13) -(def-unix-error ENOMEM 12) -(def-unix-error EAGAIN 11) -(def-unix-error ECHILD 10) -(def-unix-error EBADF 9) -(def-unix-error ENOEXEC 8) -(def-unix-error E2BIG 7) -(def-unix-error ENXIO 6) -(def-unix-error EIO 5) -(def-unix-error EINTR 4) -(def-unix-error ESRCH 3) -(def-unix-error ENOENT 2) -(def-unix-error EPERM 1) -(def-unix-error EWOULDBLOCK EAGAIN) -(def-unix-error ENOTSUP EOPNOTSUPP) -(def-unix-error EDEADLOCK EDEADLK) +(defconstant EPERM 1) +(defconstant ENOENT 2) +(defconstant ESRCH 3) +(defconstant EINTR 4) +(defconstant EIO 5) +(defconstant ENXIO 6) +(defconstant E2BIG 7) +(defconstant ENOEXEC 8) +(defconstant EBADF 9) +(defconstant ECHILD 10) +(defconstant EAGAIN 11) +(defconstant EWOULDBLOCK EAGAIN) +(defconstant ENOMEM 12) +(defconstant EACCES 13) +(defconstant EFAULT 14) +(defconstant ENOTBLK 15) +(defconstant EBUSY 16) +(defconstant EEXIST 17) +(defconstant EXDEV 18) +(defconstant ENODEV 19) +(defconstant ENOTDIR 20) +(defconstant EISDIR 21) +(defconstant EINVAL 22) +(defconstant ENFILE 23) +(defconstant EMFILE 24) +(defconstant ENOTTY 25) +(defconstant ETXTBSY 26) +(defconstant EFBIG 27) +(defconstant ENOSPC 28) +(defconstant ESPIPE 29) +(defconstant EROFS 30) +(defconstant EMLINK 31) +(defconstant EPIPE 32) +(defconstant EDOM 33) +(defconstant ERANGE 34) +(defconstant EDEADLK 35) +(defconstant EDEADLOCK EDEADLK) +(defconstant ENAMETOOLONG 36) +(defconstant ENOLCK 37) +(defconstant ENOSYS 38) +(defconstant ENOTEMPTY 39) +(defconstant ELOOP 40) +(defconstant ENOMSG 42) +(defconstant EIDRM 43) +(defconstant ECHRNG 44) +(defconstant EL2NSYNC 45) +(defconstant EL3HLT 46) +(defconstant EL3RST 47) +(defconstant ELNRNG 48) +(defconstant EUNATCH 49) +(defconstant ENOCSI 50) +(defconstant EL2HLT 51) +(defconstant EBADE 52) +(defconstant EBADR 53) +(defconstant EXFULL 54) +(defconstant ENOANO 55) +(defconstant EBADRQC 56) +(defconstant EBADSLT 57) +(defconstant EBFONT 59) +(defconstant ENOSTR 60) +(defconstant ENODATA 61) +(defconstant ETIME 62) +(defconstant ENOSR 63) +(defconstant ENONET 64) +(defconstant ENOPKG 65) +(defconstant EREMOTE 66) +(defconstant ENOLINK 67) +(defconstant EADV 68) +(defconstant ESRMNT 69) +(defconstant ECOMM 70) +(defconstant EPROTO 71) +(defconstant EMULTIHOP 72) +(defconstant EDOTDOT 73) +(defconstant EBADMSG 74) +(defconstant EOVERFLOW 75) +(defconstant ENOTUNIQ 76) +(defconstant EBADFD 77) +(defconstant EREMCHG 78) +(defconstant ELIBACC 79) +(defconstant ELIBBAD 80) +(defconstant ELIBSCN 81) +(defconstant ELIBMAX 82) +(defconstant ELIBEXEC 83) +(defconstant EILSEQ 84) +(defconstant ERESTART 85) +(defconstant ESTRPIPE 86) +(defconstant EUSERS 87) +(defconstant ENOTSOCK 88) +(defconstant EDESTADDRREQ 89) +(defconstant EMSGSIZE 90) +(defconstant EPROTOTYPE 91) +(defconstant ENOPROTOOPT 92) +(defconstant EPROTONOSUPPORT 93) +(defconstant ESOCKTNOSUPPORT 94) +(defconstant EOPNOTSUPP 95) +(defconstant ENOTSUP EOPNOTSUPP) +(defconstant EPFNOSUPPORT 96) +(defconstant EAFNOSUPPORT 97) +(defconstant EADDRINUSE 98) +(defconstant EADDRNOTAVAIL 99) +(defconstant ENETDOWN 100) +(defconstant ENETUNREACH 101) +(defconstant ENETRESET 102) +(defconstant ECONNABORTED 103) +(defconstant ECONNRESET 104) +(defconstant ENOBUFS 105) +(defconstant EISCONN 106) +(defconstant ENOTCONN 107) +(defconstant ESHUTDOWN 108) +(defconstant ETOOMANYREFS 109) +(defconstant ETIMEDOUT 110) +(defconstant ECONNREFUSED 111) +(defconstant EHOSTDOWN 112) +(defconstant EHOSTUNREACH 113) +(defconstant EALREADY 114) +(defconstant EINPROGRESS 115) +(defconstant ESTALE 116) +(defconstant EUCLEAN 117) +(defconstant ENOTNAM 118) +(defconstant ENAVAIL 119) +(defconstant EISNAM 120) +(defconstant EREMOTEIO 121) +(defconstant EDQUOT 122) +(defconstant ENOMEDIUM 123) +(defconstant EMEDIUMTYPE 124) +(defconstant ECANCELED 125) +(defconstant ENOKEY 126) +(defconstant EKEYEXPIRED 127) +(defconstant EKEYREVOKED 128) +(defconstant EKEYREJECTED 129) +(defconstant EOWNERDEAD 130) +(defconstant ENOTRECOVERABLE 131) +(defconstant ERFKILL 132) +(defconstant EHWPOISON 133) ===================================== bin/errno-template.lisp ===================================== @@ -9,27 +9,16 @@ ;;; ;;; ********************************************************************** ;;; -;;; This file contains the UNIX low-level support, just enough to run -;;; CMUCL. +;;; This file contains the definition of UNIX errno values from errno.h. ;;; (in-package "UNIX") (intl:textdomain "cmucl-unix") ;;;; Errno stuff. -(eval-when (compile eval) - -(defparameter *compiler-unix-errors* nil) - -(defmacro def-unix-error (name number) - `(progn - (defconstant ,name ,number) - (export ',name))) - -) ;eval-when - ;;; ;;; From <errno.h> ;;; -(def-unix-error ESUCCESS 0) - +(defconstant ESUCCESS 0) +;;; The following values are autogenerated via bin/create-errno.sh +;;; DO NOT EDIT this file. Update the templates instead. View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7ef852b91ad196b73ad1bf5f... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7ef852b91ad196b73ad1bf5f... You're receiving this email because of your account on gitlab.common-lisp.net.