diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2000-01-21 15:07:55 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2000-01-21 15:07:55 +0000 |
commit | c941a980ccbd8def1d925fc5c69a22f40e1e5060 (patch) | |
tree | 4b2b9ae1c94411a26ed2c5c1fa747a3fd296a4ae /cpukit/rtems/src | |
parent | Patch from Eric Norum <eric@cls.usask.ca> to remove warnings. (diff) | |
download | rtems-c941a980ccbd8def1d925fc5c69a22f40e1e5060.tar.bz2 |
Patch from Eric Norum <eric@cls.usask.ca> to implement this:
I'd like to propose a change to RTEMS task variables that I think would
make them more useful. I think that it is early enough in their
existence to still make changes to their API.
1) Change type from `int' to `void *'.
2) Add extra argument to task_variable_add -- if non-NULL, a pointer to
a `destructor' function to be called when the task exits. This function
would be called with that task's value of the task variable as its
argument. In many cases, the `dtor' function could be `free'.
rtems_status_code rtems_task_variable_add (
rtems_id tid, void **ptr, void (*dtor)(void *));
rtems_status_code rtems_task_variable_delete (rtems_id tid, void **ptr);
This would be all we'd need to cleanly and efficiently support C++
per-thread exception information without dragging in all that POSIX API
stuff.
Diffstat (limited to 'cpukit/rtems/src')
-rw-r--r-- | cpukit/rtems/src/tasks.c | 2 | ||||
-rw-r--r-- | cpukit/rtems/src/taskvariableadd.c | 6 | ||||
-rw-r--r-- | cpukit/rtems/src/taskvariabledelete.c | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c index bbd9ff0dd8..5fdff2db18 100644 --- a/cpukit/rtems/src/tasks.c +++ b/cpukit/rtems/src/tasks.c @@ -103,6 +103,8 @@ User_extensions_routine _RTEMS_tasks_Delete_extension( deleted->task_variables = NULL; while (tvp) { next = tvp->next; + if (tvp->dtor) + (*tvp->dtor)( tvp->ptr ); _Workspace_Free( tvp ); tvp = next; } diff --git a/cpukit/rtems/src/taskvariableadd.c b/cpukit/rtems/src/taskvariableadd.c index 4ba8b7b21b..0f1ae0895e 100644 --- a/cpukit/rtems/src/taskvariableadd.c +++ b/cpukit/rtems/src/taskvariableadd.c @@ -24,7 +24,8 @@ rtems_status_code rtems_task_variable_add( rtems_id tid, - int *ptr + void **ptr, + void (*dtor)(void *) ) { Thread_Control *the_thread; @@ -54,6 +55,7 @@ rtems_status_code rtems_task_variable_add( tvp = the_thread->task_variables; while (tvp) { if (tvp->ptr == ptr) { + tvp->dtor = dtor; _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } @@ -72,6 +74,7 @@ rtems_status_code rtems_task_variable_add( } new->var = 0; new->ptr = ptr; + new->dtor = dtor; new->next = the_thread->task_variables; the_thread->task_variables = new; @@ -80,4 +83,3 @@ rtems_status_code rtems_task_variable_add( } return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ } - diff --git a/cpukit/rtems/src/taskvariabledelete.c b/cpukit/rtems/src/taskvariabledelete.c index eddaf1903d..c760f9ba39 100644 --- a/cpukit/rtems/src/taskvariabledelete.c +++ b/cpukit/rtems/src/taskvariabledelete.c @@ -24,7 +24,7 @@ rtems_status_code rtems_task_variable_delete( rtems_id tid, - int *ptr + void **ptr ) { Thread_Control *the_thread; |