Commit | Line | Data |
---|---|---|
03f2053f | 1 | /* Standard wait macros. |
7b6bb8da JB |
2 | Copyright (C) 2000, 2007, 2008, 2009, 2010, 2011 |
3 | Free Software Foundation, Inc. | |
03f2053f AC |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
03f2053f AC |
10 | (at your option) any later version. |
11 | ||
12 | This program 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 | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
03f2053f AC |
19 | |
20 | #ifndef GDB_WAIT_H | |
21 | #define GDB_WAIT_H | |
22 | ||
23 | #ifdef HAVE_SYS_WAIT_H | |
24 | #include <sys/wait.h> /* POSIX */ | |
25 | #else | |
26 | #ifdef HAVE_WAIT_H | |
27 | #include <wait.h> /* legacy */ | |
28 | #endif | |
29 | #endif | |
30 | ||
31 | /* Define how to access the int that the wait system call stores. | |
32 | This has been compatible in all Unix systems since time immemorial, | |
33 | but various well-meaning people have defined various different | |
34 | words for the same old bits in the same old int (sometimes claimed | |
35 | to be a struct). We just know it's an int and we use these macros | |
36 | to access the bits. */ | |
37 | ||
38 | /* The following macros are defined equivalently to their definitions | |
39 | in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1 | |
40 | <sys/wait.h> defines, since our code does not use waitpid() (but | |
a4b6fc86 AC |
41 | NOTE exception for GNU/Linux below). We also fail to declare |
42 | wait() and waitpid(). */ | |
03f2053f AC |
43 | |
44 | #ifndef WIFEXITED | |
45 | #define WIFEXITED(w) (((w)&0377) == 0) | |
46 | #endif | |
47 | ||
48 | #ifndef WIFSIGNALED | |
49 | #define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) | |
50 | #endif | |
51 | ||
52 | #ifndef WIFSTOPPED | |
53 | #ifdef IBM6000 | |
54 | ||
55 | /* Unfortunately, the above comment (about being compatible in all Unix | |
56 | systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate | |
57 | status words like 0x57c (sigtrap received after load), and gdb would | |
0963b4bd | 58 | choke on it. */ |
03f2053f AC |
59 | |
60 | #define WIFSTOPPED(w) ((w)&0x40) | |
61 | ||
62 | #else | |
63 | #define WIFSTOPPED(w) (((w)&0377) == 0177) | |
64 | #endif | |
65 | #endif | |
66 | ||
67 | #ifndef WEXITSTATUS | |
68 | #define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */ | |
69 | #endif | |
70 | ||
71 | #ifndef WTERMSIG | |
72 | #define WTERMSIG(w) ((w) & 0177) | |
73 | #endif | |
74 | ||
75 | #ifndef WSTOPSIG | |
76 | #define WSTOPSIG WEXITSTATUS | |
77 | #endif | |
78 | ||
79 | /* These are not defined in POSIX, but are used by our programs. */ | |
80 | ||
81 | #define WAITTYPE int | |
82 | ||
83 | #ifndef WCOREDUMP | |
84 | #define WCOREDUMP(w) (((w)&0200) != 0) | |
85 | #endif | |
86 | ||
87 | #ifndef WSETEXIT | |
ca9c33a5 MS |
88 | # ifdef W_EXITCODE |
89 | #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0)) | |
90 | # else | |
03f2053f | 91 | #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8))) |
ca9c33a5 | 92 | # endif |
03f2053f AC |
93 | #endif |
94 | ||
95 | #ifndef WSETSTOP | |
ca9c33a5 | 96 | # ifdef W_STOPCODE |
6d5a5207 | 97 | #define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig)) |
ca9c33a5 | 98 | # else |
03f2053f | 99 | #define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8))) |
ca9c33a5 | 100 | # endif |
03f2053f AC |
101 | #endif |
102 | ||
a4b6fc86 AC |
103 | /* For native GNU/Linux we may use waitpid and the __WCLONE option. |
104 | <GRIPE> It is of course dangerous not to use the REAL header file... | |
105 | </GRIPE>. */ | |
03f2053f AC |
106 | |
107 | /* Bits in the third argument to `waitpid'. */ | |
108 | #ifndef WNOHANG | |
109 | #define WNOHANG 1 /* Don't block waiting. */ | |
110 | #endif | |
111 | ||
112 | #ifndef WUNTRACED | |
113 | #define WUNTRACED 2 /* Report status of stopped children. */ | |
114 | #endif | |
115 | ||
116 | #ifndef __WCLONE | |
117 | #define __WCLONE 0x80000000 /* Wait for cloned process. */ | |
118 | #endif | |
119 | ||
120 | #endif |