source: rtems/cpukit/rtems/src/taskvariabledelete.c @ 98dee44b

4.104.114.95
Last change on this file since 98dee44b was 98dee44b, checked in by Joel Sherrill <joel.sherrill@…>, on 12/12/07 at 23:19:57

2007-12-12 Joel Sherrill <joel.sherrill@…>

  • 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.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  rtems_task_variable_delete - Delete a per-task variable
3 *
4 *
5 *  COPYRIGHT (c) 1989-2007.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/tasks.h>
21#include <rtems/score/wkspace.h>
22
23/*
24 *  rtems_task_variable_delete
25 *
26 *  This directive removes a task variable.
27 */
28
29rtems_status_code rtems_task_variable_delete(
30  rtems_id  tid,
31  void    **ptr
32)
33{
34  Thread_Control        *the_thread;
35  Objects_Locations      location;
36  rtems_task_variable_t *tvp, *prev;
37
38  if ( !ptr )
39    return RTEMS_INVALID_ADDRESS;
40
41  prev = NULL;
42
43  the_thread = _Thread_Get (tid, &location);
44  switch (location) {
45
46    case OBJECTS_LOCAL:
47      tvp = the_thread->task_variables;
48      while (tvp) {
49        if (tvp->ptr == ptr) {
50          if (prev)
51            prev->next = tvp->next;
52          else     
53            the_thread->task_variables = (rtems_task_variable_t *)tvp->next;
54
55          _RTEMS_Tasks_Invoke_task_variable_dtor( the_thread, tvp );
56          _Thread_Enable_dispatch();
57          return RTEMS_SUCCESSFUL;
58        }
59        prev = tvp;
60        tvp = (rtems_task_variable_t *)tvp->next;
61      }
62      _Thread_Enable_dispatch();
63      return RTEMS_INVALID_ADDRESS;
64
65#if defined(RTEMS_MULTIPROCESSING)
66    case OBJECTS_REMOTE:
67      _Thread_Dispatch();
68      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
69#endif
70
71    case OBJECTS_ERROR:
72        break;
73  }
74
75  return RTEMS_INVALID_ID;
76}
Note: See TracBrowser for help on using the repository browser.