xref: /dflybsd-src/contrib/bmake/wait.h (revision 01e196c8756b7c1bc7ca62d0d9870afee6a0015d)
1*01e196c8SJohn Marino /* NAME:
2*01e196c8SJohn Marino  *	wait.h - compensate for what vendors leave out
3*01e196c8SJohn Marino  *
4*01e196c8SJohn Marino  * AUTHOR:
5*01e196c8SJohn Marino  *	Simon J. Gerraty <sjg@crufty.net>
6*01e196c8SJohn Marino  */
7*01e196c8SJohn Marino /*
8*01e196c8SJohn Marino  * RCSid:
9*01e196c8SJohn Marino  *	$Id: wait.h,v 1.6 2002/11/26 07:53:06 sjg Exp $
10*01e196c8SJohn Marino  *
11*01e196c8SJohn Marino  *      @(#)Copyright (c) 1994, Simon J. Gerraty.
12*01e196c8SJohn Marino  *
13*01e196c8SJohn Marino  *      This is free software.  It comes with NO WARRANTY.
14*01e196c8SJohn Marino  *      Permission to use, modify and distribute this source code
15*01e196c8SJohn Marino  *      is granted subject to the following conditions.
16*01e196c8SJohn Marino  *      1/ that the above copyright notice and this notice
17*01e196c8SJohn Marino  *      are preserved in all copies and that due credit be given
18*01e196c8SJohn Marino  *      to the author.
19*01e196c8SJohn Marino  *      2/ that any changes to this code are clearly commented
20*01e196c8SJohn Marino  *      as such so that the author does not get blamed for bugs
21*01e196c8SJohn Marino  *      other than his own.
22*01e196c8SJohn Marino  *
23*01e196c8SJohn Marino  *      Please send copies of changes and bug-fixes to:
24*01e196c8SJohn Marino  *      sjg@crufty.net
25*01e196c8SJohn Marino  */
26*01e196c8SJohn Marino 
27*01e196c8SJohn Marino #include <sys/wait.h>
28*01e196c8SJohn Marino 
29*01e196c8SJohn Marino #ifdef sun386
30*01e196c8SJohn Marino # define UNION_WAIT
31*01e196c8SJohn Marino # define WEXITSTATUS(x) ((&x)->w_retcode)
32*01e196c8SJohn Marino # define WTERMSIG(x) ((&x)->w_termsig)
33*01e196c8SJohn Marino # define WSTOPSIG(x) ((&x)->w_stopsig)
34*01e196c8SJohn Marino # define HAVE_WAIT4
35*01e196c8SJohn Marino #endif
36*01e196c8SJohn Marino 
37*01e196c8SJohn Marino #ifndef WAIT_T
38*01e196c8SJohn Marino # ifdef UNION_WAIT
39*01e196c8SJohn Marino #   define WAIT_T union wait
40*01e196c8SJohn Marino #   define WAIT_STATUS(x) (x).w_status
41*01e196c8SJohn Marino # else
42*01e196c8SJohn Marino #   define WAIT_T int
43*01e196c8SJohn Marino #   define WAIT_STATUS(x) x
44*01e196c8SJohn Marino # endif
45*01e196c8SJohn Marino #endif
46*01e196c8SJohn Marino 
47*01e196c8SJohn Marino #ifndef WEXITSTATUS
48*01e196c8SJohn Marino # define WEXITSTATUS(_X)       (((int)(_X)>>8)&0377)
49*01e196c8SJohn Marino #endif
50*01e196c8SJohn Marino #ifndef WSTOPPED
51*01e196c8SJohn Marino # define WSTOPPED 0177
52*01e196c8SJohn Marino #endif
53*01e196c8SJohn Marino #ifndef WSTOPSIG
54*01e196c8SJohn Marino # define WSTOPSIG(x) WSTOPPED
55*01e196c8SJohn Marino #endif
56*01e196c8SJohn Marino 
57*01e196c8SJohn Marino #ifdef UNION_WAIT
58*01e196c8SJohn Marino #ifndef WSET_STOPCODE
59*01e196c8SJohn Marino #define WSET_STOPCODE(x, sig) ((&x)->w_stopsig = (sig))
60*01e196c8SJohn Marino #endif
61*01e196c8SJohn Marino #ifndef WSET_EXITCODE
62*01e196c8SJohn Marino #define WSET_EXITCODE(x, ret, sig) ((&x)->w_termsig = (sig), (&x)->w_retcode = (ret))
63*01e196c8SJohn Marino #endif
64*01e196c8SJohn Marino #else
65*01e196c8SJohn Marino #ifndef WSET_STOPCODE
66*01e196c8SJohn Marino #define WSET_STOPCODE(x, sig) ((x) = ((sig) << 8) | 0177)
67*01e196c8SJohn Marino #endif
68*01e196c8SJohn Marino #ifndef WSET_EXITCODE
69*01e196c8SJohn Marino #define WSET_EXITCODE(x, ret, sig) ((x) = (ret << 8) | (sig))
70*01e196c8SJohn Marino #endif
71*01e196c8SJohn Marino #endif
72*01e196c8SJohn Marino 
73*01e196c8SJohn Marino #ifndef HAVE_WAITPID
74*01e196c8SJohn Marino # ifdef HAVE_WAIT4
75*01e196c8SJohn Marino #   define waitpid(pid, statusp, flags)	 wait4(pid, statusp, flags, (char *)0)
76*01e196c8SJohn Marino # else
77*01e196c8SJohn Marino #   ifdef HAVE_WAIT3
78*01e196c8SJohn Marino #     define waitpid(pid, statusp, flags) wait3(statusp, flags, (char *)0)
79*01e196c8SJohn Marino #   endif
80*01e196c8SJohn Marino # endif
81*01e196c8SJohn Marino #endif
82