Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / include / waitdefs.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)waitdefs.h       1.10 03/02/25 Copyright 1995-2003 J. Schilling */
14 /*
15  *      Definitions to deal with various kinds of wait flavour
16  *
17  *      Copyright (c) 1995-2003 J. Schilling
18  */
19 /*
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License version 2
22  * as published by the Free Software Foundation.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License along with
30  * this program; see the file COPYING.  If not, write to the Free Software
31  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32  */
33
34 #ifndef _WAITDEFS_H
35 #define _WAITDEFS_H
36
37 #ifndef _MCONFIG_H
38 #include <mconfig.h>
39 #endif
40
41 /*
42  * Needed for SysVr4
43  */
44 #ifndef _INCL_SYS_TYPES_H
45 #include <sys/types.h>
46 #define _INCL_SYS_TYPES_H
47 #endif
48
49 #if     defined(HAVE_WAIT_H)
50 #       ifndef  _INCL_WAIT_H
51 #       include <wait.h>
52 #       define  _INCL_WAIT_H
53 #       endif
54 #else
55 /*
56  * K&R Compiler doesn't like #elif
57  */
58 #       if      defined(HAVE_SYS_WAIT_H)        /* POSIX.1 compl. sys/wait.h */
59 #       undef   HAVE_UNION_WAIT                 /* POSIX.1 doesn't use U_W   */
60 #               ifndef  _INCL_SYS_WAIT_H
61 #               include <sys/wait.h>
62 #               define  _INCL_SYS_WAIT_H
63 #               endif
64 #       else
65 #       if      defined(HAVE_UNION_WAIT)        /* Pure BSD U_W / sys/wait.h */
66 #               ifndef  _INCL_SYS_WAIT_H
67 #               include <sys/wait.h>
68 #               define  _INCL_SYS_WAIT_H
69 #               endif
70 #       endif
71 #       endif
72 #endif
73
74 #ifdef  __cplusplus
75 extern "C" {
76 #endif
77
78 #ifdef HAVE_UNION_WAIT
79 #       define WAIT_T union wait
80 #       ifndef WSTOPPED
81 #               define  WSTOPPED        0x7F
82 #       endif
83 #       ifndef WTERMSIG
84 #               define WTERMSIG(status)         ((status).w_termsig)
85 #       endif
86 #       ifndef WCOREDUMP
87 #               define WCOREDUMP(status)        ((status).w_coredump)
88 #       endif
89 #       ifndef WEXITSTATUS
90 #               define WEXITSTATUS(status)      ((status).w_retcode)
91 #       endif
92 #       ifndef WSTOPSIG
93 #               define WSTOPSIG(status)         ((status).w_stopsig)
94 #       endif
95 #       ifndef WIFSTOPPED
96 #               define WIFSTOPPED(status)       ((status).w_stopval == \
97                                                                 WSTOPPED)
98 #       endif
99 #       ifndef WIFSIGNALED
100 #               define WIFSIGNALED(status)      ((status).w_stopval != \
101                                                 WSTOPPED && \
102                                                 (status).w_termsig != 0)
103 #       endif
104 #       ifndef WIFEXITED
105 #               define WIFEXITED(status)        ((status).w_stopval != \
106                                                 WSTOPPED && \
107                                                 (status).w_termsig == 0)
108 #       endif
109 #else
110 #       define WAIT_T int
111 #       ifndef WTERMSIG
112 #               define WTERMSIG(status)         ((status) & 0x7F)
113 #       endif
114 #       ifndef WCOREDUMP
115 #               define WCOREDUMP(status)        ((status) & 0x80)
116 #       endif
117 #       ifndef WEXITSTATUS
118 #               define WEXITSTATUS(status)      (((status) >> 8) & 0xFF)
119 #       endif
120 #       ifndef WSTOPSIG
121 #               define WSTOPSIG(status)         (((status) >> 8) & 0xFF)
122 #       endif
123 #       ifndef WIFSTOPPED
124 #               define  WIFSTOPPED(status)      (((status) & 0xFF) == 0x7F)
125 #       endif
126 #       ifndef WIFSIGNALED
127 #               define  WIFSIGNALED(status)     (((status) & 0xFF) != 0x7F && \
128                                                 WTERMSIG(status) != 0)
129 #       endif
130 #       ifndef WIFEXITED
131 #               define  WIFEXITED(status)       (((status) & 0xFF) == 0)
132 #       endif
133 #endif
134
135
136 #ifndef WCOREFLG
137 #define WCOREFLG        0x80
138 #endif
139
140 #ifndef WSTOPFLG
141 #define WSTOPFLG        0x7F
142 #endif
143
144 #ifndef WCONTFLG
145 #define WCONTFLG        0xFFFF
146 #endif
147
148 #ifdef  __cplusplus
149 }
150 #endif
151
152 #endif  /* _WAITDEFS_H */