source: rtems/cpukit/rtems/src/taskvariableget.c @ f26145b

4.104.114.84.95
Last change on this file since f26145b was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  rtems_task_variable_get - Get 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_get
25 *
26 *  This directive gets the value of a task variable.
27 */
28
29rtems_status_code rtems_task_variable_get(
30  rtems_id tid,
31  void **ptr,
32  void **result
33)
34{
35  Thread_Control        *the_thread;
36  Objects_Locations      location;
37  rtems_task_variable_t *tvp;
38
39  if ( !ptr )
40    return RTEMS_INVALID_ADDRESS;
41
42  if ( !result )
43    return RTEMS_INVALID_ADDRESS;
44
45  the_thread = _Thread_Get (tid, &location);
46  switch (location) {
47  case OBJECTS_REMOTE:
48#if defined(RTEMS_MULTIPROCESSING)
49    _Thread_Dispatch();
50    return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
51#endif
52
53  case OBJECTS_ERROR:
54    return RTEMS_INVALID_ID;
55
56  default:
57    return RTEMS_INTERNAL_ERROR;
58
59  case OBJECTS_LOCAL:
60
61    /*
62     *  Figure out if the variable is in this task's list.
63     */
64
65    tvp = the_thread->task_variables;
66    while (tvp) {
67      if (tvp->ptr == ptr) {
68        /*
69         * Should this return the current (i.e not the
70         * saved) value if `tid' is the current task?
71         */
72        *result = tvp->tval;
73        _Thread_Enable_dispatch();
74        return RTEMS_SUCCESSFUL;
75      }
76      tvp = tvp->next;
77    }
78    _Thread_Enable_dispatch();
79    return RTEMS_INVALID_ADDRESS;
80  }
81  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
82}
Note: See TracBrowser for help on using the repository browser.