2004-03-17 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / gdb_wait.h
1 /* Standard wait macros.
2 Copyright 2000 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 2 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, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 #ifndef GDB_WAIT_H
22 #define GDB_WAIT_H
23
24 #ifdef HAVE_SYS_WAIT_H
25 #include <sys/wait.h> /* POSIX */
26 #else
27 #ifdef HAVE_WAIT_H
28 #include <wait.h> /* legacy */
29 #endif
30 #endif
31
32 /* Define how to access the int that the wait system call stores.
33 This has been compatible in all Unix systems since time immemorial,
34 but various well-meaning people have defined various different
35 words for the same old bits in the same old int (sometimes claimed
36 to be a struct). We just know it's an int and we use these macros
37 to access the bits. */
38
39 /* The following macros are defined equivalently to their definitions
40 in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1
41 <sys/wait.h> defines, since our code does not use waitpid() (but
42 NOTE exception for GNU/Linux below). We also fail to declare
43 wait() and waitpid(). */
44
45 #ifndef WIFEXITED
46 #define WIFEXITED(w) (((w)&0377) == 0)
47 #endif
48
49 #ifndef WIFSIGNALED
50 #define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0)
51 #endif
52
53 #ifndef WIFSTOPPED
54 #ifdef IBM6000
55
56 /* Unfortunately, the above comment (about being compatible in all Unix
57 systems) is not quite correct for AIX, sigh. And AIX 3.2 can generate
58 status words like 0x57c (sigtrap received after load), and gdb would
59 choke on it. */
60
61 #define WIFSTOPPED(w) ((w)&0x40)
62
63 #else
64 #define WIFSTOPPED(w) (((w)&0377) == 0177)
65 #endif
66 #endif
67
68 #ifndef WEXITSTATUS
69 #define WEXITSTATUS(w) (((w) >> 8) & 0377) /* same as WRETCODE */
70 #endif
71
72 #ifndef WTERMSIG
73 #define WTERMSIG(w) ((w) & 0177)
74 #endif
75
76 #ifndef WSTOPSIG
77 #define WSTOPSIG WEXITSTATUS
78 #endif
79
80 /* These are not defined in POSIX, but are used by our programs. */
81
82 #define WAITTYPE int
83
84 #ifndef WCOREDUMP
85 #define WCOREDUMP(w) (((w)&0200) != 0)
86 #endif
87
88 #ifndef WSETEXIT
89 # ifdef W_EXITCODE
90 #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
91 # else
92 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
93 # endif
94 #endif
95
96 #ifndef WSETSTOP
97 # ifdef W_STOPCODE
98 #define WSETSTOP(w,sig) ((w) = W_STOPCODE(sig))
99 # else
100 #define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
101 # endif
102 #endif
103
104 /* For native GNU/Linux we may use waitpid and the __WCLONE option.
105 <GRIPE> It is of course dangerous not to use the REAL header file...
106 </GRIPE>. */
107
108 /* Bits in the third argument to `waitpid'. */
109 #ifndef WNOHANG
110 #define WNOHANG 1 /* Don't block waiting. */
111 #endif
112
113 #ifndef WUNTRACED
114 #define WUNTRACED 2 /* Report status of stopped children. */
115 #endif
116
117 #ifndef __WCLONE
118 #define __WCLONE 0x80000000 /* Wait for cloned process. */
119 #endif
120
121 #endif
This page took 0.035249 seconds and 4 git commands to generate.