diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-02-12 00:22:29 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-02-12 00:22:29 -0500 |
commit | 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 (patch) | |
tree | 6eaef0d8a720fa3da580de87b647fff796fe80b3 /src/errno | |
download | musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.gz musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.tar.xz musl-0b44a0315b47dd8eced9f3b7f31580cf14bbfc01.zip |
initial check-in, version 0.5.0 v0.5.0
Diffstat (limited to 'src/errno')
-rw-r--r-- | src/errno/__errno_location.c | 11 | ||||
-rw-r--r-- | src/errno/__strerror.h | 101 | ||||
-rw-r--r-- | src/errno/strerror.c | 22 |
3 files changed, 134 insertions, 0 deletions
diff --git a/src/errno/__errno_location.c b/src/errno/__errno_location.c new file mode 100644 index 00000000..0a220b63 --- /dev/null +++ b/src/errno/__errno_location.c @@ -0,0 +1,11 @@ +#include <errno.h> +#include "libc.h" + +#undef errno +int errno; + +int *__errno_location(void) +{ + if (libc.errno_location) return libc.errno_location(); + return &errno; +} diff --git a/src/errno/__strerror.h b/src/errno/__strerror.h new file mode 100644 index 00000000..00eaf938 --- /dev/null +++ b/src/errno/__strerror.h @@ -0,0 +1,101 @@ +/* This file is sorted such that 'errors' which represent exceptional + * conditions under which a correct program may fail come first, followed + * by messages that indicate an incorrect program or system failure. The + * macro E() along with double-inclusion is used to ensure that ordering + * of the strings remains synchronized. */ + +E(EILSEQ, "Illegal byte sequence") +E(EDOM, "Argument outside domain") +E(ERANGE, "Result not representable") + +E(ENOTTY, "Not a tty") +E(EACCES, "Permission denied") +E(EPERM, "Operation not permitted") +E(ENOENT, "No such file or directory") +E(ESRCH, "No such process") +E(EEXIST, "File exists") + +E(EOVERFLOW, "Value too large for defined data type") +E(ENOSPC, "No space left on device") +E(ENOMEM, "Out of memory") + +E(EBUSY, "Device or resource busy") +E(EINTR, "Interrupted system call") +E(EAGAIN, "Operation would block") +E(ESPIPE, "Illegal seek") + +E(EXDEV, "Cross-device link") +E(EROFS, "Read-only file system") +E(ENOTEMPTY, "Directory not empty") + +E(ECONNRESET, "Connection reset by peer") +E(ETIMEDOUT, "Connection timed out") +E(ECONNREFUSED, "Connection refused") +E(EHOSTDOWN, "Host is down") +E(EHOSTUNREACH, "No route to host") +E(EADDRINUSE, "Address already in use") + +E(EPIPE, "Broken pipe") +E(EIO, "I/O error") +E(ENXIO, "No such device or address") +E(ENOTBLK, "Block device required") +E(ENODEV, "No such device") +E(ENOTDIR, "Not a directory") +E(EISDIR, "Is a directory") +E(ETXTBSY, "Text file busy") +E(ENOEXEC, "Exec format error") + +E(EINVAL, "Invalid argument") + +E(E2BIG, "Argument list too long") +E(ELOOP, "Too many levels of symbolic links") +E(ENAMETOOLONG, "Filename too long") +E(ENFILE, "File table overflow") +E(EMFILE, "Too many open files") +E(EBADF, "Bad file number") +E(ECHILD, "No child processes") +E(EFAULT, "Bad address") +E(EFBIG, "File too large") +E(EMLINK, "Too many links") +E(ENOLCK, "No record locks available") + +E(EDEADLK, "Resource deadlock would occur") +E(ENOSYS, "Function not supported") +E(ENOMSG, "No message of desired type") +E(EIDRM, "Identifier removed") +E(ENOSTR, "Device not a stream") +E(ENODATA, "No data available") +E(ETIME, "Timer expired") +E(ENOSR, "Out of streams resources") +E(ENOLINK, "Link has been severed") +E(EPROTO, "Protocol error") +E(EBADMSG, "Not a data message") +E(EBADFD, "File descriptor in bad state") +E(ENOTSOCK, "Socket operation on non-socket") +E(EDESTADDRREQ, "Destination address required") +E(EMSGSIZE, "Message too long") +E(EPROTOTYPE, "Protocol wrong type for socket") +E(ENOPROTOOPT, "Protocol not available") +E(EPROTONOSUPPORT,"Protocol not supported") +E(ESOCKTNOSUPPORT,"Socket type not supported") +E(EOPNOTSUPP, "Operation not supported on socket") +E(EPFNOSUPPORT, "Protocol family not supported") +E(EAFNOSUPPORT, "Address family not supported by protocol") +E(EADDRNOTAVAIL,"Cannot assign requested address") +E(ENETDOWN, "Network is down") +E(ENETUNREACH, "Network is unreachable") +E(ENETRESET, "Network dropped connection because of reset") +E(ECONNABORTED, "Software caused connection abort") +E(ENOBUFS, "No buffer space available") +E(EISCONN, "Socket is connected") +E(ENOTCONN, "Socket is not connected") +E(ESHUTDOWN, "Cannot send after socket shutdown") +E(EALREADY, "Operation already in progress") +E(EINPROGRESS, "Operation now in progress") +E(ESTALE, "Stale NFS file handle") +E(EREMOTEIO, "Remote I/O error") +E(EDQUOT, "Quota exceeded") +E(ENOMEDIUM, "No medium found") +E(EMEDIUMTYPE, "Wrong medium type") + +E(0, "Invalid error number") diff --git a/src/errno/strerror.c b/src/errno/strerror.c new file mode 100644 index 00000000..b8fbc6db --- /dev/null +++ b/src/errno/strerror.c @@ -0,0 +1,22 @@ +#include <errno.h> +#include <string.h> + +#define E(a,b) a, +static const unsigned char errid[] = { +#include "__strerror.h" +}; + +#undef E +#define E(a,b) b "\0" +static const char errmsg[] = +#include "__strerror.h" +; + +char *strerror(int e) +{ + const char *s; + int i; + for (i=0; errid[i] && errid[i] != e; i++); + for (s=errmsg; i; s++, i--) for (; *s; s++); + return (char *)s; +} |