| Index: newlib/libc/posix/posix_spawnattr.c
|
| diff --git a/newlib/libc/posix/posix_spawnattr.c b/newlib/libc/posix/posix_spawnattr.c
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1eb6ee83dc06686f9885b2567771a7c3d5e173b8
|
| --- /dev/null
|
| +++ b/newlib/libc/posix/posix_spawnattr.c
|
| @@ -0,0 +1,168 @@
|
| +/*-
|
| + * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
|
| + * All rights reserved.
|
| + *
|
| + * Redistribution and use in source and binary forms, with or without
|
| + * modification, are permitted provided that the following conditions
|
| + * are met:
|
| + * 1. Redistributions of source code must retain the above copyright
|
| + * notice, this list of conditions and the following disclaimer.
|
| + * 2. Redistributions in binary form must reproduce the above copyright
|
| + * notice, this list of conditions and the following disclaimer in the
|
| + * documentation and/or other materials provided with the distribution.
|
| + *
|
| + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
| + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
| + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
| + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
| + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
| + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
| + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
| + * SUCH DAMAGE.
|
| + */
|
| +
|
| +#ifndef _NO_POSIX_SPAWN
|
| +
|
| +#include <errno.h>
|
| +#include <spawn.h>
|
| +#include <stdlib.h>
|
| +
|
| +/*
|
| + * Spawn attributes
|
| + */
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_init, (ret),
|
| + posix_spawnattr_t *ret)
|
| +{
|
| + posix_spawnattr_t* sa;
|
| +
|
| + sa = calloc(1, sizeof(posix_spawnattr_t));
|
| + if (sa == NULL)
|
| + return (errno);
|
| +
|
| + /* Set defaults as specified by POSIX, cleared above */
|
| + ret = sa;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_destroy, (sa),
|
| + posix_spawnattr_t *sa)
|
| +{
|
| + free(sa);
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_getflags, (sa, flags),
|
| + _CONST posix_spawnattr_t * __restrict sa _AND
|
| + short * __restrict flags)
|
| +{
|
| + *flags = sa->sa_flags;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_getpgroup, (sa, pgroup),
|
| + _CONST posix_spawnattr_t * __restrict sa _AND
|
| + pid_t * __restrict pgroup)
|
| +{
|
| + *pgroup = sa->sa_pgroup;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_getschedparam, (sa, schedparam),
|
| + _CONST posix_spawnattr_t * __restrict sa _AND
|
| + struct sched_param * __restrict schedparam)
|
| +{
|
| + *schedparam = sa->sa_schedparam;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_getschedpolicy, (sa, schedpolicy),
|
| + _CONST posix_spawnattr_t * __restrict sa _AND
|
| + int * __restrict schedpolicy)
|
| +{
|
| + *schedpolicy = sa->sa_schedpolicy;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_getsigdefault, (sa, sigdefault),
|
| + _CONST posix_spawnattr_t * __restrict sa _AND
|
| + sigset_t * __restrict sigdefault)
|
| +{
|
| + *sigdefault = sa->sa_sigdefault;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_getsigmask, (sa, sigmask),
|
| + _CONST posix_spawnattr_t * __restrict sa _AND
|
| + sigset_t * __restrict sigmask)
|
| +{
|
| + *sigmask = sa->sa_sigmask;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_setflags, (sa, flags),
|
| + posix_spawnattr_t *sa _AND
|
| + short flags)
|
| +{
|
| + sa->sa_flags = flags;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_setpgroup, (sa, pgroup),
|
| + posix_spawnattr_t *sa _AND
|
| + pid_t pgroup)
|
| +{
|
| + sa->sa_pgroup = pgroup;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_setschedparam, (sa, schedparam),
|
| + posix_spawnattr_t * __restrict sa _AND
|
| + _CONST struct sched_param * __restrict schedparam)
|
| +{
|
| + sa->sa_schedparam = *schedparam;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_setschedpolicy, (sa, schedpolicy),
|
| + posix_spawnattr_t *sa _AND
|
| + int schedpolicy)
|
| +{
|
| + sa->sa_schedpolicy = schedpolicy;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_setsigdefault, (sa, sigdefault),
|
| + posix_spawnattr_t * __restrict sa _AND
|
| + _CONST sigset_t * __restrict sigdefault)
|
| +{
|
| + sa->sa_sigdefault = *sigdefault;
|
| + return (0);
|
| +}
|
| +
|
| +int
|
| +_DEFUN(posix_spawnattr_setsigmask, (sa, sigmask),
|
| + posix_spawnattr_t * __restrict sa _AND
|
| + _CONST sigset_t * __restrict sigmask)
|
| +{
|
| + sa->sa_sigmask = *sigmask;
|
| + return (0);
|
| +}
|
| +
|
| +#endif /* !_NO_POSIX_SPAWN */
|
|
|