abis: fix wait macros on Linux

This commit is contained in:
Kacper Słomiński 2021-06-19 21:27:08 +02:00
parent cb9106f722
commit 11717b94ab
9 changed files with 51 additions and 20 deletions

22
abis/linux/x86_64/wait.h Normal file
View file

@ -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

22
abis/mlibc/wait.h Normal file
View file

@ -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

View file

@ -6,6 +6,7 @@
#include <abi-bits/pid_t.h>
// for siginfo_t
#include <abi-bits/signal.h>
#include <abi-bits/wait.h>
#ifdef __cplusplus
extern "C" {
@ -14,26 +15,6 @@ extern "C" {
// According to POSIX, <sys/wait.h> 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

View file

@ -0,0 +1 @@
../../../../abis/mlibc/wait.h

View file

@ -0,0 +1 @@
../../../../abis/mlibc/wait.h

View file

@ -0,0 +1 @@
../../../../abis/linux/x86_64/wait.h

View file

@ -0,0 +1 @@
../../../../abis/mlibc/wait.h

View file

@ -0,0 +1 @@
../../../../abis/mlibc/wait.h

View file

@ -0,0 +1 @@
../../../../abis/mlibc/wait.h