[Git][cmucl/cmucl][issue-446-use-cc-to-get-errno] 2 commits: Address review comments
Raymond Toy pushed to branch issue-446-use-cc-to-get-errno at cmucl / cmucl Commits: 6fc59db8 by Raymond Toy at 2025-10-23T20:06:53-07:00 Address review comments Inline DUMP_MACROS. Make Solaris sh happy by using backticks. - - - - - d4998b32 by Raymond Toy at 2025-10-24T09:45:24-07:00 Generate the ERRNO package definition Update create-errno.sh to generate a package definition for the ERRNO package from the `def-unix-error` forms that we generate already. This uses "bin/errno-pkg-template.lisp" for the boiler plate needed. The result is placed in src/code/exports-errno.lisp. Remove the ERRNO defpackage form from exports.lisp since we're generating it now. Update worldcom and worldload to load exports-errno.lisp. Finally, tell git to ignore the generated file exports-errno.lisp. - - - - - 7 changed files: - .gitignore - bin/build-world.sh - bin/create-errno.sh - + bin/errno-pkg-template.lisp - src/code/exports.lisp - src/tools/worldcom.lisp - src/tools/worldload.lisp Changes: ===================================== .gitignore ===================================== @@ -33,5 +33,6 @@ src/docs/cmu-user/*.tnd src/docs/cmu-user/*.toc src/docs/cmu-user/*.vdx src/docs/cmu-user/*.vnd -# Ignore generated errno.lisp +# Ignore generated errno files src/code/errno.lisp +src/code/exports-errno.lisp ===================================== bin/build-world.sh ===================================== @@ -53,6 +53,7 @@ $LISP "$@" -noinit -nositeinit <<EOF (pushnew :no-clm *features*) (pushnew :no-hemlock *features*) +(load "target:code/exports-errno") (load "target:code/exports") (load "target:tools/setup" :if-source-newer :load-source) (comf "target:tools/setup" :load t) ===================================== bin/create-errno.sh ===================================== @@ -48,6 +48,7 @@ done # Output file containing the final errno defintions OUTPUT="src/code/errno.lisp" +OUTPUT_PKG="src/code/exports-errno.lisp" # Default file containing errno definitions. ERRNO_FILE="bin/errno-default.lisp" @@ -55,16 +56,12 @@ ERRNO_FILE="bin/errno-default.lisp" # Template file containing the default def-unix-error forms and other # support code. TEMPLATE="bin/errno-template.lisp" - -# How to dump the macros. This version works on Linux, Darwin, and -# Solaris (with Sun C). Update this below if we need some other way -# for other OSes. -DUMP_MACROS="cpp -dM -" +TEMPLATE_PKG="bin/errno-pkg-template.lisp" # Set ERRNO_FILE to an OS-specific name if possible. If not, use the # default ERRNO_FILE value. if [ -z "$DEFAULT" ]; then - case $(uname -s) in + case `uname -s` in Linux) ERRNO_FILE="bin/errno-linux.lisp" ;; Darwin) ERRNO_FILE="bin/errno-darwin.lisp" @@ -84,9 +81,11 @@ fi find_errno () { # Create appropriate DEF-UNIX-ERROR forms by reading header files - # containing the C definitions. + # containing the C definitions. This version with cpp works on + # Linux, Darwin, and Solaris (with Sun C) to dump the macros + # defined in errno.h. echo '#include <errno.h>' | - ${DUMP_MACROS} | + cpp -dM - | grep "#define[ \t]\{1,\}E[A-Z0-9]\{1,\}" | sed 's/#define \(.*\) \(.*\)$/(def-unix-error \1 \2)/' | sort -n -k 3 @@ -111,6 +110,12 @@ fi # OS-specific errno values (or the default). cat "$TEMPLATE" "$ERRNO_FILE" > $OUTPUT +cut -d ' ' -f 2 "$ERRNO_FILE" | + sed 's/\(.*\)/ "\1"/' | + sort | + cat "$TEMPLATE_PKG" - > "$OUTPUT_PKG" +echo " ))" >> "$OUTPUT_PKG" + # If -S option given, cat the output file to stdout if [ -n "$SHOW" ]; then cat $OUTPUT ===================================== bin/errno-pkg-template.lisp ===================================== @@ -0,0 +1,31 @@ +;;; -*- Log: C.Log -*- +;;; +;;; ********************************************************************** +;;; This code was written as part of the CMU Common Lisp project at +;;; Carnegie Mellon University, and has been placed in the public domain. +;;; +(ext:file-comment + "$Header: src/code/exports-errno.lisp $") +;;; +;;; ********************************************************************** +;;; +;;; Defines the ERRNO package and all the exported symbols. +;;; +;;; This file is auto-generated via bin/create-errno.sh. +;;; +;;; DO NOT EDIT! +;;; + +(in-package "LISP") + +(intl:textdomain "cmucl") + +(if (find-package "ERRNO") + (rename-package "ERRNO" "ERRNO" 'nil) + (make-package "ERRNO" :nicknames 'nil :use nil)) + +(use-package '("LISP") "ERRNO") + +(defpackage "ERRNO" + (:export + "ESUCCESS" ===================================== src/code/exports.lisp ===================================== @@ -200,450 +200,6 @@ "MULTIPLY-BIGNUM-AND-FIXNUM" "MULTIPLY-BIGNUMS" "MULTIPLY-FIXNUMS" "NEGATE-BIGNUM" "SUBTRACT-BIGNUM")) -(defpackage "ERRNO" - #+linux - (:export "E2BIG" - "EACCES" - "EADDRINUSE" - "EADDRNOTAVAIL" - "EADV" - "EAFNOSUPPORT" - "EAGAIN" - "EALREADY" - "EBADE" - "EBADF" - "EBADFD" - "EBADMSG" - "EBADR" - "EBADRQC" - "EBADSLT" - "EBFONT" - "EBUSY" - "ECHILD" - "ECHRNG" - "ECOMM" - "ECONNABORTED" - "ECONNREFUSED" - "ECONNRESET" - "EDEADLK" - "EDEADLOCK" - "EDESTADDRREQ" - "EDOM" - "EDOTDOT" - "EDQUOT" - "EEXIST" - "EFAULT" - "EFBIG" - "EHOSTDOWN" - "EHOSTUNREACH" - "EIDRM" - "EILSEQ" - "EINPROGRESS" - "EINTR" - "EINVAL" - "EIO" - "EISCONN" - "EISDIR" - "EISNAM" - "EL2HLT" - "EL2NSYNC" - "EL3HLT" - "EL3RST" - "ELIBACC" - "ELIBBAD" - "ELIBEXEC" - "ELIBMAX" - "ELIBSCN" - "ELNRNG" - "ELOOP" - "EMFILE" - "EMLINK" - "EMSGSIZE" - "EMULTIHOP" - "ENAMETOOLONG" - "ENAVAIL" - "ENETDOWN" - "ENETRESET" - "ENETUNREACH" - "ENFILE" - "ENOANO" - "ENOBUFS" - "ENOCSI" - "ENODATA" - "ENODEV" - "ENOENT" - "ENOEXEC" - "ENOLCK" - "ENOLINK" - "ENOMEM" - "ENOMSG" - "ENONET" - "ENOPKG" - "ENOPROTOOPT" - "ENOSPC" - "ENOSR" - "ENOSTR" - "ENOSYS" - "ENOTBLK" - "ENOTCONN" - "ENOTDIR" - "ENOTEMPTY" - "ENOTNAM" - "ENOTSOCK" - "ENOTTY" - "ENOTUNIQ" - "ENXIO" - "EOPNOTSUPP" - "EOVERFLOW" - "EPERM" - "EPFNOSUPPORT" - "EPIPE" - "EPROTO" - "EPROTONOSUPPORT" - "EPROTOTYPE" - "ERANGE" - "EREMCHG" - "EREMOTE" - "EREMOTEIO" - "ERESTART" - "EROFS" - "ESHUTDOWN" - "ESOCKTNOSUPPORT" - "ESPIPE" - "ESRCH" - "ESRMNT" - "ESTALE" - "ESTRPIPE" - "ESUCCESS" - "ETIME" - "ETIMEDOUT" - "ETOOMANYREFS" - "ETXTBSY" - "EUCLEAN" - "EUNATCH" - "EUSERS" - "EWOULDBLOCK" - "EXDEV" - "EXFULL" - ) - #+(or bsd darwin) - (:export "E2BIG" - "EACCES" - "EADDRINUSE" - "EADDRNOTAVAIL" - "EAFNOSUPPORT" - "EAGAIN" - "EALREADY" - "EBADF" - "EBUSY" - "ECHILD" - "ECONNABORTED" - "ECONNREFUSED" - "ECONNRESET" - "EDEADLK" - "EDESTADDRREQ" - "EDOM" - "EDQUOT" - "EEXIST" - "EFAULT" - "EFBIG" - "EHOSTDOWN" - "EHOSTUNREACH" - "EINPROGRESS" - "EINTR" - "EINVAL" - "EIO" - "EISCONN" - "EISDIR" - "ELOCAL" - "ELOOP" - "EMFILE" - "EMLINK" - "EMSGSIZE" - "ENAMETOOLONG" - "ENETDOWN" - "ENETRESET" - "ENETUNREACH" - "ENFILE" - "ENOBUFS" - "ENODEV" - "ENOENT" - "ENOEXEC" - "ENOMEM" - "ENOPROTOOPT" - "ENOSPC" - "ENOTBLK" - "ENOTCONN" - "ENOTDIR" - "ENOTEMPTY" - "ENOTSOCK" - "ENOTTY" - "ENXIO" - "EOPNOTSUPP" - "EPERM" - "EPFNOSUPPORT" - "EPIPE" - "EPROCLIM" - "EPROTONOSUPPORT" - "EPROTOTYPE" - "ERANGE" - "EREMOTE" - "EROFS" - "ESHUTDOWN" - "ESOCKTNOSUPPORT" - "ESPIPE" - "ESRCH" - "ESUCCESS" - "ETIMEDOUT" - "ETOOMANYREFS" - "ETXTBSY" - "EUSERS" - "EVICEERR" - "EVICEOP" - "EWOULDBLOCK" - "EXDEV" - ) - #+solaris - (:export "E2BIG" - "EACCES" - "EADDRINUSE" - "EADDRNOTAVAIL" - "EADV" - "EAFNOSUPPORT" - "EAGAIN" - "EALREADY" - "EBADE" - "EBADF" - "EBADFD" - "EBADMSG" - "EBADR" - "EBADRQC" - "EBADSLT" - "EBFONT" - "EBUSY" - "ECANCELED" - "ECHILD" - "ECHRNG" - "ECOMM" - "ECONNABORTED" - "ECONNREFUSED" - "ECONNRESET" - "EDEADLK" - "EDEADLOCK" - "EDESTADDRREQ" - "EDOM" - "EEXIST" - "EFAULT" - "EFBIG" - "EHOSTDOWN" - "EHOSTUNREACH" - "EIDRM" - "EILSEQ" - "EINPROGRESS" - "EINTR" - "EINVAL" - "EIO" - "EISCONN" - "EISDIR" - "EL2HLT" - "EL2NSYNC" - "EL3HLT" - "EL3RST" - "ELIBACC" - "ELIBBAD" - "ELIBEXEC" - "ELIBMAX" - "ELIBSCN" - "ELNRNG" - "ELOOP" - "EMFILE" - "EMLINK" - "EMSGSIZE" - "EMULTIHOP" - "ENAMETOOLONG" - "ENETDOWN" - "ENETRESET" - "ENETUNREACH" - "ENFILE" - "ENOANO" - "ENOBUFS" - "ENOCSI" - "ENODATA" - "ENODEV" - "ENOENT" - "ENOEXEC" - "ENOLCK" - "ENOLINK" - "ENOMEM" - "ENOMSG" - "ENONET" - "ENOPKG" - "ENOPROTOOPT" - "ENOSPC" - "ENOSR" - "ENOSTR" - "ENOSYS" - "ENOTBLK" - "ENOTCONN" - "ENOTDIR" - "ENOTEMPTY" - "ENOTSOCK" - "ENOTSUP" - "ENOTTY" - "ENOTUNIQ" - "ENXIO" - "EOPNOTSUPP" - "EOVERFLOW" - "EPERM" - "EPFNOSUPPORT" - "EPIPE" - "EPROTO" - "EPROTONOSUPPORT" - "EPROTOTYPE" - "ERANGE" - "EREMCHG" - "EREMOTE" - "ERESTART" - "EROFS" - "ESHUTDOWN" - "ESOCKTNOSUPPORT" - "ESPIPE" - "ESRCH" - "ESRMNT" - "ESTALE" - "ESTRPIPE" - "ESUCCESS" - "ETIME" - "ETIMEDOUT" - "ETOOMANYREFS" - "ETXTBSY" - "EUNATCH" - "EUSERS" - "EWOULDBLOCK" - "EXDEV" - "EXFULL" - ) - #-(or linux solaris bsd darwin) - (:export "E2BIG" - "EACCES" - "EADDRINUSE" - "EADDRNOTAVAIL" - "EADV" - "EAFNOSUPPORT" - "EAGAIN" - "EALREADY" - "EBADE" - "EBADF" - "EBADFD" - "EBADMSG" - "EBADR" - "EBADRQC" - "EBADSLT" - "EBFONT" - "EBUSY" - "ECANCELED" - "ECHILD" - "ECHRNG" - "ECOMM" - "ECONNABORTED" - "ECONNREFUSED" - "ECONNRESET" - "EDEADLK" - "EDEADLOCK" - "EDESTADDRREQ" - "EDOM" - "EEXIST" - "EFAULT" - "EFBIG" - "EHOSTDOWN" - "EHOSTUNREACH" - "EIDRM" - "EILSEQ" - "EINPROGRESS" - "EINTR" - "EINVAL" - "EIO" - "EISCONN" - "EISDIR" - "EL2HLT" - "EL2NSYNC" - "EL3HLT" - "EL3RST" - "ELIBACC" - "ELIBBAD" - "ELIBEXEC" - "ELIBMAX" - "ELIBSCN" - "ELNRNG" - "ELOOP" - "EMFILE" - "EMLINK" - "EMSGSIZE" - "EMULTIHOP" - "ENAMETOOLONG" - "ENETDOWN" - "ENETRESET" - "ENETUNREACH" - "ENFILE" - "ENOANO" - "ENOBUFS" - "ENOCSI" - "ENODATA" - "ENODEV" - "ENOENT" - "ENOEXEC" - "ENOLCK" - "ENOLINK" - "ENOMEM" - "ENOMSG" - "ENONET" - "ENOPKG" - "ENOPROTOOPT" - "ENOSPC" - "ENOSR" - "ENOSTR" - "ENOSYS" - "ENOTBLK" - "ENOTCONN" - "ENOTDIR" - "ENOTEMPTY" - "ENOTSOCK" - "ENOTSUP" - "ENOTTY" - "ENOTUNIQ" - "ENXIO" - "EOPNOTSUPP" - "EOVERFLOW" - "EPERM" - "EPFNOSUPPORT" - "EPIPE" - "EPROTO" - "EPROTONOSUPPORT" - "EPROTOTYPE" - "ERANGE" - "EREMCHG" - "EREMOTE" - "ERESTART" - "EROFS" - "ESHUTDOWN" - "ESOCKTNOSUPPORT" - "ESPIPE" - "ESRCH" - "ESRMNT" - "ESTALE" - "ESTRPIPE" - "ESUCCESS" - "ETIME" - "ETIMEDOUT" - "ETOOMANYREFS" - "ETXTBSY" - "EUNATCH" - "EUSERS" - "EWOULDBLOCK" - "EXDEV" - "EXFULL" - )) - (defpackage "UNIX" (:export "UNIX-CURRENT-DIRECTORY" "UNIX-OPEN" @@ -945,7 +501,7 @@ (do-external-symbols (sym "ERRNO") (shadowing-import sym "UNIX") (export sym "UNIX"))) - + (defpackage "FORMAT") (defpackage "COMMON-LISP" ===================================== src/tools/worldcom.lisp ===================================== @@ -315,6 +315,7 @@ (comf "target:code/multi-proc")) (comf "target:code/setf-funs") +(comf "target:code/exports-errno" :proceed t) (comf "target:code/exports" :proceed t) ;;; Compile basic macros that we assume are already in the compilation ===================================== src/tools/worldload.lisp ===================================== @@ -78,6 +78,7 @@ ;;; Make sure the package structure is correct. ;;; +(maybe-byte-load "code:exports-errno") (maybe-byte-load "code:exports") ;;; Load random code sources. View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/6ce0be0f7aaae32f27ac4de... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/6ce0be0f7aaae32f27ac4de... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)