source: rtems/cpukit/rtems/src/taskvariabledelete.c @ 11b4e07

4.104.114.84.95
Last change on this file since 11b4e07 was 11b4e07, checked in by Joel Sherrill <joel.sherrill@…>, on 02/01/06 at 18:39:45

2006-02-01 Joel Sherrill <joel@…>

  • rtems/src/tasks.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c, rtems/src/taskvariableget.c: Remove warnings.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  rtems_task_variable_delete - Delete a per-task variable
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
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  case OBJECTS_REMOTE:
46#if defined(RTEMS_MULTIPROCESSING)
47    _Thread_Dispatch();
48    return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
49#endif
50
51  case OBJECTS_ERROR:
52    return RTEMS_INVALID_ID;
53
54  default:
55    return RTEMS_INTERNAL_ERROR;
56
57  case OBJECTS_LOCAL:
58    tvp = the_thread->task_variables;
59    while (tvp) {
60      if (tvp->ptr == ptr) {
61        if (prev)
62          prev->next = tvp->next;
63        else     
64          the_thread->task_variables = (rtems_task_variable_t *)tvp->next;
65        if (_Thread_Is_executing(the_thread)) {
66          if (tvp->dtor)
67            (*tvp->dtor)(*tvp->ptr);
68          *tvp->ptr = tvp->gval;
69        } else {
70          if (tvp->dtor)
71            (*tvp->dtor)(tvp->tval);
72        }
73        _Workspace_Free(tvp);
74        _Thread_Enable_dispatch();
75        return RTEMS_SUCCESSFUL;
76      }
77      prev = tvp;
78      tvp = (rtems_task_variable_t *)tvp->next;
79    }
80    _Thread_Enable_dispatch();
81    return RTEMS_INVALID_ADDRESS;
82  }
83
84  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
85}
Note: See TracBrowser for help on using the repository browser.