* gold/incremental.cc (Sized_relobj_incr::Sized_relobj_incr):
[binutils-gdb.git] / 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 #ifndef WSETEXIT
82 # ifdef W_EXITCODE
83 #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
84 # else
85 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
86 # endif
87 #endif
88
89 #ifndef WSETSTOP
90 # ifdef W_STOPCODE
91 #define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
92 # else
93 #define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
94 # endif
95 #endif
96
97 /* For native GNU/Linux we may use waitpid and the __WCLONE option.
98 <GRIPE> It is of course dangerous not to use the REAL header file...
99 </GRIPE>. */
100
101 /* Bits in the third argument to `waitpid'. */
102 #ifndef WNOHANG
103 #define WNOHANG 1 /* Don't block waiting. */
104 #endif
105
106 #ifndef WUNTRACED
107 #define WUNTRACED 2 /* Report status of stopped children. */
108 #endif
109
110 #ifndef __WCLONE
111 #define __WCLONE 0x80000000 /* Wait for cloned process. */
112 #endif
113
114 #endif