source: rtems/cpukit/rtems/src/partgetbuffer.c @ eaef4657

4.104.115
Last change on this file since eaef4657 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.0 KB
Line 
1/*
2 *  Partition Manager
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/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/score/address.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/part.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/sysstate.h>
27
28/*PAGE
29 *
30 *  rtems_partition_get_buffer
31 *
32 *  This directive will obtain a buffer from a buffer partition.
33 *
34 *  Input parameters:
35 *    id     - partition id
36 *    buffer - pointer to buffer address
37 *
38 *  Output parameters:
39 *    buffer            - pointer to buffer address filled in
40 *    RTEMS_SUCCESSFUL - if successful
41 *    error code        - if unsuccessful
42 */
43
44rtems_status_code rtems_partition_get_buffer(
45  Objects_Id   id,
46  void       **buffer
47)
48{
49  register Partition_Control *the_partition;
50  Objects_Locations           location;
51  void                       *the_buffer;
52
53  if ( !buffer )
54    return RTEMS_INVALID_ADDRESS;
55
56  the_partition = _Partition_Get( id, &location );
57  switch ( location ) {
58
59    case OBJECTS_LOCAL:
60      the_buffer = _Partition_Allocate_buffer( the_partition );
61      if ( the_buffer ) {
62        the_partition->number_of_used_blocks += 1;
63        _Thread_Enable_dispatch();
64        *buffer = the_buffer;
65        return RTEMS_SUCCESSFUL;
66      }
67      _Thread_Enable_dispatch();
68      return RTEMS_UNSATISFIED;
69
70#if defined(RTEMS_MULTIPROCESSING)
71    case OBJECTS_REMOTE:
72      _Thread_Executing->Wait.return_argument = buffer;
73      return(
74        _Partition_MP_Send_request_packet(
75          PARTITION_MP_GET_BUFFER_REQUEST,
76          id,
77          0           /* Not used */
78        )
79      );
80#endif
81
82    case OBJECTS_ERROR:
83      break;
84  }
85
86  return RTEMS_INVALID_ID;
87}
Note: See TracBrowser for help on using the repository browser.