mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 01:43:34 +08:00
Add __cxa_atexit(); atexit() is now built on top of on_exit()
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5292 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+10
-1
@@ -214,12 +214,17 @@ config SCHED_ATEXIT
|
||||
config SCHED_ATEXIT_MAX
|
||||
int "Max number of atexit() functions"
|
||||
default 1
|
||||
depends on SCHED_ATEXIT
|
||||
depends on SCHED_ATEXIT && !SCHED_ONEXIT
|
||||
---help---
|
||||
By default if SCHED_ATEXIT is selected, only a single atexit() function
|
||||
is supported. That number can be increased by defined this setting to
|
||||
the number that you require.
|
||||
|
||||
If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit() is built
|
||||
on top of the on_exit() implementation. In that case, SCHED_ONEXIT_MAX
|
||||
determines the size of the combined number of atexit(0) and on_exit calls
|
||||
and SCHED_ATEXIT_MAX is not used.
|
||||
|
||||
config SCHED_ONEXIT
|
||||
bool "Enable on_exit() API"
|
||||
default n
|
||||
@@ -235,6 +240,10 @@ config SCHED_ONEXIT_MAX
|
||||
is supported. That number can be increased by defined this setting to the
|
||||
number that you require.
|
||||
|
||||
If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit() is built
|
||||
on top of the on_exit() implementation. In that case, SCHED_ONEXIT_MAX
|
||||
determines the size of the combined number of atexit(0) and on_exit calls.
|
||||
|
||||
config USER_ENTRYPOINT
|
||||
string "Application entry point"
|
||||
default "user_start"
|
||||
|
||||
+14
-2
@@ -96,8 +96,13 @@
|
||||
* CONFIG_SCHED_ATEXIT_MAX defines a larger number.
|
||||
* 2. atexit functions are not inherited when a new task is
|
||||
* created.
|
||||
* 3. If both SCHED_ONEXIT and SCHED_ATEXIT are selected, then atexit()
|
||||
* is built on top of the on_exit() implementation. In that case,
|
||||
* CONFIG_SCHED_ONEXIT_MAX determines the size of the combined
|
||||
* number of atexit(0) and on_exit calls and SCHED_ATEXIT_MAX is
|
||||
* not used.
|
||||
*
|
||||
* Parameters:
|
||||
* Input Parameters:
|
||||
* func - A pointer to the function to be called when the task exits.
|
||||
*
|
||||
* Return Value:
|
||||
@@ -107,7 +112,14 @@
|
||||
|
||||
int atexit(void (*func)(void))
|
||||
{
|
||||
#if defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
|
||||
#if defined(CONFIG_SCHED_ONEXIT)
|
||||
/* atexit is equivalent to on_exit() with no argument (Assuming that the ABI
|
||||
* can handle a callback function that recieves more parameters than it expects).
|
||||
*/
|
||||
|
||||
return on_exit(onexitfunc_t func, NULL);
|
||||
|
||||
#elif defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
|
||||
_TCB *tcb = (_TCB*)g_readytorun.head;
|
||||
int index;
|
||||
int ret = ERROR;
|
||||
|
||||
@@ -117,7 +117,7 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
|
||||
#if defined(CONFIG_SCHED_ONEXIT_MAX) && CONFIG_SCHED_ONEXIT_MAX > 1
|
||||
_TCB *tcb = (_TCB*)g_readytorun.head;
|
||||
int index;
|
||||
int ret = ERROR;
|
||||
int ret = ENOSPC;
|
||||
|
||||
/* The following must be atomic */
|
||||
|
||||
@@ -131,7 +131,6 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
|
||||
* indices.
|
||||
*/
|
||||
|
||||
available = -1;
|
||||
for (index = 0; index < CONFIG_SCHED_ONEXIT_MAX; index++)
|
||||
{
|
||||
if (!tcb->onexitfunc[index])
|
||||
@@ -149,7 +148,7 @@ int on_exit(CODE void (*func)(int, FAR void *), FAR void *arg)
|
||||
return ret;
|
||||
#else
|
||||
_TCB *tcb = (_TCB*)g_readytorun.head;
|
||||
int ret = ERROR;
|
||||
int ret = ENOSPC;
|
||||
|
||||
/* The following must be atomic */
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
* Call any registerd atexit function(s)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SCHED_ATEXIT
|
||||
|
||||
#if defined(CONFIG_SCHED_ATEXIT) && !defined(CONFIG_SCHED_ONEXIT)
|
||||
static inline void task_atexit(FAR _TCB *tcb)
|
||||
{
|
||||
#if defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
|
||||
|
||||
Reference in New Issue
Block a user