1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2/* A POSIX-like <sys/wait.h>. 3 Copyright (C) 2001-2003, 2005-2012 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3, or (at your option) 8 any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 18 19#ifndef _GL_SYS_WAIT_H 20 21#if __GNUC__ >= 3 22#pragma GCC system_header 23#endif 24 25 26/* The include_next requires a split double-inclusion guard. */ 27#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 28# include_next <sys/wait.h> 29#endif 30 31#ifndef _GL_SYS_WAIT_H 32#define _GL_SYS_WAIT_H 33 34/* Get pid_t. */ 35#include <sys/types.h> 36 37 38/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 39#ifndef _GL_CXXDEFS_H 40#define _GL_CXXDEFS_H 41 42/* The three most frequent use cases of these macros are: 43 44 * For providing a substitute for a function that is missing on some 45 platforms, but is declared and works fine on the platforms on which 46 it exists: 47 48 #if @GNULIB_FOO@ 49 # if !@HAVE_FOO@ 50 _GL_FUNCDECL_SYS (foo, ...); 51 # endif 52 _GL_CXXALIAS_SYS (foo, ...); 53 _GL_CXXALIASWARN (foo); 54 #elif defined GNULIB_POSIXCHECK 55 ... 56 #endif 57 58 * For providing a replacement for a function that exists on all platforms, 59 but is broken/insufficient and needs to be replaced on some platforms: 60 61 #if @GNULIB_FOO@ 62 # if @REPLACE_FOO@ 63 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 64 # undef foo 65 # define foo rpl_foo 66 # endif 67 _GL_FUNCDECL_RPL (foo, ...); 68 _GL_CXXALIAS_RPL (foo, ...); 69 # else 70 _GL_CXXALIAS_SYS (foo, ...); 71 # endif 72 _GL_CXXALIASWARN (foo); 73 #elif defined GNULIB_POSIXCHECK 74 ... 75 #endif 76 77 * For providing a replacement for a function that exists on some platforms 78 but is broken/insufficient and needs to be replaced on some of them and 79 is additionally either missing or undeclared on some other platforms: 80 81 #if @GNULIB_FOO@ 82 # if @REPLACE_FOO@ 83 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 84 # undef foo 85 # define foo rpl_foo 86 # endif 87 _GL_FUNCDECL_RPL (foo, ...); 88 _GL_CXXALIAS_RPL (foo, ...); 89 # else 90 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 91 _GL_FUNCDECL_SYS (foo, ...); 92 # endif 93 _GL_CXXALIAS_SYS (foo, ...); 94 # endif 95 _GL_CXXALIASWARN (foo); 96 #elif defined GNULIB_POSIXCHECK 97 ... 98 #endif 99*/ 100 101/* _GL_EXTERN_C declaration; 102 performs the declaration with C linkage. */ 103#if defined __cplusplus 104# define _GL_EXTERN_C extern "C" 105#else 106# define _GL_EXTERN_C extern 107#endif 108 109/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 110 declares a replacement function, named rpl_func, with the given prototype, 111 consisting of return type, parameters, and attributes. 112 Example: 113 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 114 _GL_ARG_NONNULL ((1))); 115 */ 116#define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 117 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 118#define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 119 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 120 121/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 122 declares the system function, named func, with the given prototype, 123 consisting of return type, parameters, and attributes. 124 Example: 125 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 126 _GL_ARG_NONNULL ((1))); 127 */ 128#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 129 _GL_EXTERN_C rettype func parameters_and_attributes 130 131/* _GL_CXXALIAS_RPL (func, rettype, parameters); 132 declares a C++ alias called GNULIB_NAMESPACE::func 133 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 134 Example: 135 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 136 */ 137#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 138 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 139#if defined __cplusplus && defined GNULIB_NAMESPACE 140# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 141 namespace GNULIB_NAMESPACE \ 142 { \ 143 rettype (*const func) parameters = ::rpl_func; \ 144 } \ 145 _GL_EXTERN_C int _gl_cxxalias_dummy 146#else 147# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 148 _GL_EXTERN_C int _gl_cxxalias_dummy 149#endif 150 151/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 152 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 153 except that the C function rpl_func may have a slightly different 154 declaration. A cast is used to silence the "invalid conversion" error 155 that would otherwise occur. */ 156#if defined __cplusplus && defined GNULIB_NAMESPACE 157# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 158 namespace GNULIB_NAMESPACE \ 159 { \ 160 rettype (*const func) parameters = \ 161 reinterpret_cast<rettype(*)parameters>(::rpl_func); \ 162 } \ 163 _GL_EXTERN_C int _gl_cxxalias_dummy 164#else 165# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 166 _GL_EXTERN_C int _gl_cxxalias_dummy 167#endif 168 169/* _GL_CXXALIAS_SYS (func, rettype, parameters); 170 declares a C++ alias called GNULIB_NAMESPACE::func 171 that redirects to the system provided function func, if GNULIB_NAMESPACE 172 is defined. 173 Example: 174 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 175 */ 176#if defined __cplusplus && defined GNULIB_NAMESPACE 177 /* If we were to write 178 rettype (*const func) parameters = ::func; 179 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls 180 better (remove an indirection through a 'static' pointer variable), 181 but then the _GL_CXXALIASWARN macro below would cause a warning not only 182 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ 183# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 184 namespace GNULIB_NAMESPACE \ 185 { \ 186 static rettype (*func) parameters = ::func; \ 187 } \ 188 _GL_EXTERN_C int _gl_cxxalias_dummy 189#else 190# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 191 _GL_EXTERN_C int _gl_cxxalias_dummy 192#endif 193 194/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 195 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 196 except that the C function func may have a slightly different declaration. 197 A cast is used to silence the "invalid conversion" error that would 198 otherwise occur. */ 199#if defined __cplusplus && defined GNULIB_NAMESPACE 200# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 201 namespace GNULIB_NAMESPACE \ 202 { \ 203 static rettype (*func) parameters = \ 204 reinterpret_cast<rettype(*)parameters>(::func); \ 205 } \ 206 _GL_EXTERN_C int _gl_cxxalias_dummy 207#else 208# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 209 _GL_EXTERN_C int _gl_cxxalias_dummy 210#endif 211 212/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 213 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 214 except that the C function is picked among a set of overloaded functions, 215 namely the one with rettype2 and parameters2. Two consecutive casts 216 are used to silence the "cannot find a match" and "invalid conversion" 217 errors that would otherwise occur. */ 218#if defined __cplusplus && defined GNULIB_NAMESPACE 219 /* The outer cast must be a reinterpret_cast. 220 The inner cast: When the function is defined as a set of overloaded 221 functions, it works as a static_cast<>, choosing the designated variant. 222 When the function is defined as a single variant, it works as a 223 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 224# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 225 namespace GNULIB_NAMESPACE \ 226 { \ 227 static rettype (*func) parameters = \ 228 reinterpret_cast<rettype(*)parameters>( \ 229 (rettype2(*)parameters2)(::func)); \ 230 } \ 231 _GL_EXTERN_C int _gl_cxxalias_dummy 232#else 233# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 234 _GL_EXTERN_C int _gl_cxxalias_dummy 235#endif 236 237/* _GL_CXXALIASWARN (func); 238 causes a warning to be emitted when ::func is used but not when 239 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 240 variants. */ 241#if defined __cplusplus && defined GNULIB_NAMESPACE 242# define _GL_CXXALIASWARN(func) \ 243 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 244# define _GL_CXXALIASWARN_1(func,namespace) \ 245 _GL_CXXALIASWARN_2 (func, namespace) 246/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 247 we enable the warning only when not optimizing. */ 248# if !__OPTIMIZE__ 249# define _GL_CXXALIASWARN_2(func,namespace) \ 250 _GL_WARN_ON_USE (func, \ 251 "The symbol ::" #func " refers to the system function. " \ 252 "Use " #namespace "::" #func " instead.") 253# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 254# define _GL_CXXALIASWARN_2(func,namespace) \ 255 extern __typeof__ (func) func 256# else 257# define _GL_CXXALIASWARN_2(func,namespace) \ 258 _GL_EXTERN_C int _gl_cxxalias_dummy 259# endif 260#else 261# define _GL_CXXALIASWARN(func) \ 262 _GL_EXTERN_C int _gl_cxxalias_dummy 263#endif 264 265/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 266 causes a warning to be emitted when the given overloaded variant of ::func 267 is used but not when GNULIB_NAMESPACE::func is used. */ 268#if defined __cplusplus && defined GNULIB_NAMESPACE 269# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 270 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 271 GNULIB_NAMESPACE) 272# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 273 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 274/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 275 we enable the warning only when not optimizing. */ 276# if !__OPTIMIZE__ 277# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 278 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 279 "The symbol ::" #func " refers to the system function. " \ 280 "Use " #namespace "::" #func " instead.") 281# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 282# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 283 extern __typeof__ (func) func 284# else 285# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 286 _GL_EXTERN_C int _gl_cxxalias_dummy 287# endif 288#else 289# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 290 _GL_EXTERN_C int _gl_cxxalias_dummy 291#endif 292 293#endif /* _GL_CXXDEFS_H */ 294 295/* The definition of _GL_WARN_ON_USE is copied here. */ 296#ifndef _GL_WARN_ON_USE 297 298# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 299/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 300# define _GL_WARN_ON_USE(function, message) \ 301extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 302# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 303/* Verify the existence of the function. */ 304# define _GL_WARN_ON_USE(function, message) \ 305extern __typeof__ (function) function 306# else /* Unsupported. */ 307# define _GL_WARN_ON_USE(function, message) \ 308_GL_WARN_EXTERN_C int _gl_warn_on_use 309# endif 310#endif 311 312/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 313 is like _GL_WARN_ON_USE (function, "string"), except that the function is 314 declared with the given prototype, consisting of return type, parameters, 315 and attributes. 316 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 317 not work in this case. */ 318#ifndef _GL_WARN_ON_USE_CXX 319# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 320# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 321extern rettype function parameters_and_attributes \ 322 __attribute__ ((__warning__ (msg))) 323# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 324/* Verify the existence of the function. */ 325# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 326extern rettype function parameters_and_attributes 327# else /* Unsupported. */ 328# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 329_GL_WARN_EXTERN_C int _gl_warn_on_use 330# endif 331#endif 332 333/* _GL_WARN_EXTERN_C declaration; 334 performs the declaration with C linkage. */ 335#ifndef _GL_WARN_EXTERN_C 336# if defined __cplusplus 337# define _GL_WARN_EXTERN_C extern "C" 338# else 339# define _GL_WARN_EXTERN_C extern 340# endif 341#endif 342 343 344#if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 345/* Unix API. */ 346 347/* The following macros apply to an argument x, that is a status of a process, 348 as returned by waitpid(). 349 On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and 350 WTERMSIG are bits 7..0, while BeOS uses the opposite. Therefore programs 351 have to use the abstract macros. */ 352 353/* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x) 354 is true. */ 355# ifndef WIFSIGNALED 356# define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f) 357# endif 358# ifndef WIFEXITED 359# define WIFEXITED(x) (WTERMSIG (x) == 0) 360# endif 361# ifndef WIFSTOPPED 362# define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f) 363# endif 364 365/* The termination signal. Only to be accessed if WIFSIGNALED(x) is true. */ 366# ifndef WTERMSIG 367# define WTERMSIG(x) ((x) & 0x7f) 368# endif 369 370/* The exit status. Only to be accessed if WIFEXITED(x) is true. */ 371# ifndef WEXITSTATUS 372# define WEXITSTATUS(x) (((x) >> 8) & 0xff) 373# endif 374 375/* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true. */ 376# ifndef WSTOPSIG 377# define WSTOPSIG(x) (((x) >> 8) & 0x7f) 378# endif 379 380/* True if the process dumped core. Not standardized by POSIX. */ 381# ifndef WCOREDUMP 382# define WCOREDUMP(x) ((x) & 0x80) 383# endif 384 385#else 386/* Native Windows API. */ 387 388# include <signal.h> /* for SIGTERM */ 389 390/* The following macros apply to an argument x, that is a status of a process, 391 as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess(). 392 This value is simply an 'int', not composed of bit fields. */ 393 394/* When an unhandled fatal signal terminates a process, the exit code is 3. */ 395# define WIFSIGNALED(x) ((x) == 3) 396# define WIFEXITED(x) ((x) != 3) 397# define WIFSTOPPED(x) 0 398 399/* The signal that terminated a process is not known posthum. */ 400# define WTERMSIG(x) SIGTERM 401 402# define WEXITSTATUS(x) (x) 403 404/* There are no stopping signals. */ 405# define WSTOPSIG(x) 0 406 407/* There are no core dumps. */ 408# define WCOREDUMP(x) 0 409 410#endif 411 412 413/* Declarations of functions. */ 414 415#if 1 416# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 417_GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options)); 418# endif 419_GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options)); 420_GL_CXXALIASWARN (waitpid); 421#elif defined GNULIB_POSIXCHECK 422# undef waitpid 423# if HAVE_RAW_DECL_WAITPID 424_GL_WARN_ON_USE (waitpid, "waitpid is unportable - " 425 "use gnulib module sys_wait for portability"); 426# endif 427#endif 428 429 430#endif /* _GL_SYS_WAIT_H */ 431#endif /* _GL_SYS_WAIT_H */ 432