diff --git a/include/spawn.h b/include/spawn.h index c999f1ba38..41649e2f52 100644 --- a/include/spawn.h +++ b/include/spawn.h @@ -85,7 +85,8 @@ struct posix_spawnattr_s #ifndef CONFIG_BUILD_KERNEL /* 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 #ifdef CONFIG_SCHED_SPORADIC @@ -211,8 +212,13 @@ int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr, * 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, - size_t *stacksize); + FAR size_t *stacksize); int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr, size_t stacksize); diff --git a/libs/libc/spawn/Make.defs b/libs/libc/spawn/Make.defs index 972770b417..8b558134fa 100644 --- a/libs/libc/spawn/Make.defs +++ b/libs/libc/spawn/Make.defs @@ -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 ifneq ($(CONFIG_BUILD_KERNEL),y) +CSRCS += lib_psa_getstackaddr.c lib_psa_setstackaddr.c CSRCS += lib_psa_getstacksize.c lib_psa_setstacksize.c ifeq ($(CONFIG_LIB_SYSCALL),y) CSRCS += lib_task_spawn.c diff --git a/libs/libc/spawn/lib_psa_getstackaddr.c b/libs/libc/spawn/lib_psa_getstackaddr.c new file mode 100644 index 0000000000..f1c776ba8c --- /dev/null +++ b/libs/libc/spawn/lib_psa_getstackaddr.c @@ -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 + +#include +#include +#include + +#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 . + * + ****************************************************************************/ + +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 */ diff --git a/libs/libc/spawn/lib_psa_getstacksize.c b/libs/libc/spawn/lib_psa_getstacksize.c index e94347ec73..748fb52fa2 100644 --- a/libs/libc/spawn/lib_psa_getstacksize.c +++ b/libs/libc/spawn/lib_psa_getstacksize.c @@ -53,7 +53,7 @@ ****************************************************************************/ int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr, - size_t *stacksize) + FAR size_t *stacksize) { DEBUGASSERT(attr && stacksize); *stacksize = attr->stacksize; diff --git a/libs/libc/spawn/lib_psa_setstackaddr.c b/libs/libc/spawn/lib_psa_setstackaddr.c new file mode 100644 index 0000000000..dc24aeeca7 --- /dev/null +++ b/libs/libc/spawn/lib_psa_setstackaddr.c @@ -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 + +#include +#include +#include + +#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 . + * + ****************************************************************************/ + +int task_spawnattr_setstackaddr(FAR posix_spawnattr_t *attr, + FAR void *stackaddr) +{ + DEBUGASSERT(attr); + attr->stackaddr = stackaddr; + return OK; +} + +#endif /* !CONFIG_BUILD_KERNEL */