/* The first entry is a catch-all for codes not enumerated here.
 * This file is included multiple times to declare and define a structure
 * with these messages, and then to define a lookup table translating
 * error codes to offsets of corresponding fields in the structure. */
#if defined(__EMSCRIPTEN__)
/* Error handling is introduced to match the behavior in llvm-libc.
 * When invalid errno is specified, Unknown error: errno_code is emitted.
 */
E(0,            "Success")
#else
E(0,            "No error information")
#endif

E(EILSEQ,       "Illegal byte sequence")
E(EDOM,         "Domain error")
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")

#if defined(__EMSCRIPTEN__)
// This is intended to match the errno in llvm-libc.
E(EOVERFLOW,    "Value too large for defined data type")
#else
E(EOVERFLOW,    "Value too large for data type")
#endif
E(ENOSPC,       "No space left on device")
E(ENOMEM,       "Out of memory")

E(EBUSY,        "Resource busy")
E(EINTR,        "Interrupted system call")
E(EAGAIN,       "Resource temporarily unavailable")
E(ESPIPE,       "Invalid 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,    "Operation timed out")
E(ECONNREFUSED, "Connection refused")
E(EHOSTDOWN,    "Host is down")
E(EHOSTUNREACH, "Host is unreachable")
E(EADDRINUSE,   "Address 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,        "Symbolic link loop")
E(ENAMETOOLONG, "Filename too long")
E(ENFILE,       "Too many open files in system")
E(EMFILE,       "No file descriptors available")
E(EBADF,        "Bad file descriptor")
E(ECHILD,       "No child process")
E(EFAULT,       "Bad address")
E(EFBIG,        "File too large")
E(EMLINK,       "Too many links")
E(ENOLCK,       "No locks available")

E(EDEADLK,      "Resource deadlock would occur")
E(ENOTRECOVERABLE, "State not recoverable")
#if defined(__EMSCRIPTEN__)
E(EOWNERDEAD,   "Owner died")
#else
E(EOWNERDEAD,   "Previous owner died")
#endif
E(ECANCELED,    "Operation canceled")
E(ENOSYS,       "Function not implemented")
E(ENOMSG,       "No message of desired type")
E(EIDRM,        "Identifier removed")
E(ENOSTR,       "Device not a stream")
E(ENODATA,      "No data available")
E(ETIME,        "Device timeout")
E(ENOSR,        "Out of streams resources")
E(ENOLINK,      "Link has been severed")
E(EPROTO,       "Protocol error")
E(EBADMSG,      "Bad message")
E(EBADFD,       "File descriptor in bad state")
E(ENOTSOCK,     "Not a socket")
E(EDESTADDRREQ, "Destination address required")
E(EMSGSIZE,     "Message too large")
E(EPROTOTYPE,   "Protocol wrong type for socket")
E(ENOPROTOOPT,  "Protocol not available")
E(EPROTONOSUPPORT,"Protocol not supported")
E(ESOCKTNOSUPPORT,"Socket type not supported")
E(ENOTSUP,      "Not supported")
E(EPFNOSUPPORT, "Protocol family not supported")
E(EAFNOSUPPORT, "Address family not supported by protocol")
E(EADDRNOTAVAIL,"Address not available")
E(ENETDOWN,     "Network is down")
E(ENETUNREACH,  "Network unreachable")
E(ENETRESET,    "Connection reset by network")
E(ECONNABORTED, "Connection aborted")
E(ENOBUFS,      "No buffer space available")
E(EISCONN,      "Socket is connected")
E(ENOTCONN,     "Socket not connected")
E(ESHUTDOWN,    "Cannot send after socket shutdown")
E(EALREADY,     "Operation already in progress")
E(EINPROGRESS,  "Operation in progress")
E(ESTALE,       "Stale file handle")
E(EUCLEAN,      "Data consistency error")
E(ENAVAIL,      "Resource not available")
E(EREMOTEIO,    "Remote I/O error")
E(EDQUOT,       "Quota exceeded")
E(ENOMEDIUM,    "No medium found")
E(EMEDIUMTYPE,  "Wrong medium type")
E(EMULTIHOP,    "Multihop attempted")
E(ENOKEY,       "Required key not available")
E(EKEYEXPIRED,  "Key has expired")
E(EKEYREVOKED,  "Key has been revoked")
E(EKEYREJECTED, "Key was rejected by service")
