xref: /freebsd/contrib/llvm-project/libc/include/llvm-libc-macros/linux/sys-wait-macros.h (revision bb722a7d0f1642bff6487f943ad0427799a6e5bf)
1 //===-- Definition of macros from sys/wait.h ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIBC_MACROS_LINUX_SYS_WAIT_MACROS_H
10 #define LLVM_LIBC_MACROS_LINUX_SYS_WAIT_MACROS_H
11 
12 #include <linux/wait.h>
13 
14 #define WCOREDUMP(status) ((status) & WCOREFLAG)
15 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
16 #define WIFCONTINUED(status) ((status) == 0xffff)
17 #define WIFEXITED(status) (WTERMSIG(status) == 0)
18 #define WIFSIGNALED(status) ((WTERMSIG(status) + 1) >= 2)
19 #define WIFSTOPPED(status) (WTERMSIG(status) == 0x7f)
20 #define WSTOPSIG(status) WEXITSTATUS(status)
21 #define WTERMSIG(status) ((status) & 0x7f)
22 
23 #define WCOREFLAG 0x80
24 #define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
25 #define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
26 
27 #endif // LLVM_LIBC_MACROS_LINUX_SYS_WAIT_MACROS_H
28