Replace ../include/wait.h with gdb_wait.h.
[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 Linux below).
43 We also fail to declare 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 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
90 #endif
91
92 #ifndef WSETSTOP
93 #define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8)))
94 #endif
95
96 /*
97 * For native 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
102 /* Bits in the third argument to `waitpid'. */
103 #ifndef WNOHANG
104 #define WNOHANG 1 /* Don't block waiting. */
105 #endif
106
107 #ifndef WUNTRACED
108 #define WUNTRACED 2 /* Report status of stopped children. */
109 #endif
110
111 #ifndef __WCLONE
112 #define __WCLONE 0x80000000 /* Wait for cloned process. */
113 #endif
114
115 #endif
This page took 0.031308 seconds and 4 git commands to generate.