Import gdb 7.3 into vendor branch
[dragonfly.git] / contrib / gdb-7 / gdb / gdb_wait.h
1 /* Standard wait macros.
2    Copyright (C) 2000, 2007, 2008, 2009, 2010, 2011
3    Free Software Foundation, Inc.
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
9    the Free Software Foundation; either version 3 of the License, or
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
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
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
41    NOTE exception for GNU/Linux below).  We also fail to declare
42    wait() and waitpid().  */
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
58    choke on it.  */
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
88 # ifdef W_EXITCODE
89 #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
90 # else
91 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
92 # endif
93 #endif
94
95 #ifndef WSETSTOP
96 # ifdef W_STOPCODE
97 #define WSETSTOP(w,sig)    ((w) = W_STOPCODE(sig))
98 # else
99 #define WSETSTOP(w,sig)    ((w) = (0177 | ((sig) << 8)))
100 # endif
101 #endif
102
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>.  */
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