From 73e85548fe6da79e10b09e27422af678e9bff795 Mon Sep 17 00:00:00 2001 From: Joe Eli McIlvain Date: Fri, 4 Mar 2022 14:01:38 -0800 Subject: [PATCH] Add `OSError` library code. --- LICENSE.md | 2 +- README.md | 4 +- manifest.savi | 13 ++++ spec/Main.savi | 5 ++ spec/OSError.Spec.savi | 6 ++ src/OSError.savi | 140 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 manifest.savi create mode 100644 spec/Main.savi create mode 100644 spec/OSError.Spec.savi create mode 100644 src/OSError.savi diff --git a/LICENSE.md b/LICENSE.md index a82eb76..d400902 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright 2018 Joe Eli McIlvain +Copyright 2021 Joe Eli McIlvain Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 16476b8..12be7db 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -A base repository for Savi language libraries, with common CI actions configured. +# OSError -See the [Guide](https://github.com/savi-lang/base-standard-library/wiki/Guide) for details on how it works and how to use it for your own libraries. +OS-specific error numbers exposed for the Savi standard library. diff --git a/manifest.savi b/manifest.savi new file mode 100644 index 0000000..f61cfef --- /dev/null +++ b/manifest.savi @@ -0,0 +1,13 @@ +:manifest lib OSError + :sources "src/*.savi" + +:manifest bin "spec" + :copies OSError + :sources "spec/*.savi" + + :dependency Spec v0 + :from "github:savi-lang/Spec" + :depends on Map + + :transitive dependency Map v0 + :from "github:savi-lang/Map" diff --git a/spec/Main.savi b/spec/Main.savi new file mode 100644 index 0000000..8b9dfc4 --- /dev/null +++ b/spec/Main.savi @@ -0,0 +1,5 @@ +:actor Main + :new (env) + Spec.Process.run(env, [ + Spec.Run(OSError.Spec).new(env) + ]) diff --git a/spec/OSError.Spec.savi b/spec/OSError.Spec.savi new file mode 100644 index 0000000..9c81bf7 --- /dev/null +++ b/spec/OSError.Spec.savi @@ -0,0 +1,6 @@ +:class OSError.Spec + :is Spec + :const describes: "OSError" + + :it "uses zero for success" + assert: OSError.None == 0 diff --git a/src/OSError.savi b/src/OSError.savi new file mode 100644 index 0000000..ad6d72e --- /dev/null +++ b/src/OSError.savi @@ -0,0 +1,140 @@ +:enum OSError + :const bit_width U8: 32 + + :fun name: @member_name + + // TODO: cross-platform; see http://www.ioplex.com/~miallen/errcmp.html + + :member OSError.None: 0 :: Success + + :member OSError.EPERM: 1 :: Operation not permitted + :member OSError.ENOENT: 2 :: No such file or directory + :member OSError.ESRCH: 3 :: No such process + :member OSError.EINTR: 4 :: Interrupted system call + :member OSError.EIO: 5 :: I/O error + :member OSError.ENXIO: 6 :: No such device or address + :member OSError.E2BIG: 7 :: Argument list too long + :member OSError.ENOEXEC: 8 :: Exec format error + :member OSError.EBADF: 9 :: Bad file descriptor + :member OSError.ECHILD: 10 :: No child processes + :member OSError.EAGAIN: 11 :: Resource temporarily unavailable + :member OSError.ENOMEM: 12 :: Out of memory + :member OSError.EACCES: 13 :: Permission denied + :member OSError.EFAULT: 14 :: Bad address + :member OSError.ENOTBLK: 15 :: Block device required + :member OSError.EBUSY: 16 :: Device or resource busy + :member OSError.EEXIST: 17 :: File exists + :member OSError.EXDEV: 18 :: Cross-device link + :member OSError.ENODEV: 19 :: No such device + :member OSError.ENOTDIR: 20 :: Not a directory + :member OSError.EISDIR: 21 :: Is a directory + :member OSError.EINVAL: 22 :: Invalid argument + :member OSError.ENFILE: 23 :: File table overflow + :member OSError.EMFILE: 24 :: Too many open files + :member OSError.ENOTTY: 25 :: Inappropriate I/O control operation + :member OSError.ETXTBSY: 26 :: Text file busy + :member OSError.EFBIG: 27 :: File too large + :member OSError.ENOSPC: 28 :: No space left on device + :member OSError.ESPIPE: 29 :: Illegal seek + :member OSError.EROFS: 30 :: Read-only file system + :member OSError.EMLINK: 31 :: Too many links + :member OSError.EPIPE: 32 :: Broken pipe + :member OSError.EDOM: 33 :: Math argument out of domain of func + :member OSError.ERANGE: 34 :: Math result not representable + :member OSError.EDEADLK: 35 :: Resource deadlock would occur + :member OSError.ENAMETOOLONG: 36 :: File name too long + :member OSError.ENOLCK: 37 :: No record locks available + :member OSError.ENOSYS: 38 :: Invalid system call number + :member OSError.ENOTEMPTY: 39 :: Directory not empty + :member OSError.ELOOP: 40 :: Too many symbolic links encountered + + :member OSError.ENOMSG: 42 :: No message of desired type + :member OSError.EIDRM: 43 :: Identifier removed + :member OSError.ECHRNG: 44 :: Channel number out of range + :member OSError.EL2NSYNC: 45 :: Level 2 not synchronized + :member OSError.EL3HLT: 46 :: Level 3 halted + :member OSError.EL3RST: 47 :: Level 3 reset + :member OSError.ELNRNG: 48 :: Link number out of range + :member OSError.EUNATCH: 49 :: Protocol driver not attached + :member OSError.ENOCSI: 50 :: No CSI structure available + :member OSError.EL2HLT: 51 :: Level 2 halted + :member OSError.EBADE: 52 :: Invalid exchange + :member OSError.EBADR: 53 :: Invalid request descriptor + :member OSError.EXFULL: 54 :: Exchange full + :member OSError.ENOANO: 55 :: No anode + :member OSError.EBADRQC: 56 :: Invalid request code + :member OSError.EBADSLT: 57 :: Invalid slot + + :member OSError.EBFONT: 59 :: Bad font file format + :member OSError.ENOSTR: 60 :: Device not a stream + :member OSError.ENODATA: 61 :: No data available + :member OSError.ETIME: 62 :: Timer expired + :member OSError.ENOSR: 63 :: Out of streams resources + :member OSError.ENONET: 64 :: Machine is not on the network + :member OSError.ENOPKG: 65 :: Package not installed + :member OSError.EREMOTE: 66 :: Object is remote + :member OSError.ENOLINK: 67 :: Link has been severed + :member OSError.EADV: 68 :: Advertise error + :member OSError.ESRMNT: 69 :: Srmount error + :member OSError.ECOMM: 70 :: Communication error on send + :member OSError.EPROTO: 71 :: Protocol error + :member OSError.EMULTIHOP: 72 :: Multihop attempted + :member OSError.EDOTDOT: 73 :: RFS specific error + :member OSError.EBADMSG: 74 :: Not a data message + :member OSError.EOVERFLOW: 75 :: Value too large for defined data type + :member OSError.ENOTUNIQ: 76 :: Name not unique on network + :member OSError.EBADFD: 77 :: File descriptor in bad state + :member OSError.EREMCHG: 78 :: Remote address changed + :member OSError.ELIBACC: 79 :: Can not access a needed shared library + :member OSError.ELIBBAD: 80 :: Accessing a corrupted shared library + :member OSError.ELIBSCN: 81 :: .lib section in a.out corrupted + :member OSError.ELIBMAX: 82 :: Attempting to link in too many shared libraries + :member OSError.ELIBEXEC: 83 :: Cannot exec a shared library directly + :member OSError.EILSEQ: 84 :: Illegal byte sequence + :member OSError.ERESTART: 85 :: Interrupted system call should be restarted + :member OSError.ESTRPIPE: 86 :: Streams pipe error + :member OSError.EUSERS: 87 :: Too many users + :member OSError.ENOTSOCK: 88 :: Socket operation on non-socket + :member OSError.EDESTADDRREQ: 89 :: Destination address required + :member OSError.EMSGSIZE: 90 :: Message too long + :member OSError.EPROTOTYPE: 91 :: Protocol wrong type for socket + :member OSError.ENOPROTOOPT: 92 :: Protocol not available + :member OSError.EPROTONOSUPPORT: 93 :: Protocol not supported + :member OSError.ESOCKTNOSUPPORT: 94 :: Socket type not supported + :member OSError.EOPNOTSUPP: 95 :: Operation not supported on transport endpoint + :member OSError.EPFNOSUPPORT: 96 :: Protocol family not supported + :member OSError.EAFNOSUPPORT: 97 :: Address family not supported by protocol + :member OSError.EADDRINUSE: 98 :: Address already in use + :member OSError.EADDRNOTAVAIL: 99 :: Cannot assign requested address + :member OSError.ENETDOWN: 100 :: Network is down + :member OSError.ENETUNREACH: 101 :: Network is unreachable + :member OSError.ENETRESET: 102 :: Network dropped connection because of reset + :member OSError.ECONNABORTED: 103 :: Software caused connection abort + :member OSError.ECONNRESET: 104 :: Connection reset by peer + :member OSError.ENOBUFS: 105 :: No buffer space available + :member OSError.EISCONN: 106 :: Transport endpoint is already connected + :member OSError.ENOTCONN: 107 :: Transport endpoint is not connected + :member OSError.ESHUTDOWN: 108 :: Cannot send after transport endpoint shutdown + :member OSError.ETOOMANYREFS: 109 :: Too many references: cannot splice + :member OSError.ETIMEDOUT: 110 :: Connection timed out + :member OSError.ECONNREFUSED: 111 :: Connection refused + :member OSError.EHOSTDOWN: 112 :: Host is down + :member OSError.EHOSTUNREACH: 113 :: No route to host + :member OSError.EALREADY: 114 :: Operation already in progress + :member OSError.EINPROGRESS: 115 :: Operation now in progress + :member OSError.ESTALE: 116 :: Stale file handle + :member OSError.EUCLEAN: 117 :: Structure needs cleaning + :member OSError.ENOTNAM: 118 :: Not a XENIX named type file + :member OSError.ENAVAIL: 119 :: No XENIX semaphores available + :member OSError.EISNAM: 120 :: Is a named type file + :member OSError.EREMOTEIO: 121 :: Remote I/O error + :member OSError.EDQUOT: 122 :: Quota exceeded + :member OSError.ENOMEDIUM: 123 :: No medium found + :member OSError.EMEDIUMTYPE: 124 :: Wrong medium type + :member OSError.ECANCELED: 125 :: Operation Canceled + :member OSError.ENOKEY: 126 :: Required key not available + :member OSError.EKEYEXPIRED: 127 :: Key has expired + :member OSError.EKEYREVOKED: 128 :: Key has been revoked + :member OSError.EKEYREJECTED: 129 :: Key was rejected by service + :member OSError.EOWNERDEAD: 130 :: Owner died + :member OSError.ENOTRECOVERABLE: 131 :: State not recoverable