wait.h 16 KB

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