/contrib/tcsh/tc.wait.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 155 lines · 104 code · 11 blank · 40 comment · 22 complexity · 686539fb4147e9cfcdf6a42f09ba5431 MD5 · raw file

  1. /* $Header: /p/tcsh/cvsroot/tcsh/tc.wait.h,v 3.15 2011/02/04 18:00:26 christos Exp $ */
  2. /*
  3. * tc.wait.h: <sys/wait.h> for machines that don't have it or have it and
  4. * is incorrect.
  5. */
  6. /*-
  7. * Copyright (c) 1980, 1991 The Regents of the University of California.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. Neither the name of the University nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. */
  34. #ifndef _h_tc_wait
  35. #define _h_tc_wait
  36. /*
  37. * a little complicated #include <sys/wait.h>! :-(
  38. * We try to use the system's wait.h when we can...
  39. */
  40. #if SYSVREL > 0 && !defined(__linux__) && !defined(__GNU__) && !defined(__GLIBC__)
  41. # ifdef hpux
  42. # ifndef __hpux
  43. # define NEEDwait
  44. # else
  45. # ifndef POSIX
  46. # define _BSD
  47. # endif
  48. # ifndef _CLASSIC_POSIX_TYPES
  49. # define _CLASSIC_POSIX_TYPES
  50. # endif
  51. # include <sys/wait.h> /* 7.0 fixed it again */
  52. # endif /* __hpux */
  53. # else /* hpux */
  54. # if (defined(OREO) || defined(IRIS4D) || defined(POSIX)) && !defined(_VMS_POSIX)
  55. # include <sys/wait.h>
  56. # else /* OREO || IRIS4D || POSIX */
  57. # define NEEDwait
  58. # endif /* OREO || IRIS4D || POSIX */
  59. # endif /* hpux */
  60. #else /* SYSVREL == 0 || glibc */
  61. # ifdef _MINIX
  62. # undef NEEDwait
  63. # include "mi.wait.h"
  64. # else
  65. # ifndef WINNT_NATIVE
  66. # include <sys/wait.h>
  67. # endif /* WINNT_NATIVE */
  68. # endif /* _MINIX */
  69. #endif /* SYSVREL == 0 || glibc */
  70. #ifdef NEEDwait
  71. /*
  72. * This wait is for big-endians and little endians
  73. */
  74. union wait {
  75. int w_status;
  76. # ifdef _SEQUENT_
  77. struct {
  78. unsigned short w_Termsig:7;
  79. unsigned short w_Coredump:1;
  80. unsigned short w_Retcode:8;
  81. } w_T;
  82. struct {
  83. unsigned short w_Stopval:8;
  84. unsigned short w_Stopsig:8;
  85. } w_S;
  86. };
  87. # define w_termsig w_T.w_Termsig
  88. # define w_coredump w_T.w_Coredump
  89. # define w_retcode w_T.w_Retcode
  90. # define w_stopval w_S.w_Stopval
  91. # define w_stopsig w_S.w_Stopsig
  92. # else /* _SEQUENT_ */
  93. # if defined(vax) || defined(__vax__) || defined(i386) || defined(_I386) || defined(__i386__)
  94. union {
  95. struct {
  96. unsigned int w_Termsig:7;
  97. unsigned int w_Coredump:1;
  98. unsigned int w_Retcode:8;
  99. unsigned int w_Dummy:16;
  100. } w_T;
  101. struct {
  102. unsigned int w_Stopval:8;
  103. unsigned int w_Stopsig:8;
  104. unsigned int w_Dummy:16;
  105. } w_S;
  106. } w_P;
  107. # else /* mc68000 || sparc || ??? */
  108. # if defined(_CRAY) || defined(ANY_OTHER_64BIT_MACHINE)
  109. # define DUMMY_BITS 48
  110. # else /* _CRAY */
  111. # define DUMMY_BITS 16
  112. # endif /* _CRAY */
  113. union {
  114. struct {
  115. unsigned int w_Dummy:DUMMY_BITS;
  116. unsigned int w_Retcode:8;
  117. unsigned int w_Coredump:1;
  118. unsigned int w_Termsig:7;
  119. } w_T;
  120. struct {
  121. unsigned int w_Dummy:DUMMY_BITS;
  122. unsigned int w_Stopsig:8;
  123. unsigned int w_Stopval:8;
  124. } w_S;
  125. } w_P;
  126. # endif /* vax || __vax__ || i386 || _I386 || __i386__ */
  127. };
  128. # define w_termsig w_P.w_T.w_Termsig
  129. # define w_coredump w_P.w_T.w_Coredump
  130. # define w_retcode w_P.w_T.w_Retcode
  131. # define w_stopval w_P.w_S.w_Stopval
  132. # define w_stopsig w_P.w_S.w_Stopsig
  133. # endif /* _SEQUENT_ */
  134. # ifndef WNOHANG
  135. # define WNOHANG 1 /* dont hang in wait */
  136. # endif
  137. # ifndef WUNTRACED
  138. # define WUNTRACED 2 /* tell about stopped, untraced children */
  139. # endif
  140. # define WSTOPPED 0177
  141. # define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED)
  142. # define WIFSIGNALED(x) (((x).w_stopval != WSTOPPED) && ((x).w_termsig != 0))
  143. #endif /* NEEDwait */
  144. #endif /* _h_tc_wait */