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

4.104.114.95
Last change on this file since ebe61382 was ebe61382, checked in by Joel Sherrill <joel.sherrill@…>, on 11/30/07 at 21:49:41

2007-11-30 Joel Sherrill <joel.sherrill@…>

  • rtems/src/barrierdelete.c, rtems/src/barrierrelease.c, rtems/src/barriertranslatereturncode.c, rtems/src/barrierwait.c, rtems/src/clockget.c, rtems/src/dpmemdelete.c, rtems/src/dpmemexternal2internal.c, rtems/src/dpmeminternal2external.c, rtems/src/eventsend.c, rtems/src/eventtimeout.c, rtems/src/msgqbroadcast.c, rtems/src/msgqdelete.c, rtems/src/msgqflush.c, rtems/src/msgqgetnumberpending.c, rtems/src/msgqreceive.c, rtems/src/msgqsend.c, rtems/src/msgqurgent.c, rtems/src/partdelete.c, rtems/src/partgetbuffer.c, rtems/src/partreturnbuffer.c, rtems/src/ratemoncancel.c, rtems/src/ratemondelete.c, rtems/src/ratemongetstatistics.c, rtems/src/ratemongetstatus.c, rtems/src/ratemonperiod.c, rtems/src/ratemonresetstatistics.c, rtems/src/ratemontimeout.c, rtems/src/semdelete.c, rtems/src/semflush.c, rtems/src/semobtain.c, rtems/src/semrelease.c, rtems/src/semtranslatereturncode.c, rtems/src/signalsend.c, rtems/src/taskdelete.c, rtems/src/taskgetnote.c, rtems/src/taskissuspended.c, rtems/src/taskrestart.c, rtems/src/taskresume.c, rtems/src/tasksetnote.c, rtems/src/tasksetpriority.c, rtems/src/taskstart.c, rtems/src/tasksuspend.c, rtems/src/taskvariableadd.c, rtems/src/taskvariabledelete.c, rtems/src/taskvariableget.c, rtems/src/timercancel.c, rtems/src/timerdelete.c, rtems/src/timerfirewhen.c, rtems/src/timergetinfo.c, rtems/src/timerreset.c, rtems/src/timerserverfireafter.c, rtems/src/timerserverfirewhen.c: Restructured all code with the switch (location) pattern so that OBJECTS_LOCAL is first and we can fall into it and the OBJECTS_ERROR case breaks to a return RTEMS_INVALID_ID. This eliminates the return RTEMS_INTERNAL_ERROR at the bottom of each of these files which was unreachable and untestable code. This resulted in a code savings of approximately 20 bytes per file on the SPARC/ERC32.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  rtems_task_variable_get - Get 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_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
48    case OBJECTS_LOCAL:
49      /*
50       *  Figure out if the variable is in this task's list.
51       */
52      tvp = the_thread->task_variables;
53      while (tvp) {
54        if (tvp->ptr == ptr) {
55          /*
56           * Should this return the current (i.e not the
57           * saved) value if `tid' is the current task?
58           */
59          *result = tvp->tval;
60          _Thread_Enable_dispatch();
61          return RTEMS_SUCCESSFUL;
62        }
63        tvp = (rtems_task_variable_t *)tvp->next;
64      }
65      _Thread_Enable_dispatch();
66      return RTEMS_INVALID_ADDRESS;
67
68#if defined(RTEMS_MULTIPROCESSING)
69    case OBJECTS_REMOTE:
70      _Thread_Dispatch();
71      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
72#endif
73
74    case OBJECTS_ERROR:
75      break;
76  }
77  return RTEMS_INVALID_ID;
78}
Note: See TracBrowser for help on using the repository browser.