sched/spawn: Support the stack address argument
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
7169c7c5f8
commit
82fb188d02
@ -85,7 +85,8 @@ struct posix_spawnattr_s
|
|||||||
#ifndef CONFIG_BUILD_KERNEL
|
#ifndef CONFIG_BUILD_KERNEL
|
||||||
/* Used only by task_spawn (non-standard) */
|
/* Used only by task_spawn (non-standard) */
|
||||||
|
|
||||||
size_t stacksize; /* Task stack size */
|
FAR void *stackaddr; /* Task stack address */
|
||||||
|
size_t stacksize; /* Task stack size */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SCHED_SPORADIC
|
#ifdef CONFIG_SCHED_SPORADIC
|
||||||
@ -211,8 +212,13 @@ int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr,
|
|||||||
* task_spawn()
|
* task_spawn()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int task_spawnattr_getstackaddr(FAR const posix_spawnattr_t *attr,
|
||||||
|
FAR void **stackaddr);
|
||||||
|
int task_spawnattr_setstackaddr(FAR posix_spawnattr_t *attr,
|
||||||
|
FAR void *stackaddr);
|
||||||
|
|
||||||
int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
|
int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
|
||||||
size_t *stacksize);
|
FAR size_t *stacksize);
|
||||||
int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr,
|
int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr,
|
||||||
size_t stacksize);
|
size_t stacksize);
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ CSRCS += lib_psa_init.c lib_psa_setflags.c lib_psa_setschedparam.c
|
|||||||
CSRCS += lib_psa_setschedpolicy.c lib_psa_getsigmask.c lib_psa_setsigmask.c
|
CSRCS += lib_psa_setschedpolicy.c lib_psa_getsigmask.c lib_psa_setsigmask.c
|
||||||
|
|
||||||
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||||
|
CSRCS += lib_psa_getstackaddr.c lib_psa_setstackaddr.c
|
||||||
CSRCS += lib_psa_getstacksize.c lib_psa_setstacksize.c
|
CSRCS += lib_psa_getstacksize.c lib_psa_setstacksize.c
|
||||||
ifeq ($(CONFIG_LIB_SYSCALL),y)
|
ifeq ($(CONFIG_LIB_SYSCALL),y)
|
||||||
CSRCS += lib_task_spawn.c
|
CSRCS += lib_task_spawn.c
|
||||||
|
63
libs/libc/spawn/lib_psa_getstackaddr.c
Normal file
63
libs/libc/spawn/lib_psa_getstackaddr.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/spawn/lib_psa_getstackaddr.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sched.h>
|
||||||
|
#include <spawn.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef CONFIG_BUILD_KERNEL
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: task_spawnattr_getstackaddr
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The task_spawnattr_getstackaddr() function will obtain the value of
|
||||||
|
* the spawn-stackaddr attribute from the attributes object referenced
|
||||||
|
* by attr.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* attr - The address spawn attributes to be queried.
|
||||||
|
* stackaddr - The location to return the spawn-stackaddr value.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success, these functions return 0; on failure they return an error
|
||||||
|
* number from <errno.h>.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int task_spawnattr_getstackaddr(FAR const posix_spawnattr_t *attr,
|
||||||
|
FAR void **stackaddr)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(attr && stackaddr);
|
||||||
|
*stackaddr = attr->stackaddr;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !CONFIG_BUILD_KERNEL */
|
@ -53,7 +53,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
|
int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr,
|
||||||
size_t *stacksize)
|
FAR size_t *stacksize)
|
||||||
{
|
{
|
||||||
DEBUGASSERT(attr && stacksize);
|
DEBUGASSERT(attr && stacksize);
|
||||||
*stacksize = attr->stacksize;
|
*stacksize = attr->stacksize;
|
||||||
|
63
libs/libc/spawn/lib_psa_setstackaddr.c
Normal file
63
libs/libc/spawn/lib_psa_setstackaddr.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/spawn/lib_psa_setstackaddr.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sched.h>
|
||||||
|
#include <spawn.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifndef CONFIG_BUILD_KERNEL
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: task_spawnattr_setstackaddr
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* The task_spawnattr_setstackaddr() function shall set the spawn-
|
||||||
|
* stackaddr attribute in an initialized attributes object referenced
|
||||||
|
* by attr.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* attr - The address spawn attributes to be used.
|
||||||
|
* stackaddr - The new stackaddr to set.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success, these functions return 0; on failure they return an error
|
||||||
|
* number from <errno.h>.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int task_spawnattr_setstackaddr(FAR posix_spawnattr_t *attr,
|
||||||
|
FAR void *stackaddr)
|
||||||
|
{
|
||||||
|
DEBUGASSERT(attr);
|
||||||
|
attr->stackaddr = stackaddr;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !CONFIG_BUILD_KERNEL */
|
Loading…
Reference in New Issue
Block a user