summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-12-12 23:19:57 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-12-12 23:19:57 +0000
commit98dee44ba89670de7a9eb9e2e36d187cc55546b8 (patch)
tree9c64b8185d2f5e75cb50506c5cfbfee6107bd1f7 /cpukit/rtems
parent2007-12-12 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-98dee44ba89670de7a9eb9e2e36d187cc55546b8.tar.bz2
2007-12-12 Joel Sherrill <joel.sherrill@OARcorp.com>
* rtems/Makefile.am, rtems/include/rtems/rtems/tasks.h, rtems/src/tasks.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c: Add test code for task variables to improve coverage. * rtems/src/taskvariable_invoke_dtor.c: New file.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/Makefile.am3
-rw-r--r--cpukit/rtems/include/rtems/rtems/tasks.h18
-rw-r--r--cpukit/rtems/src/tasks.c10
-rw-r--r--cpukit/rtems/src/taskvariable_invoke_dtor.c43
-rw-r--r--cpukit/rtems/src/taskvariableadd.c2
-rw-r--r--cpukit/rtems/src/taskvariabledelete.c11
6 files changed, 66 insertions, 21 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 1062221001..2040578047 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -7,6 +7,7 @@ include $(top_srcdir)/automake/compile.am
AM_CPPFLAGS += -D__RTEMS_INSIDE__
+project_lib_LIBRARIES = librtems.a
noinst_LIBRARIES = librtems.a
librtems_a_CPPFLAGS = $(AM_CPPFLAGS)
@@ -61,7 +62,7 @@ librtems_a_SOURCES += src/tasks.c src/taskcreate.c src/taskdelete.c \
src/tasksetnote.c src/tasksetpriority.c src/taskstart.c \
src/tasksuspend.c src/taskwakeafter.c src/taskwakewhen.c \
src/taskvariableadd.c src/taskvariabledelete.c src/taskvariableget.c \
- src/taskdata.c
+ src/taskvariable_invoke_dtor.c src/taskdata.c
## RATEMON_C_FILES
librtems_a_SOURCES += src/ratemon.c src/ratemoncancel.c src/ratemoncreate.c \
diff --git a/cpukit/rtems/include/rtems/rtems/tasks.h b/cpukit/rtems/include/rtems/rtems/tasks.h
index a8efc5518e..0da7906fe1 100644
--- a/cpukit/rtems/include/rtems/rtems/tasks.h
+++ b/cpukit/rtems/include/rtems/rtems/tasks.h
@@ -23,7 +23,7 @@
* + wake up after interval
* + wake up when specified
*
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -449,6 +449,22 @@ rtems_status_code rtems_task_variable_delete(
void _RTEMS_tasks_Initialize_user_tasks( void );
+/*
+ * _RTEMS_Tasks_Invoke_task_variable_dtor(
+ *
+ * This routine invokes the optional user provided destructor on the
+ * task variable and frees the memory for the task variable.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ */
+
+void _RTEMS_Tasks_Invoke_task_variable_dtor(
+ Thread_Control *the_thread,
+ rtems_task_variable_t *tvp
+);
+
#ifndef __RTEMS_APPLICATION__
#include <rtems/rtems/tasks.inl>
#endif
diff --git a/cpukit/rtems/src/tasks.c b/cpukit/rtems/src/tasks.c
index 78d50db831..cfa849c1ae 100644
--- a/cpukit/rtems/src/tasks.c
+++ b/cpukit/rtems/src/tasks.c
@@ -111,15 +111,7 @@ User_extensions_routine _RTEMS_tasks_Delete_extension(
deleted->task_variables = NULL;
while (tvp) {
next = (rtems_task_variable_t *)tvp->next;
- if (_Thread_Is_executing(deleted)) {
- if (tvp->dtor)
- (*tvp->dtor)(*tvp->ptr);
- *tvp->ptr = tvp->gval;
- } else {
- if (tvp->dtor)
- (*tvp->dtor)(tvp->tval);
- }
- _Workspace_Free( tvp );
+ _RTEMS_Tasks_Invoke_task_variable_dtor( deleted, tvp );
tvp = next;
}
diff --git a/cpukit/rtems/src/taskvariable_invoke_dtor.c b/cpukit/rtems/src/taskvariable_invoke_dtor.c
new file mode 100644
index 0000000000..d348c6d90e
--- /dev/null
+++ b/cpukit/rtems/src/taskvariable_invoke_dtor.c
@@ -0,0 +1,43 @@
+/*
+ * Invoke the destructor on a per-task variable
+ *
+ *
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/system.h>
+#include <rtems/rtems/tasks.h>
+#include <rtems/score/wkspace.h>
+
+void _RTEMS_Tasks_Invoke_task_variable_dtor(
+ Thread_Control *the_thread,
+ rtems_task_variable_t *tvp
+)
+{
+ void (*dtor)(void *);
+ void *value;
+
+ dtor = tvp->dtor;
+ if (_Thread_Is_executing(the_thread)) {
+ value = *tvp->ptr;
+ *tvp->ptr = tvp->gval;
+ } else {
+ value = tvp->tval;
+ }
+
+ if ( dtor )
+ (*dtor)(value);
+
+ _Workspace_Free(tvp);
+}
diff --git a/cpukit/rtems/src/taskvariableadd.c b/cpukit/rtems/src/taskvariableadd.c
index 080d6eebf1..41d6bed57c 100644
--- a/cpukit/rtems/src/taskvariableadd.c
+++ b/cpukit/rtems/src/taskvariableadd.c
@@ -49,7 +49,7 @@ rtems_status_code rtems_task_variable_add(
tvp = the_thread->task_variables;
while (tvp) {
if (tvp->ptr == ptr) {
- tvp->dtor = dtor;
+ tvp->dtor = dtor;
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/taskvariabledelete.c b/cpukit/rtems/src/taskvariabledelete.c
index d45f5fe7df..e376c0167e 100644
--- a/cpukit/rtems/src/taskvariabledelete.c
+++ b/cpukit/rtems/src/taskvariabledelete.c
@@ -51,15 +51,8 @@ rtems_status_code rtems_task_variable_delete(
prev->next = tvp->next;
else
the_thread->task_variables = (rtems_task_variable_t *)tvp->next;
- if (_Thread_Is_executing(the_thread)) {
- if (tvp->dtor)
- (*tvp->dtor)(*tvp->ptr);
- *tvp->ptr = tvp->gval;
- } else {
- if (tvp->dtor)
- (*tvp->dtor)(tvp->tval);
- }
- _Workspace_Free(tvp);
+
+ _RTEMS_Tasks_Invoke_task_variable_dtor( the_thread, tvp );
_Thread_Enable_dispatch();
return RTEMS_SUCCESSFUL;
}