mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibC: Make errno codes be #defines instead of enum values.
It turns out that a lot of 3rd party software does things like: #ifdef EINTR ... #endif This won't work if EINTR is an enum. So much for that nice idea.
This commit is contained in:
parent
83e78648e4
commit
424368034b
4 changed files with 146 additions and 87 deletions
|
@ -64,7 +64,9 @@ static void make_shell(int ptm_fd)
|
||||||
perror("ioctl(TIOCSCTTY)");
|
perror("ioctl(TIOCSCTTY)");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
rc = execvp("/bin/sh", nullptr);
|
char* args[] = { "/bin/sh", nullptr };
|
||||||
|
char* envs[] = { "TERM=vt100", nullptr };
|
||||||
|
rc = execve("/bin/sh", args, envs);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("execve");
|
perror("execve");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -7,7 +7,6 @@ enum KSuccessTag { KSuccess };
|
||||||
|
|
||||||
class KResult {
|
class KResult {
|
||||||
public:
|
public:
|
||||||
explicit KResult(__errno_value e) : m_error(-e) { }
|
|
||||||
explicit KResult(int negative_e) : m_error(negative_e) { ASSERT(negative_e <= 0); }
|
explicit KResult(int negative_e) : m_error(negative_e) { ASSERT(negative_e <= 0); }
|
||||||
KResult(KSuccessTag) : m_error(0) { }
|
KResult(KSuccessTag) : m_error(0) { }
|
||||||
operator int() const { return m_error; }
|
operator int() const { return m_error; }
|
||||||
|
|
|
@ -1,83 +1,73 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define __ENUMERATE_ALL_ERRORS \
|
#define ESUCCESS 0
|
||||||
__ERROR(ESUCCESS, "Success (not an error)") \
|
#define EPERM 1
|
||||||
__ERROR(EPERM, "Operation not permitted") \
|
#define ENOENT 2
|
||||||
__ERROR(ENOENT, "No such file or directory") \
|
#define ESRCH 3
|
||||||
__ERROR(ESRCH, "No such process") \
|
#define EINTR 4
|
||||||
__ERROR(EINTR, "Interrupted syscall") \
|
#define EIO 5
|
||||||
__ERROR(EIO, "I/O error") \
|
#define ENXIO 6
|
||||||
__ERROR(ENXIO, "No such device or address") \
|
#define E2BIG 7
|
||||||
__ERROR(E2BIG, "Argument list too long") \
|
#define ENOEXEC 8
|
||||||
__ERROR(ENOEXEC, "Exec format error") \
|
#define EBADF 9
|
||||||
__ERROR(EBADF, "Bad fd number") \
|
#define ECHILD 10
|
||||||
__ERROR(ECHILD, "No child processes") \
|
#define EAGAIN 11
|
||||||
__ERROR(EAGAIN, "Try again") \
|
#define ENOMEM 12
|
||||||
__ERROR(ENOMEM, "Out of memory") \
|
#define EACCES 13
|
||||||
__ERROR(EACCES, "Permission denied") \
|
#define EFAULT 14
|
||||||
__ERROR(EFAULT, "Bad address") \
|
#define ENOTBLK 15
|
||||||
__ERROR(ENOTBLK, "Block device required") \
|
#define EBUSY 16
|
||||||
__ERROR(EBUSY, "Device or resource busy") \
|
#define EEXIST 17
|
||||||
__ERROR(EEXIST, "File already exists") \
|
#define EXDEV 18
|
||||||
__ERROR(EXDEV, "Cross-device link") \
|
#define ENODEV 19
|
||||||
__ERROR(ENODEV, "No such device") \
|
#define ENOTDIR 20
|
||||||
__ERROR(ENOTDIR, "Not a directory") \
|
#define EISDIR 21
|
||||||
__ERROR(EISDIR, "Is a directory") \
|
#define EINVAL 22
|
||||||
__ERROR(EINVAL, "Invalid argument") \
|
#define ENFILE 23
|
||||||
__ERROR(ENFILE, "File table overflow") \
|
#define EMFILE 24
|
||||||
__ERROR(EMFILE, "Too many open files") \
|
#define ENOTTY 25
|
||||||
__ERROR(ENOTTY, "Not a TTY") \
|
#define ETXTBSY 26
|
||||||
__ERROR(ETXTBSY, "Text file busy") \
|
#define EFBIG 27
|
||||||
__ERROR(EFBIG, "File too large") \
|
#define ENOSPC 28
|
||||||
__ERROR(ENOSPC, "No space left on device") \
|
#define ESPIPE 29
|
||||||
__ERROR(ESPIPE, "Illegal seek") \
|
#define EROFS 30
|
||||||
__ERROR(EROFS, "Read-only filesystem") \
|
#define EMLINK 31
|
||||||
__ERROR(EMLINK, "Too many links") \
|
#define EPIPE 32
|
||||||
__ERROR(EPIPE, "Broken pipe") \
|
#define ERANGE 33
|
||||||
__ERROR(ERANGE, "Range error") \
|
#define ENAMETOOLONG 34
|
||||||
__ERROR(ENAMETOOLONG, "Name too long") \
|
#define ELOOP 35
|
||||||
__ERROR(ELOOP, "Too many symlinks") \
|
#define EOVERFLOW 36
|
||||||
__ERROR(EOVERFLOW, "Overflow") \
|
#define EOPNOTSUPP 37
|
||||||
__ERROR(EOPNOTSUPP, "Operation not supported") \
|
#define ENOSYS 38
|
||||||
__ERROR(ENOSYS, "No such syscall") \
|
#define ENOTIMPL 39
|
||||||
__ERROR(ENOTIMPL, "Not implemented") \
|
#define EAFNOSUPPORT 40
|
||||||
__ERROR(EAFNOSUPPORT, "Address family not supported") \
|
#define ENOTSOCK 41
|
||||||
__ERROR(ENOTSOCK, "Not a socket") \
|
#define EADDRINUSE 42
|
||||||
__ERROR(EADDRINUSE, "Address in use") \
|
#define EWHYTHO 43
|
||||||
__ERROR(EWHYTHO, "Failed without setting an error code (Bug!)") \
|
#define ENOTEMPTY 44
|
||||||
__ERROR(ENOTEMPTY, "Directory not empty") \
|
#define EDOM 45
|
||||||
__ERROR(EDOM, "Math argument out of domain") \
|
#define ECONNREFUSED 46
|
||||||
__ERROR(ECONNREFUSED, "Connection refused") \
|
#define EADDRNOTAVAIL 47
|
||||||
__ERROR(EADDRNOTAVAIL, "Address not available") \
|
#define EISCONN 48
|
||||||
__ERROR(EISCONN, "Already connected") \
|
#define ECONNABORTED 49
|
||||||
__ERROR(ECONNABORTED, "Connection aborted") \
|
#define EALREADY 50
|
||||||
__ERROR(EALREADY, "Connection already in progress") \
|
#define ECONNRESET 51
|
||||||
__ERROR(ECONNRESET, "Connection reset") \
|
#define EDESTADDRREQ 52
|
||||||
__ERROR(EDESTADDRREQ, "Desination address required") \
|
#define EHOSTUNREACH 53
|
||||||
__ERROR(EHOSTUNREACH, "Host unreachable") \
|
#define EILSEQ 54
|
||||||
__ERROR(EILSEQ, "Illegal byte sequence") \
|
#define EMSGSIZE 55
|
||||||
__ERROR(EMSGSIZE, "Message size") \
|
#define ENETDOWN 56
|
||||||
__ERROR(ENETDOWN, "Network down") \
|
#define ENETUNREACH 57
|
||||||
__ERROR(ENETUNREACH, "Network unreachable") \
|
#define ENETRESET 58
|
||||||
__ERROR(ENETRESET, "Network reset") \
|
#define ENOBUFS 59
|
||||||
__ERROR(ENOBUFS, "No buffer space") \
|
#define ENOLCK 60
|
||||||
__ERROR(ENOLCK, "No lock available") \
|
#define ENOMSG 61
|
||||||
__ERROR(ENOMSG, "No message") \
|
#define ENOPROTOOPT 62
|
||||||
__ERROR(ENOPROTOOPT, "No protocol option") \
|
#define ENOTCONN 63
|
||||||
__ERROR(ENOTCONN, "Not connected") \
|
#define EWOULDBLOCK 64
|
||||||
__ERROR(EWOULDBLOCK, "Operation would block") \
|
#define EPROTONOSUPPORT 65
|
||||||
__ERROR(EPROTONOSUPPORT,"Protocol not supported") \
|
#define EDEADLK 66
|
||||||
__ERROR(EDEADLK, "Resource deadlock would occur") \
|
#define ETIMEDOUT 67
|
||||||
__ERROR(ETIMEDOUT, "Timed out") \
|
#define EPROTOTYPE 68
|
||||||
__ERROR(EPROTOTYPE, "Wrong protocol type") \
|
#define EINPROGRESS 69
|
||||||
__ERROR(EINPROGRESS, "Operation in progress") \
|
#define EMAXERRNO 70
|
||||||
__ERROR(EMAXERRNO, "The highest errno +1 :^)")
|
|
||||||
|
|
||||||
|
|
||||||
enum __errno_value {
|
|
||||||
#undef __ENUMERATE_ERROR
|
|
||||||
#define __ERROR(a, b) a,
|
|
||||||
__ENUMERATE_ALL_ERRORS
|
|
||||||
#undef __ENUMERATE_ERROR
|
|
||||||
__errno_count
|
|
||||||
};
|
|
||||||
|
|
|
@ -242,11 +242,79 @@ char* strncat(char *dest, const char *src, size_t n)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* sys_errlist[] = {
|
const char* sys_errlist[] = {
|
||||||
#undef __ERROR
|
"Success (not an error)",
|
||||||
#define __ERROR(a, b) b,
|
"Operation not permitted",
|
||||||
__ENUMERATE_ALL_ERRORS
|
"No such file or directory",
|
||||||
#undef __ERROR
|
"No such process",
|
||||||
|
"Interrupted syscall",
|
||||||
|
"I/O error",
|
||||||
|
"No such device or address",
|
||||||
|
"Argument list too long",
|
||||||
|
"Exec format error",
|
||||||
|
"Bad fd number",
|
||||||
|
"No child processes",
|
||||||
|
"Try again",
|
||||||
|
"Out of memory",
|
||||||
|
"Permission denied",
|
||||||
|
"Bad address",
|
||||||
|
"Block device required",
|
||||||
|
"Device or resource busy",
|
||||||
|
"File already exists",
|
||||||
|
"Cross-device link",
|
||||||
|
"No such device",
|
||||||
|
"Not a directory",
|
||||||
|
"Is a directory",
|
||||||
|
"Invalid argument",
|
||||||
|
"File table overflow",
|
||||||
|
"Too many open files",
|
||||||
|
"Not a TTY",
|
||||||
|
"Text file busy",
|
||||||
|
"File too large",
|
||||||
|
"No space left on device",
|
||||||
|
"Illegal seek",
|
||||||
|
"Read-only filesystem",
|
||||||
|
"Too many links",
|
||||||
|
"Broken pipe",
|
||||||
|
"Range error",
|
||||||
|
"Name too long",
|
||||||
|
"Too many symlinks",
|
||||||
|
"Overflow",
|
||||||
|
"Operation not supported",
|
||||||
|
"No such syscall",
|
||||||
|
"Not implemented",
|
||||||
|
"Address family not supported",
|
||||||
|
"Not a socket",
|
||||||
|
"Address in use",
|
||||||
|
"Failed without setting an error code (bug!)",
|
||||||
|
"Directory not empty",
|
||||||
|
"Math argument out of domain",
|
||||||
|
"Connection refused",
|
||||||
|
"Address not available",
|
||||||
|
"Already connected",
|
||||||
|
"Connection aborted",
|
||||||
|
"Connection already in progress",
|
||||||
|
"Connection reset",
|
||||||
|
"Desination address required",
|
||||||
|
"Host unreachable",
|
||||||
|
"Illegal byte sequence",
|
||||||
|
"Message size",
|
||||||
|
"Network down",
|
||||||
|
"Network unreachable",
|
||||||
|
"Network reset",
|
||||||
|
"No buffer space",
|
||||||
|
"No lock available",
|
||||||
|
"No message",
|
||||||
|
"No protocol option",
|
||||||
|
"Not connected",
|
||||||
|
"Operation would block",
|
||||||
|
"Protocol not supported",
|
||||||
|
"Resource deadlock would occur",
|
||||||
|
"Timed out",
|
||||||
|
"Wrong protocol type",
|
||||||
|
"Operation in progress",
|
||||||
|
"The highest errno +1 :^)",
|
||||||
};
|
};
|
||||||
|
|
||||||
int sys_nerr = EMAXERRNO;
|
int sys_nerr = EMAXERRNO;
|
||||||
|
|
||||||
char* strerror(int errnum)
|
char* strerror(int errnum)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue