1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20: #if !defined _SYS_WAIT_H && !defined _STDLIB_H
21: # error "Never include <bits/waitstatus.h> directly; use <sys/wait.h> instead."
22: #endif
23:
24:
25:
26:
27:
28:
29: #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
30:
31:
32: #define __WTERMSIG(status) ((status) & 0x7f)
33:
34:
35: #define __WSTOPSIG(status) __WEXITSTATUS(status)
36:
37:
38: #define __WIFEXITED(status) (__WTERMSIG(status) == 0)
39:
40:
41: #define __WIFSIGNALED(status) \
42: (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
43:
44:
45: #define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
46:
47:
48:
49: #ifdef WCONTINUED
50: # define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
51: #endif
52:
53:
54: #define __WCOREDUMP(status) ((status) & __WCOREFLAG)
55:
56:
57: #define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
58: #define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
59: #define __W_CONTINUED 0xffff
60: #define __WCOREFLAG 0x80
61:
62:
63: #ifdef __USE_BSD
64:
65: # include <endian.h>
66:
67: union wait
68: {
69: int w_status;
70: struct
71: {
72: # if __BYTE_ORDER == __LITTLE_ENDIAN
73: unsigned int __w_termsig:7;
74: unsigned int __w_coredump:1;
75: unsigned int __w_retcode:8;
76: unsigned int:16;
77: # endif
78: # if __BYTE_ORDER == __BIG_ENDIAN
79: unsigned int:16;
80: unsigned int __w_retcode:8;
81: unsigned int __w_coredump:1;
82: unsigned int __w_termsig:7;
83: # endif
84: } __wait_terminated;
85: struct
86: {
87: # if __BYTE_ORDER == __LITTLE_ENDIAN
88: unsigned int __w_stopval:8;
89: unsigned int __w_stopsig:8;
90: unsigned int:16;
91: # endif
92: # if __BYTE_ORDER == __BIG_ENDIAN
93: unsigned int:16;
94: unsigned int __w_stopsig:8;
95: unsigned int __w_stopval:8;
96: # endif
97: } __wait_stopped;
98: };
99:
100: # define w_termsig __wait_terminated.__w_termsig
101: # define w_coredump __wait_terminated.__w_coredump
102: # define w_retcode __wait_terminated.__w_retcode
103: # define w_stopsig __wait_stopped.__w_stopsig
104: # define w_stopval __wait_stopped.__w_stopval
105:
106: #endif