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

4.115
Last change on this file since e6b31b27 was 217b3f53, checked in by Joel Sherrill <joel.sherrill@…>, on 03/14/15 at 16:04:25

Disable deprecated warning on implementation of deprecated methods

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Get a per-task variable
5 * @ingroup ClassicTasks Tasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#if !defined(RTEMS_SMP)
22#include <rtems/rtems/tasksimpl.h>
23#include <rtems/score/threadimpl.h>
24#include <rtems/score/wkspace.h>
25#include <rtems/config.h>
26
27/*
28 * We know this is deprecated and don't want a warning on every BSP built.
29 */
30#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
31
32rtems_status_code rtems_task_variable_get(
33  rtems_id tid,
34  void **ptr,
35  void **result
36)
37{
38  Thread_Control        *the_thread;
39  Objects_Locations      location;
40  rtems_task_variable_t *tvp;
41
42#if defined( RTEMS_SMP )
43  if ( rtems_configuration_is_smp_enabled() ) {
44    return RTEMS_NOT_IMPLEMENTED;
45  }
46#endif
47
48  if ( !ptr )
49    return RTEMS_INVALID_ADDRESS;
50
51  if ( !result )
52    return RTEMS_INVALID_ADDRESS;
53
54  the_thread = _Thread_Get (tid, &location);
55  switch (location) {
56
57    case OBJECTS_LOCAL:
58      /*
59       *  Figure out if the variable is in this task's list.
60       */
61      tvp = the_thread->task_variables;
62      while (tvp) {
63        if (tvp->ptr == ptr) {
64          /*
65           * Should this return the current (i.e not the
66           * saved) value if `tid' is the current task?
67           */
68          *result = tvp->tval;
69          _Objects_Put( &the_thread->Object );
70          return RTEMS_SUCCESSFUL;
71        }
72        tvp = (rtems_task_variable_t *)tvp->next;
73      }
74      _Objects_Put( &the_thread->Object );
75      return RTEMS_INVALID_ADDRESS;
76
77#if defined(RTEMS_MULTIPROCESSING)
78    case OBJECTS_REMOTE:
79      _Thread_Dispatch();
80      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
81#endif
82
83    case OBJECTS_ERROR:
84      break;
85  }
86  return RTEMS_INVALID_ID;
87}
88#endif
Note: See TracBrowser for help on using the repository browser.