source: rtems/cpukit/rtems/src/semflush.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: 2.4 KB
Line 
1/*
2 *  rtems_semaphore_flush
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the flush directive
7 *  of the Semaphore Manager.
8 *
9 *  COPYRIGHT (c) 1989-2007.
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.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <rtems/system.h>
24#include <rtems/rtems/status.h>
25#include <rtems/rtems/support.h>
26#include <rtems/rtems/attr.h>
27#include <rtems/score/isr.h>
28#include <rtems/score/object.h>
29#include <rtems/rtems/options.h>
30#include <rtems/rtems/sem.h>
31#include <rtems/score/coremutex.h>
32#include <rtems/score/coresem.h>
33#include <rtems/score/states.h>
34#include <rtems/score/thread.h>
35#include <rtems/score/threadq.h>
36#if defined(RTEMS_MULTIPROCESSING)
37#include <rtems/score/mpci.h>
38#endif
39#include <rtems/score/sysstate.h>
40
41#include <rtems/score/interr.h>
42
43/*PAGE
44 *
45 *  rtems_semaphore_flush
46 *
47 *  This directive allows a thread to flush the threads
48 *  pending on the semaphore.
49 *
50 *  Input parameters:
51 *    id         - semaphore id
52 *
53 *  Output parameters:
54 *    RTEMS_SUCCESSFUL - if successful
55 *    error code       - if unsuccessful
56 */
57
58#if defined(RTEMS_MULTIPROCESSING)
59#define SEND_OBJECT_WAS_DELETED _Semaphore_MP_Send_object_was_deleted
60#else
61#define SEND_OBJECT_WAS_DELETED NULL
62#endif
63
64rtems_status_code rtems_semaphore_flush(
65  rtems_id        id
66)
67{
68  register Semaphore_Control *the_semaphore;
69  Objects_Locations           location;
70
71  the_semaphore = _Semaphore_Get( id, &location );
72  switch ( location ) {
73
74    case OBJECTS_LOCAL:
75      if ( !_Attributes_Is_counting_semaphore(the_semaphore->attribute_set) ) {
76        _CORE_mutex_Flush(
77          &the_semaphore->Core_control.mutex,
78          SEND_OBJECT_WAS_DELETED,
79          CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT
80        );
81      } else {
82        _CORE_semaphore_Flush(
83          &the_semaphore->Core_control.semaphore,
84          SEND_OBJECT_WAS_DELETED,
85          CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT
86        );
87      }
88      _Thread_Enable_dispatch();
89      return RTEMS_SUCCESSFUL;
90
91#if defined(RTEMS_MULTIPROCESSING)
92    case OBJECTS_REMOTE:
93      _Thread_Dispatch();
94      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
95#endif
96
97    case OBJECTS_ERROR:
98      break;
99  }
100
101  return RTEMS_INVALID_ID;
102}
Note: See TracBrowser for help on using the repository browser.