diff --git a/abis/linux/x86_64/wait.h b/abis/linux/x86_64/wait.h new file mode 100644 index 00000000..f8f0f586 --- /dev/null +++ b/abis/linux/x86_64/wait.h @@ -0,0 +1,22 @@ +#ifndef _ABIBITS_WAIT_H +#define _ABIBITS_WAIT_H + +#define WNOHANG 1 +#define WUNTRACED 2 +#define WSTOPPED 2 +#define WEXITED 4 +#define WCONTINUED 8 +#define WNOWAIT 0x01000000 + +#define WCOREFLAG 0x80 + +#define WEXITSTATUS(x) (((x) & 0xff00) >> 8) +#define WTERMSIG(x) ((x) & 0x7f) +#define WSTOPSIG(x) WEXITSTATUS(x) +#define WIFEXITED(x) (WTERMSIG(x) == 0) +#define WIFSIGNALED(x) (((signed char) (((x) & 0x7f) + 1) >> 1) > 0) +#define WIFSTOPPED(x) (((x) & 0xff) == 0x7f) +#define WIFCONTINUED(x) ((x) == 0xffff) +#define WCOREDUMP(x) ((x) & WCOREFLAG) + +#endif //_ABIBITS_WAIT_H diff --git a/abis/mlibc/wait.h b/abis/mlibc/wait.h new file mode 100644 index 00000000..eb616df6 --- /dev/null +++ b/abis/mlibc/wait.h @@ -0,0 +1,22 @@ +#ifndef _ABIBITS_WAIT_H +#define _ABIBITS_WAIT_H + +#define WCONTINUED 1 +#define WNOHANG 2 +#define WUNTRACED 4 +#define WEXITED 8 +#define WNOWAIT 16 +#define WSTOPPED 32 + +#define WCOREFLAG 0x80 + +#define WEXITSTATUS(x) ((x) & 0x000000FF) +#define WIFCONTINUED(x) ((x) & 0x00000100) +#define WIFEXITED(x) ((x) & 0x00000200) +#define WIFSIGNALED(x) ((x) & 0x00000400) +#define WIFSTOPPED(x) ((x) & 0x00000800) +#define WSTOPSIG(x) (((x) & 0x00FF0000) >> 16) +#define WTERMSIG(x) (((x) & 0xFF000000) >> 24) +#define WCOREDUMP(x) ((x) & WCOREFLAG) + +#endif //_ABIBITS_WAIT_H diff --git a/options/posix/include/sys/wait.h b/options/posix/include/sys/wait.h index 8656ca31..c291e8e7 100644 --- a/options/posix/include/sys/wait.h +++ b/options/posix/include/sys/wait.h @@ -6,6 +6,7 @@ #include // for siginfo_t #include +#include #ifdef __cplusplus extern "C" { @@ -14,26 +15,6 @@ extern "C" { // According to POSIX, does not make rusage available. struct rusage; -#define WCONTINUED 1 -#define WNOHANG 2 -#define WUNTRACED 4 -#define WEXITED 8 -#define WNOWAIT 16 -#define WSTOPPED 32 - -#define WCOREFLAG 0x80 - -// TODO: #error if int is smaller than 32 bits - -#define WEXITSTATUS(x) ((x) & 0x000000FF) -#define WIFCONTINUED(x) ((x) & 0x00000100) -#define WIFEXITED(x) ((x) & 0x00000200) -#define WIFSIGNALED(x) ((x) & 0x00000400) -#define WIFSTOPPED(x) ((x) & 0x00000800) -#define WSTOPSIG(x) (((x) & 0x00FF0000) >> 16) -#define WTERMSIG(x) (((x) & 0xFF000000) >> 24) -#define WCOREDUMP(x) ((x) & WCOREFLAG) - // TODO: move to own file and include in sys/types.h typedef enum { P_ALL, P_PID, P_PGID diff --git a/sysdeps/dripos/include/abi-bits/wait.h b/sysdeps/dripos/include/abi-bits/wait.h new file mode 120000 index 00000000..6d911c7f --- /dev/null +++ b/sysdeps/dripos/include/abi-bits/wait.h @@ -0,0 +1 @@ +../../../../abis/mlibc/wait.h \ No newline at end of file diff --git a/sysdeps/lemon/include/abi-bits/wait.h b/sysdeps/lemon/include/abi-bits/wait.h new file mode 120000 index 00000000..6d911c7f --- /dev/null +++ b/sysdeps/lemon/include/abi-bits/wait.h @@ -0,0 +1 @@ +../../../../abis/mlibc/wait.h \ No newline at end of file diff --git a/sysdeps/linux/include/abi-bits/wait.h b/sysdeps/linux/include/abi-bits/wait.h new file mode 120000 index 00000000..dc39395f --- /dev/null +++ b/sysdeps/linux/include/abi-bits/wait.h @@ -0,0 +1 @@ +../../../../abis/linux/x86_64/wait.h \ No newline at end of file diff --git a/sysdeps/managarm/include/abi-bits/wait.h b/sysdeps/managarm/include/abi-bits/wait.h new file mode 120000 index 00000000..6d911c7f --- /dev/null +++ b/sysdeps/managarm/include/abi-bits/wait.h @@ -0,0 +1 @@ +../../../../abis/mlibc/wait.h \ No newline at end of file diff --git a/sysdeps/qword/include/abi-bits/wait.h b/sysdeps/qword/include/abi-bits/wait.h new file mode 120000 index 00000000..6d911c7f --- /dev/null +++ b/sysdeps/qword/include/abi-bits/wait.h @@ -0,0 +1 @@ +../../../../abis/mlibc/wait.h \ No newline at end of file diff --git a/sysdeps/sigma/include/abi-bits/wait.h b/sysdeps/sigma/include/abi-bits/wait.h new file mode 120000 index 00000000..6d911c7f --- /dev/null +++ b/sysdeps/sigma/include/abi-bits/wait.h @@ -0,0 +1 @@ +../../../../abis/mlibc/wait.h \ No newline at end of file