1/* Definitions of status bits for `wait' et al.
2 MIPS version, based on the generic version (bits/waitstatus.h).
3
4 Copyright (C) 1992-2026 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <https://www.gnu.org/licenses/>. */
20
21#if !defined _SYS_WAIT_H && !defined _STDLIB_H
22# error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
23#endif
24
25
26/* On MIPS SIGRTMAX is 127, so we need to handle the status code 127
27 which is impossible on other ports. */
28
29/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */
30#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
31
32/* If WIFSIGNALED(STATUS), the terminating signal. */
33#define __WTERMSIG(status) ((status) & 0x7f)
34
35/* If WIFSTOPPED(STATUS), the signal that stopped the child. */
36#define __WSTOPSIG(status) __WEXITSTATUS(status)
37
38/* Nonzero if STATUS indicates normal termination. */
39#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
40
41/* Nonzero if STATUS indicates termination by a signal. */
42static __inline int
43__WIFSIGNALED (int __status)
44{
45 return ((signed char) ((__status & 0x7f) + 1) >> 1) > 0 || __status == 0x7f;
46}
47
48/* Nonzero if STATUS indicates the child is stopped. */
49static __inline int
50__WIFSTOPPED (int __status)
51{
52 return (__status & 0xff) == 0x7f && __status != 0x7f;
53}
54
55/* Nonzero if STATUS indicates the child continued after a stop. We only
56 define this if <bits/waitflags.h> provides the WCONTINUED flag bit. */
57#ifdef WCONTINUED
58# define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
59#endif
60
61/* Nonzero if STATUS indicates the child dumped core. */
62#define __WCOREDUMP(status) ((status) & __WCOREFLAG)
63
64/* Macros for constructing status values. */
65#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
66#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
67#define __W_CONTINUED 0xffff
68#define __WCOREFLAG 0x80