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

4.104.114.9
Last change on this file since ebe61382 was ebe61382, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 30, 2007 at 9:49:41 PM

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.5 KB
Line 
1/*
2 *  Barrier Manager -- Wait at a Barrier
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/rtems/status.h>
20#include <rtems/rtems/support.h>
21#include <rtems/rtems/barrier.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/threadq.h>
24
25/*
26 *  rtems_barrier_wait
27 *
28 *  This directive allows a thread to wait at a barrier.
29 *
30 *  Input parameters:
31 *    id         - barrier id
32 *    timeout    - number of ticks to wait (0 means wait forever)
33 *
34 *  Output parameters:
35 *    RTEMS_SUCCESSFUL - if successful
36 *    error code        - if unsuccessful
37 */
38
39rtems_status_code rtems_barrier_wait(
40  rtems_id        id,
41  rtems_interval  timeout
42)
43{
44  Barrier_Control   *the_barrier;
45  Objects_Locations  location;
46
47  the_barrier = _Barrier_Get( id, &location );
48  switch ( location ) {
49
50    case OBJECTS_LOCAL:
51      _CORE_barrier_Wait(
52        &the_barrier->Barrier,
53        id,
54        TRUE,
55        timeout,
56        NULL
57      );
58      _Thread_Enable_dispatch();
59      return _Barrier_Translate_core_barrier_return_code(
60                _Thread_Executing->Wait.return_code );
61
62#if defined(RTEMS_MULTIPROCESSING)
63    case OBJECTS_REMOTE:
64#endif
65    case OBJECTS_ERROR:
66      break;
67  }
68
69  return RTEMS_INVALID_ID;
70}
Note: See TracBrowser for help on using the repository browser.