comparison src/syswait.h @ 46865:971ae7795f13

Only the include of sys/wait.h tests HAVE_SYS_WAIT_H. [!VMS] (WCOREDUMP, WEXITSTATUS, WIFEXITED, WIFSTOPPED, WIFSIGNALED) (WSTOPSIG, WTERMSIG): Define each one independently if not defined already.
author Richard M. Stallman <rms@gnu.org>
date Mon, 12 Aug 2002 17:27:57 +0000
parents d12c8d3334f4
children 23a1cea22d13
comparison
equal deleted inserted replaced
46864:df9f70dd69a4 46865:971ae7795f13
25 #ifndef EMACS_SYSWAIT_H 25 #ifndef EMACS_SYSWAIT_H
26 #define EMACS_SYSWAIT_H 26 #define EMACS_SYSWAIT_H
27 27
28 #ifndef VMS 28 #ifndef VMS
29 29
30 /* Try the approach recommended by autoconf. If this doesn't cause 30 /* This is now really the approach recommended by Autoconf. If this
31 trouble anywhere, remove the original code, which is #if'd out 31 doesn't cause trouble anywhere, remove the original code, which is
32 below. */ 32 #if'd out below. */
33 33
34 #if 1 34 #if 1
35 #include <sys/types.h> 35 #include <sys/types.h>
36 36
37 #ifdef HAVE_SYS_WAIT_H /* We have sys/wait.h with POSIXoid definitions. */ 37 #ifdef HAVE_SYS_WAIT_H /* We have sys/wait.h with POSIXoid definitions. */
38 #include <sys/wait.h>
39 #endif /* !HAVE_SYS_WAIT_H */
38 40
39 #include <sys/wait.h>
40 #ifndef WCOREDUMP /* not POSIX */ 41 #ifndef WCOREDUMP /* not POSIX */
41 #define WCOREDUMP(status) ((status) & 0x80) 42 #define WCOREDUMP(status) ((status) & 0x80)
42 #endif 43 #endif
43 44 #ifndef WEXITSTATUS
44 #else /* !HAVE_SYS_WAIT_H */
45
46 /* Note that sys/wait.h may still be included by stdlib.h or something
47 according to XPG. */
48
49 #undef WEXITSTATUS
50 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) 45 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
51 #undef WIFEXITED 46 #endif
47 #ifndef WIFEXITED
52 #define WIFEXITED(status) (WTERMSIG(status) == 0) 48 #define WIFEXITED(status) (WTERMSIG(status) == 0)
53 #undef WIFSTOPPED 49 #endif
50 #ifndef WIFSTOPPED
54 #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f) 51 #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
55 #undef WIFSIGNALED 52 #endif
53 #ifndef WIFSIGNALED
56 #define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status)) 54 #define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
57 #undef WSTOPSIG 55 #endif
56 #ifndef WSTOPSIG
58 #define WSTOPSIG(status) WEXITSTATUS(status) 57 #define WSTOPSIG(status) WEXITSTATUS(status)
59 #undef WTERMSIG 58 #endif
59 #ifndef WTERMSIG
60 #define WTERMSIG(status) ((status) & 0x7f) 60 #define WTERMSIG(status) ((status) & 0x7f)
61 #undef WCOREDUMP 61 #endif
62 #define WCOREDUMP(status) ((status) & 0x80)
63 #endif /* HAVE_SYS_WAIT_H */
64 62
65 #undef WAITTYPE 63 #undef WAITTYPE
66 #define WAITTYPE int 64 #define WAITTYPE int
67 #undef WRETCODE 65 #undef WRETCODE
68 #define WRETCODE(status) WEXITSTATUS (status) 66 #define WRETCODE(status) WEXITSTATUS (status)
69 67
70 #else /* !1 */ 68 #else /* 0 */
71 69
72 #ifndef WAITTYPE 70 #ifndef WAITTYPE
73 71
74 #ifdef WAIT_USE_INT 72 #ifdef WAIT_USE_INT
75 /* Some systems have union wait in their header, but we should use 73 /* Some systems have union wait in their header, but we should use
132 #endif 130 #endif
133 #endif /* BSD_SYSTEM || UNIPLUS || STRIDE || HPUX */ 131 #endif /* BSD_SYSTEM || UNIPLUS || STRIDE || HPUX */
134 #endif /* not WAIT_USE_INT */ 132 #endif /* not WAIT_USE_INT */
135 #endif /* no WAITTYPE */ 133 #endif /* no WAITTYPE */
136 134
137 #endif /* 1 */ 135 #endif /* 0 */
138 136
139 #else /* VMS */ 137 #else /* VMS */
140 138
141 #define WAITTYPE int 139 #define WAITTYPE int
142 #define WIFSTOPPED(w) 0 140 #define WIFSTOPPED(w) 0