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