gdb/common/gdb_wait.h - gdb

Macros defined

Source code

  1. /* Standard wait macros.
  2.    Copyright (C) 2000-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef GDB_WAIT_H
  15. #define GDB_WAIT_H

  16. #ifdef HAVE_SYS_WAIT_H
  17. #include <sys/wait.h> /* POSIX */
  18. #else
  19. #ifdef HAVE_WAIT_H
  20. #include <wait.h> /* legacy */
  21. #endif
  22. #endif

  23. /* Define how to access the int that the wait system call stores.
  24.    This has been compatible in all Unix systems since time immemorial,
  25.    but various well-meaning people have defined various different
  26.    words for the same old bits in the same old int (sometimes claimed
  27.    to be a struct).  We just know it's an int and we use these macros
  28.    to access the bits.  */

  29. /* The following macros are defined equivalently to their definitions
  30.    in POSIX.1.  We fail to define WNOHANG and WUNTRACED, which POSIX.1
  31.    <sys/wait.h> defines, since our code does not use waitpid() (but
  32.    NOTE exception for GNU/Linux below).  We also fail to declare
  33.    wait() and waitpid().  */

  34. #ifndef        WIFEXITED
  35. #define WIFEXITED(w)        (((w)&0377) == 0)
  36. #endif

  37. #ifndef        WIFSIGNALED
  38. #define WIFSIGNALED(w)        (((w)&0377) != 0177 && ((w)&~0377) == 0)
  39. #endif

  40. #ifndef        WIFSTOPPED
  41. #ifdef IBM6000

  42. /* Unfortunately, the above comment (about being compatible in all Unix
  43.    systems) is not quite correct for AIX, sigh.  And AIX 3.2 can generate
  44.    status words like 0x57c (sigtrap received after load), and gdb would
  45.    choke on it.  */

  46. #define WIFSTOPPED(w)        ((w)&0x40)

  47. #else
  48. #define WIFSTOPPED(w)        (((w)&0377) == 0177)
  49. #endif
  50. #endif

  51. #ifndef        WEXITSTATUS
  52. #define WEXITSTATUS(w)        (((w) >> 8) & 0377) /* same as WRETCODE */
  53. #endif

  54. #ifndef        WTERMSIG
  55. #define WTERMSIG(w)        ((w) & 0177)
  56. #endif

  57. #ifndef        WSTOPSIG
  58. #define WSTOPSIG        WEXITSTATUS
  59. #endif

  60. /* These are not defined in POSIX, but are used by our programs.  */

  61. #ifndef        WSETEXIT
  62. # ifdef        W_EXITCODE
  63. #define        WSETEXIT(w,status) ((w) = W_EXITCODE(status,0))
  64. # else
  65. #define WSETEXIT(w,status) ((w) = (0 | ((status) << 8)))
  66. # endif
  67. #endif

  68. #ifndef        WSETSTOP
  69. # ifdef        W_STOPCODE
  70. #define        WSETSTOP(w,sig)    ((w) = W_STOPCODE(sig))
  71. # else
  72. #define WSETSTOP(w,sig)           ((w) = (0177 | ((sig) << 8)))
  73. # endif
  74. #endif

  75. /* For native GNU/Linux we may use waitpid and the __WCLONE option.
  76.   <GRIPE> It is of course dangerous not to use the REAL header file...
  77.   </GRIPE>.  */

  78. /* Bits in the third argument to `waitpid'.  */
  79. #ifndef WNOHANG
  80. #define        WNOHANG                1        /* Don't block waiting.  */
  81. #endif

  82. #ifndef WUNTRACED
  83. #define        WUNTRACED        2        /* Report status of stopped children.  */
  84. #endif

  85. #ifndef __WCLONE
  86. #define __WCLONE        0x80000000 /* Wait for cloned process.  */
  87. #endif

  88. #endif