41668637d8acbe8fabe6d9075908dda06fbe4b25
[platform/upstream/diffutils.git] / lib / sys_wait.in.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* A POSIX-like <sys/wait.h>.
4    Copyright (C) 2001-2003, 2005-2011 Free Software Foundation, Inc.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3, or (at your option)
9    any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software Foundation,
18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19
20
21 #ifndef _@GUARD_PREFIX@_SYS_WAIT_H
22
23 #if __GNUC__ >= 3
24 @PRAGMA_SYSTEM_HEADER@
25 #endif
26 @PRAGMA_COLUMNS@
27
28 /* The include_next requires a split double-inclusion guard.  */
29 #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
30 # @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
31 #endif
32
33 #ifndef _@GUARD_PREFIX@_SYS_WAIT_H
34 #define _@GUARD_PREFIX@_SYS_WAIT_H
35
36 /* Get pid_t.  */
37 #include <sys/types.h>
38
39
40 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
41
42 /* The definition of _GL_WARN_ON_USE is copied here.  */
43
44
45 #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
46 /* Unix API.  */
47
48 /* The following macros apply to an argument x, that is a status of a process,
49    as returned by waitpid().
50    On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and
51    WTERMSIG are bits 7..0, while BeOS uses the opposite.  Therefore programs
52    have to use the abstract macros.  */
53
54 /* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
55    is true.  */
56 # ifndef WIFSIGNALED
57 #  define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
58 # endif
59 # ifndef WIFEXITED
60 #  define WIFEXITED(x) (WTERMSIG (x) == 0)
61 # endif
62 # ifndef WIFSTOPPED
63 #  define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
64 # endif
65
66 /* The termination signal. Only to be accessed if WIFSIGNALED(x) is true.  */
67 # ifndef WTERMSIG
68 #  define WTERMSIG(x) ((x) & 0x7f)
69 # endif
70
71 /* The exit status. Only to be accessed if WIFEXITED(x) is true.  */
72 # ifndef WEXITSTATUS
73 #  define WEXITSTATUS(x) (((x) >> 8) & 0xff)
74 # endif
75
76 /* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true.  */
77 # ifndef WSTOPSIG
78 #  define WSTOPSIG(x) (((x) >> 8) & 0x7f)
79 # endif
80
81 /* True if the process dumped core.  Not standardized by POSIX.  */
82 # ifndef WCOREDUMP
83 #  define WCOREDUMP(x) ((x) & 0x80)
84 # endif
85
86 #else
87 /* Native Windows API.  */
88
89 # include <signal.h> /* for SIGTERM */
90
91 /* The following macros apply to an argument x, that is a status of a process,
92    as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
93    This value is simply an 'int', not composed of bit fields.  */
94
95 /* When an unhandled fatal signal terminates a process, the exit code is 3.  */
96 # define WIFSIGNALED(x) ((x) == 3)
97 # define WIFEXITED(x) ((x) != 3)
98 # define WIFSTOPPED(x) 0
99
100 /* The signal that terminated a process is not known posthum.  */
101 # define WTERMSIG(x) SIGTERM
102
103 # define WEXITSTATUS(x) (x)
104
105 /* There are no stopping signals.  */
106 # define WSTOPSIG(x) 0
107
108 /* There are no core dumps.  */
109 # define WCOREDUMP(x) 0
110
111 #endif
112
113
114 /* Declarations of functions.  */
115
116 #if @GNULIB_WAITPID@
117 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
118 _GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
119 # endif
120 _GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
121 _GL_CXXALIASWARN (waitpid);
122 #elif defined GNULIB_POSIXCHECK
123 # undef waitpid
124 # if HAVE_RAW_DECL_WAITPID
125 _GL_WARN_ON_USE (waitpid, "waitpid is unportable - "
126                  "use gnulib module sys_wait for portability");
127 # endif
128 #endif
129
130
131 #endif /* _@GUARD_PREFIX@_SYS_WAIT_H */
132 #endif /* _@GUARD_PREFIX@_SYS_WAIT_H */