b29e25a70912c2caed9aa3ea6de2dc3bb53468da
[gnulib.git] / lib / spawn.in.h
1 /* Definitions for POSIX spawn interface.
2    Copyright (C) 2000, 2003-2004, 2008-2010 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
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 of the License, or
8    (at your option) 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 #ifndef _GL_SPAWN_H
19
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23 @PRAGMA_COLUMNS@
24
25 /* The include_next requires a split double-inclusion guard.  */
26 #if @HAVE_SPAWN_H@
27 # @INCLUDE_NEXT@ @NEXT_SPAWN_H@
28 #endif
29
30 #ifndef _GL_SPAWN_H
31 #define _GL_SPAWN_H
32
33 /* Get definitions of 'struct sched_param' and 'sigset_t'.
34    But avoid namespace pollution on glibc systems.  */
35 #if !(defined __GLIBC__ && !defined __UCLIBC__)
36 # include <sched.h>
37 # include <signal.h>
38 #endif
39
40 #include <sys/types.h>
41
42 #ifndef __THROW
43 # define __THROW
44 #endif
45
46 /* GCC 2.95 and later have "__restrict"; C99 compilers have
47    "restrict", and "configure" may have defined "restrict".
48    Other compilers use __restrict, __restrict__, and _Restrict, and
49    'configure' might #define 'restrict' to those words, so pick a
50    different name.  */
51 #ifndef _Restrict_
52 # if 199901L <= __STDC_VERSION__
53 #  define _Restrict_ restrict
54 # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
55 #  define _Restrict_ __restrict
56 # else
57 #  define _Restrict_
58 # endif
59 #endif
60 /* gcc 3.1 and up support the [restrict] syntax.  Don't trust
61    sys/cdefs.h's definition of __restrict_arr, though, as it
62    mishandles gcc -ansi -pedantic.  */
63 #ifndef _Restrict_arr_
64 # if ((199901L <= __STDC_VERSION__                                      \
65        || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__))     \
66            && !__STRICT_ANSI__))                                        \
67       && !defined __GNUG__)
68 #  define _Restrict_arr_ _Restrict_
69 # else
70 #  define _Restrict_arr_
71 # endif
72 #endif
73
74 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
75
76 /* The definition of _GL_ARG_NONNULL is copied here.  */
77
78 /* The definition of _GL_WARN_ON_USE is copied here.  */
79
80
81 /* Data structure to contain attributes for thread creation.  */
82 #if @REPLACE_POSIX_SPAWN@
83 # define posix_spawnattr_t rpl_posix_spawnattr_t
84 #endif
85 #if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@
86 typedef struct
87 {
88   short int _flags;
89   pid_t _pgrp;
90   sigset_t _sd;
91   sigset_t _ss;
92   struct sched_param _sp;
93   int _policy;
94   int __pad[16];
95 } posix_spawnattr_t;
96 #endif
97
98
99 /* Data structure to contain information about the actions to be
100    performed in the new process with respect to file descriptors.  */
101 #if @REPLACE_POSIX_SPAWN@
102 # define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
103 #endif
104 #if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@
105 typedef struct
106 {
107   int _allocated;
108   int _used;
109   struct __spawn_action *_actions;
110   int __pad[16];
111 } posix_spawn_file_actions_t;
112 #endif
113
114
115 /* Flags to be set in the `posix_spawnattr_t'.  */
116 #if @HAVE_POSIX_SPAWN@
117 /* Use the values from the system, but provide the missing ones.  */
118 # ifndef POSIX_SPAWN_SETSCHEDPARAM
119 #  define POSIX_SPAWN_SETSCHEDPARAM 0
120 # endif
121 # ifndef POSIX_SPAWN_SETSCHEDULER
122 #  define POSIX_SPAWN_SETSCHEDULER 0
123 # endif
124 #else
125 # if @REPLACE_POSIX_SPAWN@
126 /* Use the values from the system, for better compatibility.  */
127 /* But this implementation does not support AIX extensions.  */
128 #  undef POSIX_SPAWN_FORK_HANDLERS
129 # else
130 #  define POSIX_SPAWN_RESETIDS           0x01
131 #  define POSIX_SPAWN_SETPGROUP          0x02
132 #  define POSIX_SPAWN_SETSIGDEF          0x04
133 #  define POSIX_SPAWN_SETSIGMASK         0x08
134 #  define POSIX_SPAWN_SETSCHEDPARAM      0x10
135 #  define POSIX_SPAWN_SETSCHEDULER       0x20
136 # endif
137 #endif
138 /* A GNU extension.  Use the next free bit position.  */
139 #define POSIX_SPAWN_USEVFORK \
140   ((POSIX_SPAWN_RESETIDS | (POSIX_SPAWN_RESETIDS - 1)                     \
141     | POSIX_SPAWN_SETPGROUP | (POSIX_SPAWN_SETPGROUP - 1)                 \
142     | POSIX_SPAWN_SETSIGDEF | (POSIX_SPAWN_SETSIGDEF - 1)                 \
143     | POSIX_SPAWN_SETSIGMASK | (POSIX_SPAWN_SETSIGMASK - 1)               \
144     | POSIX_SPAWN_SETSCHEDPARAM                                           \
145     | (POSIX_SPAWN_SETSCHEDPARAM > 0 ? POSIX_SPAWN_SETSCHEDPARAM - 1 : 0) \
146     | POSIX_SPAWN_SETSCHEDULER                                            \
147     | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0))  \
148    + 1)
149 typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap
150             [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP
151                 | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK
152                 | POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER)
153                & POSIX_SPAWN_USEVFORK)
154               == 0)
155              ? 1 : -1];
156
157
158 #if @GNULIB_POSIX_SPAWN@
159 /* Spawn a new process executing PATH with the attributes describes in *ATTRP.
160    Before running the process perform the actions described in FILE-ACTIONS.
161
162    This function is a possible cancellation points and therefore not
163    marked with __THROW. */
164 # if @REPLACE_POSIX_SPAWN@
165 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
166 #   define posix_spawn rpl_posix_spawn
167 #  endif
168 _GL_FUNCDECL_RPL (posix_spawn, int,
169                   (pid_t *_Restrict_ __pid,
170                    const char *_Restrict_ __path,
171                    const posix_spawn_file_actions_t *_Restrict_ __file_actions,
172                    const posix_spawnattr_t *_Restrict_ __attrp,
173                    char *const argv[_Restrict_arr_],
174                    char *const envp[_Restrict_arr_])
175                   _GL_ARG_NONNULL ((2, 5, 6)));
176 _GL_CXXALIAS_RPL (posix_spawn, int,
177                   (pid_t *_Restrict_ __pid,
178                    const char *_Restrict_ __path,
179                    const posix_spawn_file_actions_t *_Restrict_ __file_actions,
180                    const posix_spawnattr_t *_Restrict_ __attrp,
181                    char *const argv[_Restrict_arr_],
182                    char *const envp[_Restrict_arr_]));
183 # else
184 #  if !@HAVE_POSIX_SPAWN@
185 _GL_FUNCDECL_SYS (posix_spawn, int,
186                   (pid_t *_Restrict_ __pid,
187                    const char *_Restrict_ __path,
188                    const posix_spawn_file_actions_t *_Restrict_ __file_actions,
189                    const posix_spawnattr_t *_Restrict_ __attrp,
190                    char *const argv[_Restrict_arr_],
191                    char *const envp[_Restrict_arr_])
192                   _GL_ARG_NONNULL ((2, 5, 6)));
193 #  endif
194 _GL_CXXALIAS_SYS (posix_spawn, int,
195                   (pid_t *_Restrict_ __pid,
196                    const char *_Restrict_ __path,
197                    const posix_spawn_file_actions_t *_Restrict_ __file_actions,
198                    const posix_spawnattr_t *_Restrict_ __attrp,
199                    char *const argv[_Restrict_arr_],
200                    char *const envp[_Restrict_arr_]));
201 # endif
202 _GL_CXXALIASWARN (posix_spawn);
203 #elif defined GNULIB_POSIXCHECK
204 # undef posix_spawn
205 # if HAVE_RAW_DECL_POSIX_SPAWN
206 _GL_WARN_ON_USE (posix_spawn, "posix_spawn is unportable - "
207                  "use gnulib module posix_spawn for portability");
208 # endif
209 #endif
210
211 #if @GNULIB_POSIX_SPAWNP@
212 /* Similar to `posix_spawn' but search for FILE in the PATH.
213
214    This function is a possible cancellation points and therefore not
215    marked with __THROW.  */
216 # if @REPLACE_POSIX_SPAWN@
217 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
218 #   define posix_spawnp rpl_posix_spawnp
219 #  endif
220 _GL_FUNCDECL_RPL (posix_spawnp, int,
221                   (pid_t *__pid, const char *__file,
222                    const posix_spawn_file_actions_t *__file_actions,
223                    const posix_spawnattr_t *__attrp,
224                    char *const argv[], char *const envp[])
225                   _GL_ARG_NONNULL ((2, 5, 6)));
226 _GL_CXXALIAS_RPL (posix_spawnp, int,
227                   (pid_t *__pid, const char *__file,
228                    const posix_spawn_file_actions_t *__file_actions,
229                    const posix_spawnattr_t *__attrp,
230                    char *const argv[], char *const envp[]));
231 # else
232 #  if !@HAVE_POSIX_SPAWN@
233 _GL_FUNCDECL_SYS (posix_spawnp, int,
234                   (pid_t *__pid, const char *__file,
235                    const posix_spawn_file_actions_t *__file_actions,
236                    const posix_spawnattr_t *__attrp,
237                    char *const argv[], char *const envp[])
238                   _GL_ARG_NONNULL ((2, 5, 6)));
239 #  endif
240 _GL_CXXALIAS_SYS (posix_spawnp, int,
241                   (pid_t *__pid, const char *__file,
242                    const posix_spawn_file_actions_t *__file_actions,
243                    const posix_spawnattr_t *__attrp,
244                    char *const argv[], char *const envp[]));
245 # endif
246 _GL_CXXALIASWARN (posix_spawnp);
247 #elif defined GNULIB_POSIXCHECK
248 # undef posix_spawnp
249 # if HAVE_RAW_DECL_POSIX_SPAWNP
250 _GL_WARN_ON_USE (posix_spawnp, "posix_spawnp is unportable - "
251                  "use gnulib module posix_spawnp for portability");
252 # endif
253 #endif
254
255
256 #if @GNULIB_POSIX_SPAWNATTR_INIT@
257 /* Initialize data structure with attributes for `spawn' to default values.  */
258 # if @REPLACE_POSIX_SPAWN@
259 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
260 #   define posix_spawnattr_init rpl_posix_spawnattr_init
261 #  endif
262 _GL_FUNCDECL_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
263                                              __THROW _GL_ARG_NONNULL ((1)));
264 _GL_CXXALIAS_RPL (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
265 # else
266 #  if !@HAVE_POSIX_SPAWN@
267 _GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
268                                              __THROW _GL_ARG_NONNULL ((1)));
269 #  endif
270 _GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
271 # endif
272 _GL_CXXALIASWARN (posix_spawnattr_init);
273 #elif defined GNULIB_POSIXCHECK
274 # undef posix_spawnattr_init
275 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT
276 _GL_WARN_ON_USE (posix_spawnattr_init, "posix_spawnattr_init is unportable - "
277                  "use gnulib module posix_spawnattr_init for portability");
278 # endif
279 #endif
280
281 #if @GNULIB_POSIX_SPAWNATTR_DESTROY@
282 /* Free resources associated with ATTR.  */
283 # if @REPLACE_POSIX_SPAWN@
284 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
285 #   define posix_spawnattr_destroy rpl_posix_spawnattr_destroy
286 #  endif
287 _GL_FUNCDECL_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
288                                                 __THROW _GL_ARG_NONNULL ((1)));
289 _GL_CXXALIAS_RPL (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
290 # else
291 #  if !@HAVE_POSIX_SPAWN@
292 _GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
293                                                 __THROW _GL_ARG_NONNULL ((1)));
294 #  endif
295 _GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
296 # endif
297 _GL_CXXALIASWARN (posix_spawnattr_destroy);
298 #elif defined GNULIB_POSIXCHECK
299 # undef posix_spawnattr_destroy
300 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY
301 _GL_WARN_ON_USE (posix_spawnattr_destroy,
302                  "posix_spawnattr_destroy is unportable - "
303                  "use gnulib module posix_spawnattr_destroy for portability");
304 # endif
305 #endif
306
307 #if @GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT@
308 /* Store signal mask for signals with default handling from ATTR in
309    SIGDEFAULT.  */
310 # if @REPLACE_POSIX_SPAWN@
311 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312 #   define posix_spawnattr_getsigdefault rpl_posix_spawnattr_getsigdefault
313 #  endif
314 _GL_FUNCDECL_RPL (posix_spawnattr_getsigdefault, int,
315                   (const posix_spawnattr_t *_Restrict_ __attr,
316                    sigset_t *_Restrict_ __sigdefault)
317                   __THROW _GL_ARG_NONNULL ((1, 2)));
318 _GL_CXXALIAS_RPL (posix_spawnattr_getsigdefault, int,
319                   (const posix_spawnattr_t *_Restrict_ __attr,
320                    sigset_t *_Restrict_ __sigdefault));
321 # else
322 #  if !@HAVE_POSIX_SPAWN@
323 _GL_FUNCDECL_SYS (posix_spawnattr_getsigdefault, int,
324                   (const posix_spawnattr_t *_Restrict_ __attr,
325                    sigset_t *_Restrict_ __sigdefault)
326                   __THROW _GL_ARG_NONNULL ((1, 2)));
327 #  endif
328 _GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int,
329                   (const posix_spawnattr_t *_Restrict_ __attr,
330                    sigset_t *_Restrict_ __sigdefault));
331 # endif
332 _GL_CXXALIASWARN (posix_spawnattr_getsigdefault);
333 #elif defined GNULIB_POSIXCHECK
334 # undef posix_spawnattr_getsigdefault
335 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT
336 _GL_WARN_ON_USE (posix_spawnattr_getsigdefault,
337                  "posix_spawnattr_getsigdefault is unportable - "
338                  "use gnulib module posix_spawnattr_getsigdefault for portability");
339 # endif
340 #endif
341
342 #if @GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT@
343 /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT.  */
344 # if @REPLACE_POSIX_SPAWN@
345 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
346 #   define posix_spawnattr_setsigdefault rpl_posix_spawnattr_setsigdefault
347 #  endif
348 _GL_FUNCDECL_RPL (posix_spawnattr_setsigdefault, int,
349                   (posix_spawnattr_t *_Restrict_ __attr,
350                    const sigset_t *_Restrict_ __sigdefault)
351                   __THROW _GL_ARG_NONNULL ((1, 2)));
352 _GL_CXXALIAS_RPL (posix_spawnattr_setsigdefault, int,
353                   (posix_spawnattr_t *_Restrict_ __attr,
354                    const sigset_t *_Restrict_ __sigdefault));
355 # else
356 #  if !@HAVE_POSIX_SPAWN@
357 _GL_FUNCDECL_SYS (posix_spawnattr_setsigdefault, int,
358                   (posix_spawnattr_t *_Restrict_ __attr,
359                    const sigset_t *_Restrict_ __sigdefault)
360                   __THROW _GL_ARG_NONNULL ((1, 2)));
361 #  endif
362 _GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int,
363                   (posix_spawnattr_t *_Restrict_ __attr,
364                    const sigset_t *_Restrict_ __sigdefault));
365 # endif
366 _GL_CXXALIASWARN (posix_spawnattr_setsigdefault);
367 #elif defined GNULIB_POSIXCHECK
368 # undef posix_spawnattr_setsigdefault
369 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT
370 _GL_WARN_ON_USE (posix_spawnattr_setsigdefault,
371                  "posix_spawnattr_setsigdefault is unportable - "
372                  "use gnulib module posix_spawnattr_setsigdefault for portability");
373 # endif
374 #endif
375
376 #if @GNULIB_POSIX_SPAWNATTR_GETSIGMASK@
377 /* Store signal mask for the new process from ATTR in SIGMASK.  */
378 # if @REPLACE_POSIX_SPAWN@
379 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
380 #   define posix_spawnattr_getsigmask rpl_posix_spawnattr_getsigmask
381 #  endif
382 _GL_FUNCDECL_RPL (posix_spawnattr_getsigmask, int,
383                   (const posix_spawnattr_t *_Restrict_ __attr,
384                    sigset_t *_Restrict_ __sigmask)
385                   __THROW _GL_ARG_NONNULL ((1, 2)));
386 _GL_CXXALIAS_RPL (posix_spawnattr_getsigmask, int,
387                   (const posix_spawnattr_t *_Restrict_ __attr,
388                    sigset_t *_Restrict_ __sigmask));
389 # else
390 #  if !@HAVE_POSIX_SPAWN@
391 _GL_FUNCDECL_SYS (posix_spawnattr_getsigmask, int,
392                   (const posix_spawnattr_t *_Restrict_ __attr,
393                    sigset_t *_Restrict_ __sigmask)
394                   __THROW _GL_ARG_NONNULL ((1, 2)));
395 #  endif
396 _GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int,
397                   (const posix_spawnattr_t *_Restrict_ __attr,
398                    sigset_t *_Restrict_ __sigmask));
399 # endif
400 _GL_CXXALIASWARN (posix_spawnattr_getsigmask);
401 #elif defined GNULIB_POSIXCHECK
402 # undef posix_spawnattr_getsigmask
403 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK
404 _GL_WARN_ON_USE (posix_spawnattr_getsigmask,
405                  "posix_spawnattr_getsigmask is unportable - "
406                  "use gnulib module posix_spawnattr_getsigmask for portability");
407 # endif
408 #endif
409
410 #if @GNULIB_POSIX_SPAWNATTR_SETSIGMASK@
411 /* Set signal mask for the new process in ATTR to SIGMASK.  */
412 # if @REPLACE_POSIX_SPAWN@
413 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
414 #   define posix_spawnattr_setsigmask rpl_posix_spawnattr_setsigmask
415 #  endif
416 _GL_FUNCDECL_RPL (posix_spawnattr_setsigmask, int,
417                   (posix_spawnattr_t *_Restrict_ __attr,
418                    const sigset_t *_Restrict_ __sigmask)
419                   __THROW _GL_ARG_NONNULL ((1, 2)));
420 _GL_CXXALIAS_RPL (posix_spawnattr_setsigmask, int,
421                   (posix_spawnattr_t *_Restrict_ __attr,
422                    const sigset_t *_Restrict_ __sigmask));
423 # else
424 #  if !@HAVE_POSIX_SPAWN@
425 _GL_FUNCDECL_SYS (posix_spawnattr_setsigmask, int,
426                   (posix_spawnattr_t *_Restrict_ __attr,
427                    const sigset_t *_Restrict_ __sigmask)
428                   __THROW _GL_ARG_NONNULL ((1, 2)));
429 #  endif
430 _GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int,
431                   (posix_spawnattr_t *_Restrict_ __attr,
432                    const sigset_t *_Restrict_ __sigmask));
433 # endif
434 _GL_CXXALIASWARN (posix_spawnattr_setsigmask);
435 #elif defined GNULIB_POSIXCHECK
436 # undef posix_spawnattr_setsigmask
437 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK
438 _GL_WARN_ON_USE (posix_spawnattr_setsigmask,
439                  "posix_spawnattr_setsigmask is unportable - "
440                  "use gnulib module posix_spawnattr_setsigmask for portability");
441 # endif
442 #endif
443
444 #if @GNULIB_POSIX_SPAWNATTR_GETFLAGS@
445 /* Get flag word from the attribute structure.  */
446 # if @REPLACE_POSIX_SPAWN@
447 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
448 #   define posix_spawnattr_getflags rpl_posix_spawnattr_getflags
449 #  endif
450 _GL_FUNCDECL_RPL (posix_spawnattr_getflags, int,
451                   (const posix_spawnattr_t *_Restrict_ __attr,
452                    short int *_Restrict_ __flags)
453                   __THROW _GL_ARG_NONNULL ((1, 2)));
454 _GL_CXXALIAS_RPL (posix_spawnattr_getflags, int,
455                   (const posix_spawnattr_t *_Restrict_ __attr,
456                    short int *_Restrict_ __flags));
457 # else
458 #  if !@HAVE_POSIX_SPAWN@
459 _GL_FUNCDECL_SYS (posix_spawnattr_getflags, int,
460                   (const posix_spawnattr_t *_Restrict_ __attr,
461                    short int *_Restrict_ __flags)
462                   __THROW _GL_ARG_NONNULL ((1, 2)));
463 #  endif
464 _GL_CXXALIAS_SYS (posix_spawnattr_getflags, int,
465                   (const posix_spawnattr_t *_Restrict_ __attr,
466                    short int *_Restrict_ __flags));
467 # endif
468 _GL_CXXALIASWARN (posix_spawnattr_getflags);
469 #elif defined GNULIB_POSIXCHECK
470 # undef posix_spawnattr_getflags
471 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS
472 _GL_WARN_ON_USE (posix_spawnattr_getflags,
473                  "posix_spawnattr_getflags is unportable - "
474                  "use gnulib module posix_spawnattr_getflags for portability");
475 # endif
476 #endif
477
478 #if @GNULIB_POSIX_SPAWNATTR_SETFLAGS@
479 /* Store flags in the attribute structure.  */
480 # if @REPLACE_POSIX_SPAWN@
481 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
482 #   define posix_spawnattr_setflags rpl_posix_spawnattr_setflags
483 #  endif
484 _GL_FUNCDECL_RPL (posix_spawnattr_setflags, int,
485                   (posix_spawnattr_t *__attr, short int __flags)
486                   __THROW _GL_ARG_NONNULL ((1)));
487 _GL_CXXALIAS_RPL (posix_spawnattr_setflags, int,
488                   (posix_spawnattr_t *__attr, short int __flags));
489 # else
490 #  if !@HAVE_POSIX_SPAWN@
491 _GL_FUNCDECL_SYS (posix_spawnattr_setflags, int,
492                   (posix_spawnattr_t *__attr, short int __flags)
493                   __THROW _GL_ARG_NONNULL ((1)));
494 #  endif
495 _GL_CXXALIAS_SYS (posix_spawnattr_setflags, int,
496                   (posix_spawnattr_t *__attr, short int __flags));
497 # endif
498 _GL_CXXALIASWARN (posix_spawnattr_setflags);
499 #elif defined GNULIB_POSIXCHECK
500 # undef posix_spawnattr_setflags
501 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS
502 _GL_WARN_ON_USE (posix_spawnattr_setflags,
503                  "posix_spawnattr_setflags is unportable - "
504                  "use gnulib module posix_spawnattr_setflags for portability");
505 # endif
506 #endif
507
508 #if @GNULIB_POSIX_SPAWNATTR_GETPGROUP@
509 /* Get process group ID from the attribute structure.  */
510 # if @REPLACE_POSIX_SPAWN@
511 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
512 #   define posix_spawnattr_getpgroup rpl_posix_spawnattr_getpgroup
513 #  endif
514 _GL_FUNCDECL_RPL (posix_spawnattr_getpgroup, int,
515                   (const posix_spawnattr_t *_Restrict_ __attr,
516                    pid_t *_Restrict_ __pgroup)
517                   __THROW _GL_ARG_NONNULL ((1, 2)));
518 _GL_CXXALIAS_RPL (posix_spawnattr_getpgroup, int,
519                   (const posix_spawnattr_t *_Restrict_ __attr,
520                    pid_t *_Restrict_ __pgroup));
521 # else
522 #  if !@HAVE_POSIX_SPAWN@
523 _GL_FUNCDECL_SYS (posix_spawnattr_getpgroup, int,
524                   (const posix_spawnattr_t *_Restrict_ __attr,
525                    pid_t *_Restrict_ __pgroup)
526                   __THROW _GL_ARG_NONNULL ((1, 2)));
527 #  endif
528 _GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int,
529                   (const posix_spawnattr_t *_Restrict_ __attr,
530                    pid_t *_Restrict_ __pgroup));
531 # endif
532 _GL_CXXALIASWARN (posix_spawnattr_getpgroup);
533 #elif defined GNULIB_POSIXCHECK
534 # undef posix_spawnattr_getpgroup
535 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP
536 _GL_WARN_ON_USE (posix_spawnattr_getpgroup,
537                  "posix_spawnattr_getpgroup is unportable - "
538                  "use gnulib module posix_spawnattr_getpgroup for portability");
539 # endif
540 #endif
541
542 #if @GNULIB_POSIX_SPAWNATTR_SETPGROUP@
543 /* Store process group ID in the attribute structure.  */
544 # if @REPLACE_POSIX_SPAWN@
545 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
546 #   define posix_spawnattr_setpgroup rpl_posix_spawnattr_setpgroup
547 #  endif
548 _GL_FUNCDECL_RPL (posix_spawnattr_setpgroup, int,
549                   (posix_spawnattr_t *__attr, pid_t __pgroup)
550                   __THROW _GL_ARG_NONNULL ((1)));
551 _GL_CXXALIAS_RPL (posix_spawnattr_setpgroup, int,
552                   (posix_spawnattr_t *__attr, pid_t __pgroup));
553 # else
554 #  if !@HAVE_POSIX_SPAWN@
555 _GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int,
556                   (posix_spawnattr_t *__attr, pid_t __pgroup)
557                   __THROW _GL_ARG_NONNULL ((1)));
558 #  endif
559 _GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int,
560                   (posix_spawnattr_t *__attr, pid_t __pgroup));
561 # endif
562 _GL_CXXALIASWARN (posix_spawnattr_setpgroup);
563 #elif defined GNULIB_POSIXCHECK
564 # undef posix_spawnattr_setpgroup
565 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP
566 _GL_WARN_ON_USE (posix_spawnattr_setpgroup,
567                  "posix_spawnattr_setpgroup is unportable - "
568                  "use gnulib module posix_spawnattr_setpgroup for portability");
569 # endif
570 #endif
571
572 #if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY@
573 /* Get scheduling policy from the attribute structure.  */
574 # if @REPLACE_POSIX_SPAWN@
575 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
576 #   define posix_spawnattr_getschedpolicy rpl_posix_spawnattr_getschedpolicy
577 #  endif
578 _GL_FUNCDECL_RPL (posix_spawnattr_getschedpolicy, int,
579                   (const posix_spawnattr_t *_Restrict_ __attr,
580                    int *_Restrict_ __schedpolicy)
581                   __THROW _GL_ARG_NONNULL ((1, 2)));
582 _GL_CXXALIAS_RPL (posix_spawnattr_getschedpolicy, int,
583                   (const posix_spawnattr_t *_Restrict_ __attr,
584                    int *_Restrict_ __schedpolicy));
585 # else
586 #  if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
587 _GL_FUNCDECL_SYS (posix_spawnattr_getschedpolicy, int,
588                   (const posix_spawnattr_t *_Restrict_ __attr,
589                    int *_Restrict_ __schedpolicy)
590                   __THROW _GL_ARG_NONNULL ((1, 2)));
591 #  endif
592 _GL_CXXALIAS_SYS (posix_spawnattr_getschedpolicy, int,
593                   (const posix_spawnattr_t *_Restrict_ __attr,
594                    int *_Restrict_ __schedpolicy));
595 # endif
596 _GL_CXXALIASWARN (posix_spawnattr_getschedpolicy);
597 #elif defined GNULIB_POSIXCHECK
598 # undef posix_spawnattr_getschedpolicy
599 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPOLICY
600 _GL_WARN_ON_USE (posix_spawnattr_getschedpolicy,
601                  "posix_spawnattr_getschedpolicy is unportable - "
602                  "use gnulib module posix_spawnattr_getschedpolicy for portability");
603 # endif
604 #endif
605
606 #if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY@
607 /* Store scheduling policy in the attribute structure.  */
608 # if @REPLACE_POSIX_SPAWN@
609 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
610 #   define posix_spawnattr_setschedpolicy rpl_posix_spawnattr_setschedpolicy
611 #  endif
612 _GL_FUNCDECL_RPL (posix_spawnattr_setschedpolicy, int,
613                   (posix_spawnattr_t *__attr, int __schedpolicy)
614                   __THROW _GL_ARG_NONNULL ((1)));
615 _GL_CXXALIAS_RPL (posix_spawnattr_setschedpolicy, int,
616                   (posix_spawnattr_t *__attr, int __schedpolicy));
617 # else
618 #  if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDULER == 0
619 _GL_FUNCDECL_SYS (posix_spawnattr_setschedpolicy, int,
620                   (posix_spawnattr_t *__attr, int __schedpolicy)
621                   __THROW _GL_ARG_NONNULL ((1)));
622 #  endif
623 _GL_CXXALIAS_SYS (posix_spawnattr_setschedpolicy, int,
624                   (posix_spawnattr_t *__attr, int __schedpolicy));
625 # endif
626 _GL_CXXALIASWARN (posix_spawnattr_setschedpolicy);
627 #elif defined GNULIB_POSIXCHECK
628 # undef posix_spawnattr_setschedpolicy
629 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPOLICY
630 _GL_WARN_ON_USE (posix_spawnattr_setschedpolicy,
631                  "posix_spawnattr_setschedpolicy is unportable - "
632                  "use gnulib module posix_spawnattr_setschedpolicy for portability");
633 # endif
634 #endif
635
636 #if @GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM@
637 /* Get scheduling parameters from the attribute structure.  */
638 # if @REPLACE_POSIX_SPAWN@
639 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
640 #   define posix_spawnattr_getschedparam rpl_posix_spawnattr_getschedparam
641 #  endif
642 _GL_FUNCDECL_RPL (posix_spawnattr_getschedparam, int,
643                   (const posix_spawnattr_t *_Restrict_ __attr,
644                    struct sched_param *_Restrict_ __schedparam)
645                   __THROW _GL_ARG_NONNULL ((1, 2)));
646 _GL_CXXALIAS_RPL (posix_spawnattr_getschedparam, int,
647                   (const posix_spawnattr_t *_Restrict_ __attr,
648                    struct sched_param *_Restrict_ __schedparam));
649 # else
650 #  if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
651 _GL_FUNCDECL_SYS (posix_spawnattr_getschedparam, int,
652                   (const posix_spawnattr_t *_Restrict_ __attr,
653                    struct sched_param *_Restrict_ __schedparam)
654                   __THROW _GL_ARG_NONNULL ((1, 2)));
655 #  endif
656 _GL_CXXALIAS_SYS (posix_spawnattr_getschedparam, int,
657                   (const posix_spawnattr_t *_Restrict_ __attr,
658                    struct sched_param *_Restrict_ __schedparam));
659 # endif
660 _GL_CXXALIASWARN (posix_spawnattr_getschedparam);
661 #elif defined GNULIB_POSIXCHECK
662 # undef posix_spawnattr_getschedparam
663 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSCHEDPARAM
664 _GL_WARN_ON_USE (posix_spawnattr_getschedparam,
665                  "posix_spawnattr_getschedparam is unportable - "
666                  "use gnulib module posix_spawnattr_getschedparam for portability");
667 # endif
668 #endif
669
670 #if @GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM@
671 /* Store scheduling parameters in the attribute structure.  */
672 # if @REPLACE_POSIX_SPAWN@
673 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
674 #   define posix_spawnattr_setschedparam rpl_posix_spawnattr_setschedparam
675 #  endif
676 _GL_FUNCDECL_RPL (posix_spawnattr_setschedparam, int,
677                   (posix_spawnattr_t *_Restrict_ __attr,
678                    const struct sched_param *_Restrict_ __schedparam)
679                   __THROW _GL_ARG_NONNULL ((1, 2)));
680 _GL_CXXALIAS_RPL (posix_spawnattr_setschedparam, int,
681                   (posix_spawnattr_t *_Restrict_ __attr,
682                    const struct sched_param *_Restrict_ __schedparam));
683 # else
684 #  if !@HAVE_POSIX_SPAWN@ || POSIX_SPAWN_SETSCHEDPARAM == 0
685 _GL_FUNCDECL_SYS (posix_spawnattr_setschedparam, int,
686                   (posix_spawnattr_t *_Restrict_ __attr,
687                    const struct sched_param *_Restrict_ __schedparam)
688                   __THROW _GL_ARG_NONNULL ((1, 2)));
689 #  endif
690 _GL_CXXALIAS_SYS (posix_spawnattr_setschedparam, int,
691                   (posix_spawnattr_t *_Restrict_ __attr,
692                    const struct sched_param *_Restrict_ __schedparam));
693 # endif
694 _GL_CXXALIASWARN (posix_spawnattr_setschedparam);
695 #elif defined GNULIB_POSIXCHECK
696 # undef posix_spawnattr_setschedparam
697 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSCHEDPARAM
698 _GL_WARN_ON_USE (posix_spawnattr_setschedparam,
699                  "posix_spawnattr_setschedparam is unportable - "
700                  "use gnulib module posix_spawnattr_setschedparam for portability");
701 # endif
702 #endif
703
704
705 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT@
706 /* Initialize data structure for file attribute for `spawn' call.  */
707 # if @REPLACE_POSIX_SPAWN@
708 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
709 #   define posix_spawn_file_actions_init rpl_posix_spawn_file_actions_init
710 #  endif
711 _GL_FUNCDECL_RPL (posix_spawn_file_actions_init, int,
712                   (posix_spawn_file_actions_t *__file_actions)
713                   __THROW _GL_ARG_NONNULL ((1)));
714 _GL_CXXALIAS_RPL (posix_spawn_file_actions_init, int,
715                   (posix_spawn_file_actions_t *__file_actions));
716 # else
717 #  if !@HAVE_POSIX_SPAWN@
718 _GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int,
719                   (posix_spawn_file_actions_t *__file_actions)
720                   __THROW _GL_ARG_NONNULL ((1)));
721 #  endif
722 _GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int,
723                   (posix_spawn_file_actions_t *__file_actions));
724 # endif
725 _GL_CXXALIASWARN (posix_spawn_file_actions_init);
726 #elif defined GNULIB_POSIXCHECK
727 # undef posix_spawn_file_actions_init
728 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT
729 _GL_WARN_ON_USE (posix_spawn_file_actions_init,
730                  "posix_spawn_file_actions_init is unportable - "
731                  "use gnulib module posix_spawn_file_actions_init for portability");
732 # endif
733 #endif
734
735 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY@
736 /* Free resources associated with FILE-ACTIONS.  */
737 # if @REPLACE_POSIX_SPAWN@
738 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
739 #   define posix_spawn_file_actions_destroy rpl_posix_spawn_file_actions_destroy
740 #  endif
741 _GL_FUNCDECL_RPL (posix_spawn_file_actions_destroy, int,
742                   (posix_spawn_file_actions_t *__file_actions)
743                   __THROW _GL_ARG_NONNULL ((1)));
744 _GL_CXXALIAS_RPL (posix_spawn_file_actions_destroy, int,
745                   (posix_spawn_file_actions_t *__file_actions));
746 # else
747 #  if !@HAVE_POSIX_SPAWN@
748 _GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int,
749                   (posix_spawn_file_actions_t *__file_actions)
750                   __THROW _GL_ARG_NONNULL ((1)));
751 #  endif
752 _GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int,
753                   (posix_spawn_file_actions_t *__file_actions));
754 # endif
755 _GL_CXXALIASWARN (posix_spawn_file_actions_destroy);
756 #elif defined GNULIB_POSIXCHECK
757 # undef posix_spawn_file_actions_destroy
758 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY
759 _GL_WARN_ON_USE (posix_spawn_file_actions_destroy,
760                  "posix_spawn_file_actions_destroy is unportable - "
761                  "use gnulib module posix_spawn_file_actions_destroy for portability");
762 # endif
763 #endif
764
765 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN@
766 /* Add an action to FILE-ACTIONS which tells the implementation to call
767    `open' for the given file during the `spawn' call.  */
768 # if @REPLACE_POSIX_SPAWN@
769 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
770 #   define posix_spawn_file_actions_addopen rpl_posix_spawn_file_actions_addopen
771 #  endif
772 _GL_FUNCDECL_RPL (posix_spawn_file_actions_addopen, int,
773                   (posix_spawn_file_actions_t *_Restrict_ __file_actions,
774                    int __fd,
775                    const char *_Restrict_ __path, int __oflag, mode_t __mode)
776                   __THROW _GL_ARG_NONNULL ((1, 3)));
777 _GL_CXXALIAS_RPL (posix_spawn_file_actions_addopen, int,
778                   (posix_spawn_file_actions_t *_Restrict_ __file_actions,
779                    int __fd,
780                    const char *_Restrict_ __path, int __oflag, mode_t __mode));
781 # else
782 #  if !@HAVE_POSIX_SPAWN@
783 _GL_FUNCDECL_SYS (posix_spawn_file_actions_addopen, int,
784                   (posix_spawn_file_actions_t *_Restrict_ __file_actions,
785                    int __fd,
786                    const char *_Restrict_ __path, int __oflag, mode_t __mode)
787                   __THROW _GL_ARG_NONNULL ((1, 3)));
788 #  endif
789 _GL_CXXALIAS_SYS (posix_spawn_file_actions_addopen, int,
790                   (posix_spawn_file_actions_t *_Restrict_ __file_actions,
791                    int __fd,
792                    const char *_Restrict_ __path, int __oflag, mode_t __mode));
793 # endif
794 _GL_CXXALIASWARN (posix_spawn_file_actions_addopen);
795 #elif defined GNULIB_POSIXCHECK
796 # undef posix_spawn_file_actions_addopen
797 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN
798 _GL_WARN_ON_USE (posix_spawn_file_actions_addopen,
799                  "posix_spawn_file_actions_addopen is unportable - "
800                  "use gnulib module posix_spawn_file_actions_addopen for portability");
801 # endif
802 #endif
803
804 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE@
805 /* Add an action to FILE-ACTIONS which tells the implementation to call
806    `close' for the given file descriptor during the `spawn' call.  */
807 # if @REPLACE_POSIX_SPAWN@
808 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809 #   define posix_spawn_file_actions_addclose rpl_posix_spawn_file_actions_addclose
810 #  endif
811 _GL_FUNCDECL_RPL (posix_spawn_file_actions_addclose, int,
812                   (posix_spawn_file_actions_t *__file_actions, int __fd)
813                   __THROW _GL_ARG_NONNULL ((1)));
814 _GL_CXXALIAS_RPL (posix_spawn_file_actions_addclose, int,
815                   (posix_spawn_file_actions_t *__file_actions, int __fd));
816 # else
817 #  if !@HAVE_POSIX_SPAWN@
818 _GL_FUNCDECL_SYS (posix_spawn_file_actions_addclose, int,
819                   (posix_spawn_file_actions_t *__file_actions, int __fd)
820                   __THROW _GL_ARG_NONNULL ((1)));
821 #  endif
822 _GL_CXXALIAS_SYS (posix_spawn_file_actions_addclose, int,
823                   (posix_spawn_file_actions_t *__file_actions, int __fd));
824 # endif
825 _GL_CXXALIASWARN (posix_spawn_file_actions_addclose);
826 #elif defined GNULIB_POSIXCHECK
827 # undef posix_spawn_file_actions_addclose
828 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE
829 _GL_WARN_ON_USE (posix_spawn_file_actions_addclose,
830                  "posix_spawn_file_actions_addclose is unportable - "
831                  "use gnulib module posix_spawn_file_actions_addclose for portability");
832 # endif
833 #endif
834
835 #if @GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2@
836 /* Add an action to FILE-ACTIONS which tells the implementation to call
837    `dup2' for the given file descriptors during the `spawn' call.  */
838 # if @REPLACE_POSIX_SPAWN@
839 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
840 #   define posix_spawn_file_actions_adddup2 rpl_posix_spawn_file_actions_adddup2
841 #  endif
842 _GL_FUNCDECL_RPL (posix_spawn_file_actions_adddup2, int,
843                   (posix_spawn_file_actions_t *__file_actions,
844                    int __fd, int __newfd)
845                   __THROW _GL_ARG_NONNULL ((1)));
846 _GL_CXXALIAS_RPL (posix_spawn_file_actions_adddup2, int,
847                   (posix_spawn_file_actions_t *__file_actions,
848                    int __fd, int __newfd));
849 # else
850 #  if !@HAVE_POSIX_SPAWN@
851 _GL_FUNCDECL_SYS (posix_spawn_file_actions_adddup2, int,
852                   (posix_spawn_file_actions_t *__file_actions,
853                    int __fd, int __newfd)
854                   __THROW _GL_ARG_NONNULL ((1)));
855 #  endif
856 _GL_CXXALIAS_SYS (posix_spawn_file_actions_adddup2, int,
857                   (posix_spawn_file_actions_t *__file_actions,
858                    int __fd, int __newfd));
859 # endif
860 _GL_CXXALIASWARN (posix_spawn_file_actions_adddup2);
861 #elif defined GNULIB_POSIXCHECK
862 # undef posix_spawn_file_actions_adddup2
863 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2
864 _GL_WARN_ON_USE (posix_spawn_file_actions_adddup2,
865                  "posix_spawn_file_actions_adddup2 is unportable - "
866                  "use gnulib module posix_spawn_file_actions_adddup2 for portability");
867 # endif
868 #endif
869
870
871 #endif /* _GL_SPAWN_H */
872 #endif /* _GL_SPAWN_H */