OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [rtems/] [src/] [taskvariabledelete.c] - Blame information for rev 587

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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.OARcorp.com/rtems/license.html.
11
 *
12
 *  $Id: taskvariabledelete.c,v 1.2 2001-09-27 11:59:19 chris Exp $
13
 */
14
 
15
#include <rtems/system.h>
16
#include <rtems/rtems/tasks.h>
17
#include <rtems/score/wkspace.h>
18
 
19
/*
20
 *  rtems_task_variable_delete
21
 *
22
 *  This directive removes a task variable.
23
 */
24
 
25
rtems_status_code rtems_task_variable_delete(
26
  rtems_id  tid,
27
  void    **ptr
28
)
29
{
30
  Thread_Control        *the_thread;
31
  Objects_Locations      location;
32
  rtems_task_variable_t *tvp, *prev;
33
 
34
  prev = NULL;
35
 
36
  the_thread = _Thread_Get (tid, &location);
37
  switch (location) {
38
  case OBJECTS_REMOTE:
39
#if defined(RTEMS_MULTIPROCESSING)
40
    _Thread_Dispatch();
41
    return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
42
#endif
43
 
44
  case OBJECTS_ERROR:
45
    return RTEMS_INVALID_ID;
46
 
47
  default:
48
    return RTEMS_INTERNAL_ERROR;
49
 
50
  case OBJECTS_LOCAL:
51
    tvp = the_thread->task_variables;
52
    while (tvp) {
53
      if (tvp->ptr == ptr) {
54
        if (prev) prev->next = tvp->next;
55
        else      the_thread->task_variables = tvp->next;
56
        if (_Thread_Is_executing (the_thread))
57
          *tvp->ptr = tvp->gval;
58
        _Thread_Enable_dispatch();
59
        _Workspace_Free(tvp);
60
        return RTEMS_SUCCESSFUL;
61
      }
62
      prev = tvp;
63
      tvp = tvp->next;
64
    }
65
    _Thread_Enable_dispatch();
66
    return RTEMS_INVALID_ADDRESS;
67
  }
68
 
69
  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
70
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.