Skip to content

Commit

Permalink
Android: Add wait.h definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Sep 30, 2024
1 parent e08034b commit 2450984
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/adbg/include/posix/sys/wait.d
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ version (linux) {
int WCOREDUMP(int s) { return s & 0x80; }

version (CRuntime_Glibc) {
// Source: bits/waitstatus.h
// sysdeps/unix/sysv/linux/bits/waitflags.h
// bits/waitstatus.h
// sysdeps/unix/sysv/linux/bits/waitflags.h

bool WIFEXITED(int s) { return WTERMSIG(s) == 0; }
bool WIFSIGNALED(int s) { return (cast(byte)((s & 0x7f) + 1) >> 1) > 0; }
Expand All @@ -65,11 +65,17 @@ version (linux) {
#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
*/
} else version (CRuntime_Musl) {
// Source: include/sys/wait.h
// include/sys/wait.h

bool WIFEXITED(int s) { return !WTERMSIG(s); }
bool WIFSIGNALED(int s) { return (s&0xffff)-1U < 0xffu; }
bool WIFSTOPPED(int s) { return cast(short)(((s&0xffff)*0x10001U)>>8) > 0x7f00; }
} else version (CRuntime_Bionic) {
// libc/include/bits/wait.h

bool WIFEXITED(int s) { return WTERMSIG(s) == 0; }
bool WIFSIGNALED(int s) { return WTERMSIG(s+1) >= 2; }
bool WIFSTOPPED(int s) { return WTERMSIG(s) == 0x7f; }
} else static assert(0, "Define wait.h macros (Linux)");
} else version (FreeBSD) {
// Source: sys/sys/wait.h
Expand Down

0 comments on commit 2450984

Please sign in to comment.