source: rtems/cpukit/rtems/src/regiongetsegmentsize.c @ 66cb142

5
Last change on this file since 66cb142 was 1142f55, checked in by Sebastian Huber <sebastian.huber@…>, on 04/08/16 at 04:56:46

rtems: Add and use _Region_Get_and_lock()

Get region and lock allocator in _Region_Get_and_lock() in case the
region exists and unlock it in _Region_Unlock().

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Get Region Segment Size
5 *  @ingroup ClassicRegion
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#include <rtems/rtems/regionimpl.h>
22
23rtems_status_code rtems_region_get_segment_size(
24  rtems_id   id,
25  void      *segment,
26  uintptr_t *size
27)
28{
29  rtems_status_code  status;
30  Region_Control    *the_region;
31
32  if ( segment == NULL ) {
33    return RTEMS_INVALID_ADDRESS;
34  }
35
36  if ( size == NULL ) {
37    return RTEMS_INVALID_ADDRESS;
38  }
39
40  the_region = _Region_Get_and_lock( id );
41
42  if ( the_region == NULL ) {
43    return RTEMS_INVALID_ID;
44  }
45
46  if ( _Heap_Size_of_alloc_area( &the_region->Memory, segment, size ) ) {
47    status = RTEMS_SUCCESSFUL;
48  } else {
49    status = RTEMS_INVALID_ADDRESS;
50  }
51
52  _Region_Unlock( the_region );
53  return status;
54}
Note: See TracBrowser for help on using the repository browser.