diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-01 16:50:53 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-01 16:50:53 +0000 |
commit | eb26187767da1e752bfdc6571ccb70e3f84fd954 (patch) | |
tree | 6047f392552b62c0d5f6e7aabe95266b5f2ef0cf /nuttx/sched | |
parent | 1214744afca8851c7888b6b3f2bb8b47c5a815e2 (diff) | |
download | px4-firmware-eb26187767da1e752bfdc6571ccb70e3f84fd954.tar.gz px4-firmware-eb26187767da1e752bfdc6571ccb70e3f84fd954.tar.bz2 px4-firmware-eb26187767da1e752bfdc6571ccb70e3f84fd954.zip |
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
Diffstat (limited to 'nuttx/sched')
-rw-r--r-- | nuttx/sched/Kconfig | 11 | ||||
-rw-r--r-- | nuttx/sched/atexit.c | 16 | ||||
-rw-r--r-- | nuttx/sched/on_exit.c | 5 | ||||
-rw-r--r-- | nuttx/sched/task_exithook.c | 4 |
4 files changed, 28 insertions, 8 deletions
diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig index 4f7149595..4a3e87745 100644 --- a/nuttx/sched/Kconfig +++ b/nuttx/sched/Kconfig @@ -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" diff --git a/nuttx/sched/atexit.c b/nuttx/sched/atexit.c index f7d81bec2..b0559b01b 100644 --- a/nuttx/sched/atexit.c +++ b/nuttx/sched/atexit.c @@ -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; diff --git a/nuttx/sched/on_exit.c b/nuttx/sched/on_exit.c index 5b8be5cd1..19a4f9196 100644 --- a/nuttx/sched/on_exit.c +++ b/nuttx/sched/on_exit.c @@ -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 */ diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c index e94476f2a..6f52ef739 100644 --- a/nuttx/sched/task_exithook.c +++ b/nuttx/sched/task_exithook.c @@ -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 |