Raymond Toy pushed to branch issue-365-add-strerror at cmucl / cmucl
Commits:
-
967de6a7
by Raymond Toy at 2025-01-30T06:58:14-08:00
-
d122b95f
by Raymond Toy at 2025-01-30T07:01:45-08:00
-
07a998ee
by Raymond Toy at 2025-01-30T07:31:19-08:00
-
034c685d
by Raymond Toy at 2025-01-30T07:42:59-08:00
-
55db6026
by Raymond Toy at 2025-01-30T07:44:09-08:00
-
e3504ec0
by Raymond Toy at 2025-01-30T07:44:59-08:00
8 changed files:
- bin/build.sh
- src/code/unix.lisp
- src/lisp/Config.x86_linux
- src/lisp/Config.x86_linux_clang
- src/lisp/GNUmakefile
- + src/lisp/create-errno.c
- src/tools/worldbuild.lisp
- src/tools/worldcom.lisp
Changes:
| ... | ... | @@ -129,6 +129,8 @@ buildit () |
| 129 | 129 | if [ "$ENABLE" = "yes" ];
|
| 130 | 130 | then
|
| 131 | 131 | $TOOLDIR/clean-target.sh $CLEAN_FLAGS $TARGET || { echo "Failed: $TOOLDIR/clean-target.sh"; exit 1; }
|
| 132 | + # Generate code/unix-errno.lisp
|
|
| 133 | + $MAKE -C $TARGET/lisp ../code/unix-errno.lisp
|
|
| 132 | 134 | time $BUILDWORLD $TARGET $OLDLISP $BOOT || { echo "Failed: $BUILDWORLD"; exit 1; }
|
| 133 | 135 | if [ "$REBUILD_LISP" = "yes" ]; then
|
| 134 | 136 | $TOOLDIR/rebuild-lisp.sh $TARGET
|
| ... | ... | @@ -1742,13 +1742,16 @@ |
| 1742 | 1742 | |
| 1743 | 1743 | (defparameter *compiler-unix-errors* nil)
|
| 1744 | 1744 | |
| 1745 | -(defmacro def-unix-error (name number description)
|
|
| 1745 | +(defmacro def-unix-error (name number &optional description)
|
|
| 1746 | + "Define a constant named Name corresponding to the Unix errno value
|
|
| 1747 | + Number. A description of the errno is optional in Description."
|
|
| 1746 | 1748 | `(progn
|
| 1747 | 1749 | (eval-when (compile eval)
|
| 1748 | 1750 | (push (cons ,number ,description) *compiler-unix-errors*))
|
| 1749 | 1751 | (defconstant ,name ,number ,description)
|
| 1750 | 1752 | (export ',name)))
|
| 1751 | 1753 | |
| 1754 | +#-linux
|
|
| 1752 | 1755 | (defmacro emit-unix-errors ()
|
| 1753 | 1756 | (let* ((max (apply #'max (mapcar #'car *compiler-unix-errors*)))
|
| 1754 | 1757 | (array (make-array (1+ max) :initial-element nil)))
|
| ... | ... | @@ -1760,6 +1763,10 @@ |
| 1760 | 1763 | |
| 1761 | 1764 | ) ;eval-when
|
| 1762 | 1765 | |
| 1766 | +;;; For Linux, the def-unix-error forms are auto-generated and are not
|
|
| 1767 | +;;; defined here.
|
|
| 1768 | +#-linux
|
|
| 1769 | +(progn
|
|
| 1763 | 1770 | ;;;
|
| 1764 | 1771 | ;;; From <errno.h>
|
| 1765 | 1772 | ;;;
|
| ... | ... | @@ -1945,101 +1952,11 @@ |
| 1945 | 1952 | (def-unix-error EINPROGRESS 150 _N"Operation now in progress")
|
| 1946 | 1953 | (def-unix-error ESTALE 151 _N"Stale NFS file handle")
|
| 1947 | 1954 | )
|
| 1948 | -#+linux
|
|
| 1949 | -(progn
|
|
| 1950 | -(def-unix-error EDEADLK 35 _N"Resource deadlock would occur")
|
|
| 1951 | -(def-unix-error ENAMETOOLONG 36 _N"File name too long")
|
|
| 1952 | -(def-unix-error ENOLCK 37 _N"No record locks available")
|
|
| 1953 | -(def-unix-error ENOSYS 38 _N"Function not implemented")
|
|
| 1954 | -(def-unix-error ENOTEMPTY 39 _N"Directory not empty")
|
|
| 1955 | -(def-unix-error ELOOP 40 _N"Too many symbolic links encountered")
|
|
| 1956 | -(def-unix-error EWOULDBLOCK 11 _N"Operation would block")
|
|
| 1957 | -(def-unix-error ENOMSG 42 _N"No message of desired type")
|
|
| 1958 | -(def-unix-error EIDRM 43 _N"Identifier removed")
|
|
| 1959 | -(def-unix-error ECHRNG 44 _N"Channel number out of range")
|
|
| 1960 | -(def-unix-error EL2NSYNC 45 _N"Level 2 not synchronized")
|
|
| 1961 | -(def-unix-error EL3HLT 46 _N"Level 3 halted")
|
|
| 1962 | -(def-unix-error EL3RST 47 _N"Level 3 reset")
|
|
| 1963 | -(def-unix-error ELNRNG 48 _N"Link number out of range")
|
|
| 1964 | -(def-unix-error EUNATCH 49 _N"Protocol driver not attached")
|
|
| 1965 | -(def-unix-error ENOCSI 50 _N"No CSI structure available")
|
|
| 1966 | -(def-unix-error EL2HLT 51 _N"Level 2 halted")
|
|
| 1967 | -(def-unix-error EBADE 52 _N"Invalid exchange")
|
|
| 1968 | -(def-unix-error EBADR 53 _N"Invalid request descriptor")
|
|
| 1969 | -(def-unix-error EXFULL 54 _N"Exchange full")
|
|
| 1970 | -(def-unix-error ENOANO 55 _N"No anode")
|
|
| 1971 | -(def-unix-error EBADRQC 56 _N"Invalid request code")
|
|
| 1972 | -(def-unix-error EBADSLT 57 _N"Invalid slot")
|
|
| 1973 | -(def-unix-error EDEADLOCK EDEADLK _N"File locking deadlock error")
|
|
| 1974 | -(def-unix-error EBFONT 59 _N"Bad font file format")
|
|
| 1975 | -(def-unix-error ENOSTR 60 _N"Device not a stream")
|
|
| 1976 | -(def-unix-error ENODATA 61 _N"No data available")
|
|
| 1977 | -(def-unix-error ETIME 62 _N"Timer expired")
|
|
| 1978 | -(def-unix-error ENOSR 63 _N"Out of streams resources")
|
|
| 1979 | -(def-unix-error ENONET 64 _N"Machine is not on the network")
|
|
| 1980 | -(def-unix-error ENOPKG 65 _N"Package not installed")
|
|
| 1981 | -(def-unix-error EREMOTE 66 _N"Object is remote")
|
|
| 1982 | -(def-unix-error ENOLINK 67 _N"Link has been severed")
|
|
| 1983 | -(def-unix-error EADV 68 _N"Advertise error")
|
|
| 1984 | -(def-unix-error ESRMNT 69 _N"Srmount error")
|
|
| 1985 | -(def-unix-error ECOMM 70 _N"Communication error on send")
|
|
| 1986 | -(def-unix-error EPROTO 71 _N"Protocol error")
|
|
| 1987 | -(def-unix-error EMULTIHOP 72 _N"Multihop attempted")
|
|
| 1988 | -(def-unix-error EDOTDOT 73 _N"RFS specific error")
|
|
| 1989 | -(def-unix-error EBADMSG 74 _N"Not a data message")
|
|
| 1990 | -(def-unix-error EOVERFLOW 75 _N"Value too large for defined data type")
|
|
| 1991 | -(def-unix-error ENOTUNIQ 76 _N"Name not unique on network")
|
|
| 1992 | -(def-unix-error EBADFD 77 _N"File descriptor in bad state")
|
|
| 1993 | -(def-unix-error EREMCHG 78 _N"Remote address changed")
|
|
| 1994 | -(def-unix-error ELIBACC 79 _N"Can not access a needed shared library")
|
|
| 1995 | -(def-unix-error ELIBBAD 80 _N"Accessing a corrupted shared library")
|
|
| 1996 | -(def-unix-error ELIBSCN 81 _N".lib section in a.out corrupted")
|
|
| 1997 | -(def-unix-error ELIBMAX 82 _N"Attempting to link in too many shared libraries")
|
|
| 1998 | -(def-unix-error ELIBEXEC 83 _N"Cannot exec a shared library directly")
|
|
| 1999 | -(def-unix-error EILSEQ 84 _N"Illegal byte sequence")
|
|
| 2000 | -(def-unix-error ERESTART 85 _N"Interrupted system call should be restarted _N")
|
|
| 2001 | -(def-unix-error ESTRPIPE 86 _N"Streams pipe error")
|
|
| 2002 | -(def-unix-error EUSERS 87 _N"Too many users")
|
|
| 2003 | -(def-unix-error ENOTSOCK 88 _N"Socket operation on non-socket")
|
|
| 2004 | -(def-unix-error EDESTADDRREQ 89 _N"Destination address required")
|
|
| 2005 | -(def-unix-error EMSGSIZE 90 _N"Message too long")
|
|
| 2006 | -(def-unix-error EPROTOTYPE 91 _N"Protocol wrong type for socket")
|
|
| 2007 | -(def-unix-error ENOPROTOOPT 92 _N"Protocol not available")
|
|
| 2008 | -(def-unix-error EPROTONOSUPPORT 93 _N"Protocol not supported")
|
|
| 2009 | -(def-unix-error ESOCKTNOSUPPORT 94 _N"Socket type not supported")
|
|
| 2010 | -(def-unix-error EOPNOTSUPP 95 _N"Operation not supported on transport endpoint")
|
|
| 2011 | -(def-unix-error EPFNOSUPPORT 96 _N"Protocol family not supported")
|
|
| 2012 | -(def-unix-error EAFNOSUPPORT 97 _N"Address family not supported by protocol")
|
|
| 2013 | -(def-unix-error EADDRINUSE 98 _N"Address already in use")
|
|
| 2014 | -(def-unix-error EADDRNOTAVAIL 99 _N"Cannot assign requested address")
|
|
| 2015 | -(def-unix-error ENETDOWN 100 _N"Network is down")
|
|
| 2016 | -(def-unix-error ENETUNREACH 101 _N"Network is unreachable")
|
|
| 2017 | -(def-unix-error ENETRESET 102 _N"Network dropped connection because of reset")
|
|
| 2018 | -(def-unix-error ECONNABORTED 103 _N"Software caused connection abort")
|
|
| 2019 | -(def-unix-error ECONNRESET 104 _N"Connection reset by peer")
|
|
| 2020 | -(def-unix-error ENOBUFS 105 _N"No buffer space available")
|
|
| 2021 | -(def-unix-error EISCONN 106 _N"Transport endpoint is already connected")
|
|
| 2022 | -(def-unix-error ENOTCONN 107 _N"Transport endpoint is not connected")
|
|
| 2023 | -(def-unix-error ESHUTDOWN 108 _N"Cannot send after transport endpoint shutdown")
|
|
| 2024 | -(def-unix-error ETOOMANYREFS 109 _N"Too many references: cannot splice")
|
|
| 2025 | -(def-unix-error ETIMEDOUT 110 _N"Connection timed out")
|
|
| 2026 | -(def-unix-error ECONNREFUSED 111 _N"Connection refused")
|
|
| 2027 | -(def-unix-error EHOSTDOWN 112 _N"Host is down")
|
|
| 2028 | -(def-unix-error EHOSTUNREACH 113 _N"No route to host")
|
|
| 2029 | -(def-unix-error EALREADY 114 _N"Operation already in progress")
|
|
| 2030 | -(def-unix-error EINPROGRESS 115 _N"Operation now in progress")
|
|
| 2031 | -(def-unix-error ESTALE 116 _N"Stale NFS file handle")
|
|
| 2032 | -(def-unix-error EUCLEAN 117 _N"Structure needs cleaning")
|
|
| 2033 | -(def-unix-error ENOTNAM 118 _N"Not a XENIX named type file")
|
|
| 2034 | -(def-unix-error ENAVAIL 119 _N"No XENIX semaphores available")
|
|
| 2035 | -(def-unix-error EISNAM 120 _N"Is a named type file")
|
|
| 2036 | -(def-unix-error EREMOTEIO 121 _N"Remote I/O error")
|
|
| 2037 | -(def-unix-error EDQUOT 122 _N"Quota exceeded")
|
|
| 2038 | -)
|
|
| 2039 | 1955 | |
| 2040 | 1956 | ;;;
|
| 2041 | 1957 | ;;; And now for something completely different ...
|
| 2042 | 1958 | (emit-unix-errors)
|
| 1959 | +)
|
|
| 2043 | 1960 | |
| 2044 | 1961 | (def-alien-routine ("os_get_errno" unix-get-errno) int)
|
| 2045 | 1962 | (def-alien-routine ("os_set_errno" unix-set-errno) int (newvalue int))
|
| ... | ... | @@ -14,3 +14,6 @@ OS_LINK_FLAGS = -m32 -rdynamic -Xlinker --export-dynamic -Xlinker -Map -Xlinker |
| 14 | 14 | OS_LINK_FLAGS += -Wl,-z,noexecstack
|
| 15 | 15 | |
| 16 | 16 | EXEC_FINAL_OBJ = exec-final.o
|
| 17 | + |
|
| 18 | +../code/unix-errno.lisp : create-errno
|
|
| 19 | + ./create-errno /usr/include/asm-generic/errno* | uniq > $@ |
| ... | ... | @@ -19,3 +19,6 @@ OS_LINK_FLAGS = -m32 -rdynamic -Xlinker --export-dynamic -Xlinker -Map -Xlinker |
| 19 | 19 | OS_LINK_FLAGS += -Wl,-z,noexecstack
|
| 20 | 20 | |
| 21 | 21 | EXEC_FINAL_OBJ = exec-final.o
|
| 22 | + |
|
| 23 | +../code/unix-errno.lisp : create-errno
|
|
| 24 | + ./create-errno /usr/include/asm-generic/errno* | uniq > $@ |
| ... | ... | @@ -66,9 +66,9 @@ endif |
| 66 | 66 | version:
|
| 67 | 67 | echo 0 > version
|
| 68 | 68 | |
| 69 | -internals.h internals.inc:
|
|
| 70 | - @echo "You must run genesis to create internals.h!"
|
|
| 71 | - @false
|
|
| 69 | +#internals.h internals.inc:
|
|
| 70 | +# @echo "You must run genesis to create internals.h!"
|
|
| 71 | +# @false
|
|
| 72 | 72 | |
| 73 | 73 | clean:
|
| 74 | 74 | $(RM) Depends *.o lisp lisp.nm core lisp.a
|
| ... | ... | @@ -139,3 +139,7 @@ translations-update: |
| 139 | 139 | done; done
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | +# Compile program that creates the unix-error.lisp file. Actual
|
|
| 143 | +# generation of the file is OS-dependent.
|
|
| 144 | +create-errno : create-errno.c
|
|
| 145 | + $(CC) -o $@ $^ |
| 1 | +#include <regex.h>
|
|
| 2 | +#include <stdio.h>
|
|
| 3 | +#include <stdlib.h>
|
|
| 4 | +#include <string.h>
|
|
| 5 | + |
|
| 6 | +struct Err {
|
|
| 7 | + char *name;
|
|
| 8 | + int num;
|
|
| 9 | +#if 0
|
|
| 10 | + char *descr;
|
|
| 11 | +#endif
|
|
| 12 | +} err[256];
|
|
| 13 | + |
|
| 14 | +int nerr = 0;
|
|
| 15 | + |
|
| 16 | +regex_t reg;
|
|
| 17 | + |
|
| 18 | +void match(const char *line) {
|
|
| 19 | + regmatch_t match[3];
|
|
| 20 | + regoff_t len;
|
|
| 21 | + |
|
| 22 | + if (regexec(®, line, 3, match, 0) == REG_NOMATCH)
|
|
| 23 | + return;
|
|
| 24 | + |
|
| 25 | + len = match[1].rm_eo - match[1].rm_so;
|
|
| 26 | + err[nerr].name = malloc(len + 1);
|
|
| 27 | + sprintf(err[nerr].name, "%.*s", len, line + match[1].rm_so);
|
|
| 28 | + |
|
| 29 | + err[nerr].num = atoi(line + match[2].rm_so);
|
|
| 30 | + |
|
| 31 | +#if 0
|
|
| 32 | + err[nerr].descr = strerror(err[nerr].num);
|
|
| 33 | +#endif
|
|
| 34 | + |
|
| 35 | + nerr++;
|
|
| 36 | +}
|
|
| 37 | + |
|
| 38 | +int cmp(const void *a, const void *b) {
|
|
| 39 | + return ((struct Err *)a)->num - ((struct Err *)b)->num;
|
|
| 40 | +}
|
|
| 41 | + |
|
| 42 | +int main(int argc, char **argv)
|
|
| 43 | +{
|
|
| 44 | + int i;
|
|
| 45 | + FILE *fp;
|
|
| 46 | + char line[1024];
|
|
| 47 | + |
|
| 48 | + regcomp(®, "^#define[ \t]*(E[A-Z0-9]+)[ \t]*([0-9]+)", REG_EXTENDED);
|
|
| 49 | + |
|
| 50 | + for (i = 1; i < argc; i++) {
|
|
| 51 | + if ((fp = fopen(argv[i], "r")) == NULL) {
|
|
| 52 | + perror("fopen");
|
|
| 53 | + exit(1);
|
|
| 54 | + }
|
|
| 55 | + while (fgets(line, sizeof(line), fp) != NULL)
|
|
| 56 | + match(line);
|
|
| 57 | + fclose(fp);
|
|
| 58 | + }
|
|
| 59 | + |
|
| 60 | + qsort(err, nerr, sizeof(*err), cmp);
|
|
| 61 | + |
|
| 62 | + /*
|
|
| 63 | + * Print out CMUCL-style file header
|
|
| 64 | + */
|
|
| 65 | + puts(";;; -*- Package: UNIX -*-\n\
|
|
| 66 | +;;;\n\
|
|
| 67 | +;;; **********************************************************************\n\
|
|
| 68 | +;;; This code was written as part of the CMU Common Lisp project at\n\
|
|
| 69 | +;;; Carnegie Mellon University, and has been placed in the public domain.\n\
|
|
| 70 | +;;;\n\
|
|
| 71 | +(ext:file-comment\n\
|
|
| 72 | + \"$Header: src/code/unix-errno.lisp $\")\n\
|
|
| 73 | +;;;\n\
|
|
| 74 | +;;; **********************************************************************\n\
|
|
| 75 | +;;;\n\
|
|
| 76 | +;;; This file contains the values of the UNIX errno values.\n\
|
|
| 77 | +;;;\n \
|
|
| 78 | +;;; DO NOT EDIT! This is auto-generated from create-errno.\n\
|
|
| 79 | +;;;\n");
|
|
| 80 | + |
|
| 81 | + puts("(in-package \"UNIX\")\n");
|
|
| 82 | + for (i = 0; i < nerr; i++) {
|
|
| 83 | +#if 0
|
|
| 84 | + printf("(def-unix-error %s %d \"%s\")\n", err[i].name, err[i].num, err[i].descr);
|
|
| 85 | +#else
|
|
| 86 | + printf("(def-unix-error %s %d)\n", err[i].name, err[i].num);
|
|
| 87 | +#endif
|
|
| 88 | + }
|
|
| 89 | + |
|
| 90 | + return 0;
|
|
| 91 | +} |
| ... | ... | @@ -136,6 +136,10 @@ |
| 136 | 136 | "target:code/c-call"
|
| 137 | 137 | "target:code/sap"
|
| 138 | 138 | "target:code/unix"
|
| 139 | + ,@(when (or (c:backend-featurep :linux))
|
|
| 140 | + ;; This is currently only available for some OSes. Ideally,
|
|
| 141 | + ;; it should be available for all OSes.
|
|
| 142 | + "target:code/unix-errno")
|
|
| 139 | 143 | ,@(when (c:backend-featurep :mach)
|
| 140 | 144 | '("target:code/mach"
|
| 141 | 145 | "target:code/mach-os"))
|
| ... | ... | @@ -163,6 +163,10 @@ |
| 163 | 163 | (comf "target:code/mipsstrops")
|
| 164 | 164 | |
| 165 | 165 | (comf "target:code/unix" :proceed t)
|
| 166 | +(when (or (c:backend-featurep :linux))
|
|
| 167 | + ;; This is currently only available for some OSes. Ideally, it
|
|
| 168 | + ;; should be available for all OSes.
|
|
| 169 | + (comf "target:code/unix-errno" :proceed t))
|
|
| 166 | 170 | |
| 167 | 171 | (when (c:backend-featurep :mach)
|
| 168 | 172 | (comf "target:code/mach")
|