
Raymond Toy pushed to branch issue-386-generate-def-unix-error at cmucl / cmucl Commits: 594cf215 by Raymond Toy at 2025-03-28T08:12:30-07:00 Address review comments We now have separate files named bin/errno-<os>.lisp that contains the def-unix-error forms for the OSes that support auto-generating them. These files are checked in. (This commit only has the definitions for Linux.) Update bin/create-errno.sh add a -U option to generate the bin/errno-<os>.lisp. When create-errno.sh generates the final src/code/errno.lisp file, we also check that the checked-in bin/errno-<os>.lisp file matches what we find in the header files. The bin/errno-template.lisp file is simplified by moving the default `def-unix-error` forms to the new file bin/errno-default.lisp. Skip CI this until we add the errno files for darwin and solaris. [SKIP-CI] - - - - - 4 changed files: - bin/create-errno.sh - + bin/errno-default.lisp - + bin/errno-linux.lisp - bin/errno-template.lisp Changes: ===================================== bin/create-errno.sh ===================================== @@ -11,6 +11,7 @@ usage () create-erno.sh [-h?DS] -h This help -? This help + -U Update the errno file -D Do not auto-generate; use default -S Show the resulting generated file; the file is still created. @@ -21,61 +22,73 @@ EOF exit 0 } -while getopts "h?DS" arg +while getopts "h?DSU" arg do case $arg in h) usage ;; \?) usage ;; D) DEFAULT=yes ;; S) SHOW=yes ;; + U) UPDATE=yes ;; esac done -# Where the output should go. +# Output file containing the final errno defintions OUTPUT="src/code/errno.lisp" +# Default file containing errno definitions. +ERRNO_FILE="bin/errno-default.lisp" + # Template file containing the default def-unix-error forms and other # support code. TEMPLATE="bin/errno-template.lisp" -# Set ERRNO_FILES to the files where we can find errno definitions. +# Set ERRNO_HEADERS to the files where we can find errno definitions. if [ -z "$DEFAULT" ]; then case $(uname -s) in - Linux) ERRNO_FILES=/usr/include/asm-generic/errno*.h + Linux) ERRNO_HEADERS=/usr/include/asm-generic/errno*.h + ERRNO_FILE="bin/errno-linux.lisp" ;; - Darwin) ERRNO_FILES=/usr/include/sys/errno.h + Darwin) ERRNO_HEADERS=/usr/include/sys/errno.h + ERRNO_FILE="bin/errno-darwin.lisp" ;; - SunOS) ERRNO_FILES=/usr/include/sys/errno.h + SunOS) ERRNO_HEADERS=/usr/include/sys/errno.h + ERRNO_FILE="bin/errno-solaris.lisp" ;; + *) # The default case where we use the defaults. But also disable updating. + UPDATE="" + ;; esac fi -if [ -z "$ERRNO_FILES" ]; then - # Copy the main errno template to the output. The template is a lisp - # file so we can read and modify it more easily. - cat "$TEMPLATE" > $OUTPUT -else - # We can autogenerate the def-unix-error forms. Copy just the - # initial part of the template, up to the first def-unix-error - # form. - { - sed '/^(def-unix-error ESUCCESS/q' "$TEMPLATE" - cat <<EOF - -;; Autogenerated def-unix-error forms -EOF - - # Create appropriate DEF-UNIX-ERROR forms by reading header files - # containing the C definitions. +if [ -n "$DEFAULT" ]; then + UPDATE="" +fi + +find_errno () +{ + # Create appropriate DEF-UNIX-ERROR forms by reading header files + # containing the C definitions. - awk -f bin/create-def-unix-error.awk ${ERRNO_FILES} + awk -f bin/create-def-unix-error.awk ${ERRNO_HEADERS} +} - # The tail was also copied from code/unix.lisp. It's needed to tell - # Lisp about the errno values. - sed '1,/^;;; End of default/d' "$TEMPLATE" - } > $OUTPUT +if [ "$UPDATE" = "yes" ]; then + find_errno > "$ERRNO_FILE" + exit 0 fi +if [ -z "$DEFAULT" -a -n "$ERRNO_FILE" ]; then + # First check that the errno definitions haven't changed. If they + # have, exit with an error. + + (find_errno | diff -u "$ERRNO_FILE" - ) || exit 1 +fi + +# Create the src/code/errno.lisp file from the template and the +# OS-specific errno values (or the default). +cat "$TEMPLATE" "$ERRNO_FILE" > $OUTPUT + # If -S option given, cat the output file to stdout if [ -n "$SHOW" ]; then cat $OUTPUT ===================================== bin/errno-default.lisp ===================================== @@ -0,0 +1,94 @@ +;;; Default errno values. These are used only if we could not +;;; auto-generate these forms. +(def-unix-error EPERM 1 _N"Operation not permitted") +(def-unix-error ENOENT 2 _N"No such file or directory") +(def-unix-error ESRCH 3 _N"No such process") +(def-unix-error EINTR 4 _N"Interrupted system call") +(def-unix-error EIO 5 _N"I/O error") +(def-unix-error ENXIO 6 _N"Device not configured") +(def-unix-error E2BIG 7 _N"Arg list too long") +(def-unix-error ENOEXEC 8 _N"Exec format error") +(def-unix-error EBADF 9 _N"Bad file descriptor") +(def-unix-error ECHILD 10 _N"No child process") +#+bsd(def-unix-error EDEADLK 11 _N"Resource deadlock avoided") +#-bsd(def-unix-error EAGAIN 11 #-linux _N"No more processes" #+linux _N"Try again") +(def-unix-error ENOMEM 12 _N"Out of memory") +(def-unix-error EACCES 13 _N"Permission denied") +(def-unix-error EFAULT 14 _N"Bad address") +(def-unix-error ENOTBLK 15 _N"Block device required") +(def-unix-error EBUSY 16 _N"Device or resource busy") +(def-unix-error EEXIST 17 _N"File exists") +(def-unix-error EXDEV 18 _N"Cross-device link") +(def-unix-error ENODEV 19 _N"No such device") +(def-unix-error ENOTDIR 20 _N"Not a director") +(def-unix-error EISDIR 21 _N"Is a directory") +(def-unix-error EINVAL 22 _N"Invalid argument") +(def-unix-error ENFILE 23 _N"File table overflow") +(def-unix-error EMFILE 24 _N"Too many open files") +(def-unix-error ENOTTY 25 _N"Inappropriate ioctl for device") +(def-unix-error ETXTBSY 26 _N"Text file busy") +(def-unix-error EFBIG 27 _N"File too large") +(def-unix-error ENOSPC 28 _N"No space left on device") +(def-unix-error ESPIPE 29 _N"Illegal seek") +(def-unix-error EROFS 30 _N"Read-only file system") +(def-unix-error EMLINK 31 _N"Too many links") +(def-unix-error EPIPE 32 _N"Broken pipe") +;;; +;;; Math +(def-unix-error EDOM 33 _N"Numerical argument out of domain") +(def-unix-error ERANGE 34 #-linux _N"Result too large" #+linux _N"Math result not representable") + +;;; non-blocking and interrupt i/o +(def-unix-error EWOULDBLOCK 35 _N"Operation would block") +#-bsd(def-unix-error EDEADLK 35 _N"Operation would block") ; Ditto +#+bsd(def-unix-error EAGAIN 35 _N"Resource temporarily unavailable") +(def-unix-error EINPROGRESS 36 _N"Operation now in progress") +(def-unix-error EALREADY 37 _N"Operation already in progress") +;;; +;;; ipc/network software +(def-unix-error ENOTSOCK 38 _N"Socket operation on non-socket") +(def-unix-error EDESTADDRREQ 39 _N"Destination address required") +(def-unix-error EMSGSIZE 40 _N"Message too long") +(def-unix-error EPROTOTYPE 41 _N"Protocol wrong type for socket") +(def-unix-error ENOPROTOOPT 42 _N"Protocol not available") +(def-unix-error EPROTONOSUPPORT 43 _N"Protocol not supported") +(def-unix-error ESOCKTNOSUPPORT 44 _N"Socket type not supported") +(def-unix-error EOPNOTSUPP 45 _N"Operation not supported on socket") +(def-unix-error EPFNOSUPPORT 46 _N"Protocol family not supported") +(def-unix-error EAFNOSUPPORT 47 _N"Address family not supported by protocol family") +(def-unix-error EADDRINUSE 48 _N"Address already in use") +(def-unix-error EADDRNOTAVAIL 49 _N"Can't assign requested address") +;;; +;;; operational errors +(def-unix-error ENETDOWN 50 _N"Network is down") +(def-unix-error ENETUNREACH 51 _N"Network is unreachable") +(def-unix-error ENETRESET 52 _N"Network dropped connection on reset") +(def-unix-error ECONNABORTED 53 _N"Software caused connection abort") +(def-unix-error ECONNRESET 54 _N"Connection reset by peer") +(def-unix-error ENOBUFS 55 _N"No buffer space available") +(def-unix-error EISCONN 56 _N"Socket is already connected") +(def-unix-error ENOTCONN 57 _N"Socket is not connected") +(def-unix-error ESHUTDOWN 58 _N"Can't send after socket shutdown") +(def-unix-error ETOOMANYREFS 59 _N"Too many references: can't splice") +(def-unix-error ETIMEDOUT 60 _N"Connection timed out") +(def-unix-error ECONNREFUSED 61 _N"Connection refused") +;;; +(def-unix-error ELOOP 62 _N"Too many levels of symbolic links") +(def-unix-error ENAMETOOLONG 63 _N"File name too long") +;;; +(def-unix-error EHOSTDOWN 64 _N"Host is down") +(def-unix-error EHOSTUNREACH 65 _N"No route to host") +(def-unix-error ENOTEMPTY 66 _N"Directory not empty") +;;; +;;; quotas & resource +(def-unix-error EPROCLIM 67 _N"Too many processes") +(def-unix-error EUSERS 68 _N"Too many users") +(def-unix-error EDQUOT 69 _N"Disc quota exceeded") +;;; +;;; CMU RFS +(def-unix-error ELOCAL 126 _N"namei should continue locally") +(def-unix-error EREMOTE 127 _N"namei was handled remotely") +;;; +;;; VICE +(def-unix-error EVICEERR 70 _N"Remote file system error _N") +(def-unix-error EVICEOP 71 _N"syscall was handled by Vice") ===================================== bin/errno-linux.lisp ===================================== @@ -0,0 +1,133 @@ +(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) +(def-unix-error EAGAIN 11) +(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) +(def-unix-error EDOM 33) +(def-unix-error ERANGE 34) +(def-unix-error EDEADLK 35) +(def-unix-error ENAMETOOLONG 36) +(def-unix-error ENOLCK 37) +(def-unix-error ENOSYS 38) +(def-unix-error ENOTEMPTY 39) +(def-unix-error ELOOP 40) +(def-unix-error EWOULDBLOCK EAGAIN) +(def-unix-error ENOMSG 42) +(def-unix-error EIDRM 43) +(def-unix-error ECHRNG 44) +(def-unix-error EL2NSYNC 45) +(def-unix-error EL3HLT 46) +(def-unix-error EL3RST 47) +(def-unix-error ELNRNG 48) +(def-unix-error EUNATCH 49) +(def-unix-error ENOCSI 50) +(def-unix-error EL2HLT 51) +(def-unix-error EBADE 52) +(def-unix-error EBADR 53) +(def-unix-error EXFULL 54) +(def-unix-error ENOANO 55) +(def-unix-error EBADRQC 56) +(def-unix-error EBADSLT 57) +(def-unix-error EDEADLOCK EDEADLK) +(def-unix-error EBFONT 59) +(def-unix-error ENOSTR 60) +(def-unix-error ENODATA 61) +(def-unix-error ETIME 62) +(def-unix-error ENOSR 63) +(def-unix-error ENONET 64) +(def-unix-error ENOPKG 65) +(def-unix-error EREMOTE 66) +(def-unix-error ENOLINK 67) +(def-unix-error EADV 68) +(def-unix-error ESRMNT 69) +(def-unix-error ECOMM 70) +(def-unix-error EPROTO 71) +(def-unix-error EMULTIHOP 72) +(def-unix-error EDOTDOT 73) +(def-unix-error EBADMSG 74) +(def-unix-error EOVERFLOW 75) +(def-unix-error ENOTUNIQ 76) +(def-unix-error EBADFD 77) +(def-unix-error EREMCHG 78) +(def-unix-error ELIBACC 79) +(def-unix-error ELIBBAD 80) +(def-unix-error ELIBSCN 81) +(def-unix-error ELIBMAX 82) +(def-unix-error ELIBEXEC 83) +(def-unix-error EILSEQ 84) +(def-unix-error ERESTART 85) +(def-unix-error ESTRPIPE 86) +(def-unix-error EUSERS 87) +(def-unix-error ENOTSOCK 88) +(def-unix-error EDESTADDRREQ 89) +(def-unix-error EMSGSIZE 90) +(def-unix-error EPROTOTYPE 91) +(def-unix-error ENOPROTOOPT 92) +(def-unix-error EPROTONOSUPPORT 93) +(def-unix-error ESOCKTNOSUPPORT 94) +(def-unix-error EOPNOTSUPP 95) +(def-unix-error EPFNOSUPPORT 96) +(def-unix-error EAFNOSUPPORT 97) +(def-unix-error EADDRINUSE 98) +(def-unix-error EADDRNOTAVAIL 99) +(def-unix-error ENETDOWN 100) +(def-unix-error ENETUNREACH 101) +(def-unix-error ENETRESET 102) +(def-unix-error ECONNABORTED 103) +(def-unix-error ECONNRESET 104) +(def-unix-error ENOBUFS 105) +(def-unix-error EISCONN 106) +(def-unix-error ENOTCONN 107) +(def-unix-error ESHUTDOWN 108) +(def-unix-error ETOOMANYREFS 109) +(def-unix-error ETIMEDOUT 110) +(def-unix-error ECONNREFUSED 111) +(def-unix-error EHOSTDOWN 112) +(def-unix-error EHOSTUNREACH 113) +(def-unix-error EALREADY 114) +(def-unix-error EINPROGRESS 115) +(def-unix-error ESTALE 116) +(def-unix-error EUCLEAN 117) +(def-unix-error ENOTNAM 118) +(def-unix-error ENAVAIL 119) +(def-unix-error EISNAM 120) +(def-unix-error EREMOTEIO 121) +(def-unix-error EDQUOT 122) +(def-unix-error ENOMEDIUM 123) +(def-unix-error EMEDIUMTYPE 124) +(def-unix-error ECANCELED 125) +(def-unix-error ENOKEY 126) +(def-unix-error EKEYEXPIRED 127) +(def-unix-error EKEYREVOKED 128) +(def-unix-error EKEYREJECTED 129) +(def-unix-error EOWNERDEAD 130) +(def-unix-error ENOTRECOVERABLE 131) +(def-unix-error ERFKILL 132) +(def-unix-error EHWPOISON 133) ===================================== bin/errno-template.lisp ===================================== @@ -34,104 +34,3 @@ ;;; (def-unix-error ESUCCESS 0 _N"Successful") -;;; Do NOT modify the ESUCCESS form above. bin/create-errno.sh -;;; depends on it. - -;;; Default errno values. These are used only if we could not -;;; auto-generate these forms. -(def-unix-error EPERM 1 _N"Operation not permitted") -(def-unix-error ENOENT 2 _N"No such file or directory") -(def-unix-error ESRCH 3 _N"No such process") -(def-unix-error EINTR 4 _N"Interrupted system call") -(def-unix-error EIO 5 _N"I/O error") -(def-unix-error ENXIO 6 _N"Device not configured") -(def-unix-error E2BIG 7 _N"Arg list too long") -(def-unix-error ENOEXEC 8 _N"Exec format error") -(def-unix-error EBADF 9 _N"Bad file descriptor") -(def-unix-error ECHILD 10 _N"No child process") -#+bsd(def-unix-error EDEADLK 11 _N"Resource deadlock avoided") -#-bsd(def-unix-error EAGAIN 11 #-linux _N"No more processes" #+linux _N"Try again") -(def-unix-error ENOMEM 12 _N"Out of memory") -(def-unix-error EACCES 13 _N"Permission denied") -(def-unix-error EFAULT 14 _N"Bad address") -(def-unix-error ENOTBLK 15 _N"Block device required") -(def-unix-error EBUSY 16 _N"Device or resource busy") -(def-unix-error EEXIST 17 _N"File exists") -(def-unix-error EXDEV 18 _N"Cross-device link") -(def-unix-error ENODEV 19 _N"No such device") -(def-unix-error ENOTDIR 20 _N"Not a director") -(def-unix-error EISDIR 21 _N"Is a directory") -(def-unix-error EINVAL 22 _N"Invalid argument") -(def-unix-error ENFILE 23 _N"File table overflow") -(def-unix-error EMFILE 24 _N"Too many open files") -(def-unix-error ENOTTY 25 _N"Inappropriate ioctl for device") -(def-unix-error ETXTBSY 26 _N"Text file busy") -(def-unix-error EFBIG 27 _N"File too large") -(def-unix-error ENOSPC 28 _N"No space left on device") -(def-unix-error ESPIPE 29 _N"Illegal seek") -(def-unix-error EROFS 30 _N"Read-only file system") -(def-unix-error EMLINK 31 _N"Too many links") -(def-unix-error EPIPE 32 _N"Broken pipe") -;;; -;;; Math -(def-unix-error EDOM 33 _N"Numerical argument out of domain") -(def-unix-error ERANGE 34 #-linux _N"Result too large" #+linux _N"Math result not representable") - -;;; non-blocking and interrupt i/o -(def-unix-error EWOULDBLOCK 35 _N"Operation would block") -#-bsd(def-unix-error EDEADLK 35 _N"Operation would block") ; Ditto -#+bsd(def-unix-error EAGAIN 35 _N"Resource temporarily unavailable") -(def-unix-error EINPROGRESS 36 _N"Operation now in progress") -(def-unix-error EALREADY 37 _N"Operation already in progress") -;;; -;;; ipc/network software -(def-unix-error ENOTSOCK 38 _N"Socket operation on non-socket") -(def-unix-error EDESTADDRREQ 39 _N"Destination address required") -(def-unix-error EMSGSIZE 40 _N"Message too long") -(def-unix-error EPROTOTYPE 41 _N"Protocol wrong type for socket") -(def-unix-error ENOPROTOOPT 42 _N"Protocol not available") -(def-unix-error EPROTONOSUPPORT 43 _N"Protocol not supported") -(def-unix-error ESOCKTNOSUPPORT 44 _N"Socket type not supported") -(def-unix-error EOPNOTSUPP 45 _N"Operation not supported on socket") -(def-unix-error EPFNOSUPPORT 46 _N"Protocol family not supported") -(def-unix-error EAFNOSUPPORT 47 _N"Address family not supported by protocol family") -(def-unix-error EADDRINUSE 48 _N"Address already in use") -(def-unix-error EADDRNOTAVAIL 49 _N"Can't assign requested address") -;;; -;;; operational errors -(def-unix-error ENETDOWN 50 _N"Network is down") -(def-unix-error ENETUNREACH 51 _N"Network is unreachable") -(def-unix-error ENETRESET 52 _N"Network dropped connection on reset") -(def-unix-error ECONNABORTED 53 _N"Software caused connection abort") -(def-unix-error ECONNRESET 54 _N"Connection reset by peer") -(def-unix-error ENOBUFS 55 _N"No buffer space available") -(def-unix-error EISCONN 56 _N"Socket is already connected") -(def-unix-error ENOTCONN 57 _N"Socket is not connected") -(def-unix-error ESHUTDOWN 58 _N"Can't send after socket shutdown") -(def-unix-error ETOOMANYREFS 59 _N"Too many references: can't splice") -(def-unix-error ETIMEDOUT 60 _N"Connection timed out") -(def-unix-error ECONNREFUSED 61 _N"Connection refused") -;;; -(def-unix-error ELOOP 62 _N"Too many levels of symbolic links") -(def-unix-error ENAMETOOLONG 63 _N"File name too long") -;;; -(def-unix-error EHOSTDOWN 64 _N"Host is down") -(def-unix-error EHOSTUNREACH 65 _N"No route to host") -(def-unix-error ENOTEMPTY 66 _N"Directory not empty") -;;; -;;; quotas & resource -(def-unix-error EPROCLIM 67 _N"Too many processes") -(def-unix-error EUSERS 68 _N"Too many users") -(def-unix-error EDQUOT 69 _N"Disc quota exceeded") -;;; -;;; CMU RFS -(def-unix-error ELOCAL 126 _N"namei should continue locally") -(def-unix-error EREMOTE 127 _N"namei was handled remotely") -;;; -;;; VICE -(def-unix-error EVICEERR 70 _N"Remote file system error _N") -(def-unix-error EVICEOP 71 _N"syscall was handled by Vice") - -;;; Do NOT modify the line below. bin/create-errno.sh depends on it. - -;;; End of default def-unix-error forms View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/594cf2152a500c4abcd073db... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/594cf2152a500c4abcd073db... You're receiving this email because of your account on gitlab.common-lisp.net.