GDB (API)
/home/stan/gdb/src/gdb/common/gdb_wait.h
Go to the documentation of this file.
00001 /* Standard wait macros.
00002    Copyright (C) 2000-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 #ifndef GDB_WAIT_H
00020 #define GDB_WAIT_H
00021 
00022 #ifdef HAVE_SYS_WAIT_H
00023 #include <sys/wait.h> /* POSIX */
00024 #else
00025 #ifdef HAVE_WAIT_H
00026 #include <wait.h> /* legacy */
00027 #endif
00028 #endif
00029 
00030 /* Define how to access the int that the wait system call stores.
00031    This has been compatible in all Unix systems since time immemorial,
00032    but various well-meaning people have defined various different
00033    words for the same old bits in the same old int (sometimes claimed
00034    to be a struct).  We just know it's an int and we use these macros
00035    to access the bits.  */
00036 
00037 /* The following macros are defined equivalently to their definitions
00038    in POSIX.1.  We fail to define WNOHANG and WUNTRACED, which POSIX.1
00039    <sys/wait.h> defines, since our code does not use waitpid() (but
00040    NOTE exception for GNU/Linux below).  We also fail to declare
00041    wait() and waitpid().  */
00042 
00043 #ifndef WIFEXITED
00044 #define WIFEXITED(w)    (((w)&0377) == 0)
00045 #endif
00046 
00047 #ifndef WIFSIGNALED
00048 #define WIFSIGNALED(w)  (((w)&0377) != 0177 && ((w)&~0377) == 0)
00049 #endif
00050 
00051 #ifndef WIFSTOPPED
00052 #ifdef IBM6000
00053 
00054 /* Unfortunately, the above comment (about being compatible in all Unix 
00055    systems) is not quite correct for AIX, sigh.  And AIX 3.2 can generate
00056    status words like 0x57c (sigtrap received after load), and gdb would
00057    choke on it.  */
00058 
00059 #define WIFSTOPPED(w)   ((w)&0x40)
00060 
00061 #else
00062 #define WIFSTOPPED(w)   (((w)&0377) == 0177)
00063 #endif
00064 #endif
00065 
00066 #ifndef WEXITSTATUS
00067 #define WEXITSTATUS(w)  (((w) >> 8) & 0377) /* same as WRETCODE */
00068 #endif
00069 
00070 #ifndef WTERMSIG
00071 #define WTERMSIG(w)     ((w) & 0177)
00072 #endif
00073 
00074 #ifndef WSTOPSIG
00075 #define WSTOPSIG        WEXITSTATUS
00076 #endif
00077 
00078 /* These are not defined in POSIX, but are used by our programs.  */
00079 
00080 #ifndef WSETEXIT
00081 # ifdef W_EXITCODE
00082 #define WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
00083 # else
00084 #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
00085 # endif
00086 #endif
00087 
00088 #ifndef WSETSTOP
00089 # ifdef W_STOPCODE
00090 #define WSETSTOP(w,sig)    ((w) = W_STOPCODE(sig))
00091 # else
00092 #define WSETSTOP(w,sig)    ((w) = (0177 | ((sig) << 8)))
00093 # endif
00094 #endif
00095 
00096 /* For native GNU/Linux we may use waitpid and the __WCLONE option.
00097   <GRIPE> It is of course dangerous not to use the REAL header file...
00098   </GRIPE>.  */
00099 
00100 /* Bits in the third argument to `waitpid'.  */
00101 #ifndef WNOHANG
00102 #define WNOHANG         1       /* Don't block waiting.  */
00103 #endif
00104 
00105 #ifndef WUNTRACED
00106 #define WUNTRACED       2       /* Report status of stopped children.  */
00107 #endif
00108 
00109 #ifndef __WCLONE
00110 #define __WCLONE        0x80000000 /* Wait for cloned process.  */
00111 #endif
00112 
00113 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines