source: rtems/cpukit/rtems/src/workspacegreedy.c @ 1240aade

5
Last change on this file since 1240aade was b2700c35, checked in by Sebastian Huber <sebastian.huber@…>, on 04/07/14 at 13:55:55

score: Use proper protection

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Greedy Allocate that Empties the Workspace and Free
5 *  @ingroup ClassicRTEMS
6 */
7
8/*
9 * Copyright (c) 2012 embedded brains GmbH.  All rights reserved.
10 *
11 *  embedded brains GmbH
12 *  Obere Lagerstr. 30
13 *  82178 Puchheim
14 *  Germany
15 *  <rtems@embedded-brains.de>
16 *
17 * The license and distribution terms for this file may be
18 * found in the file LICENSE in this distribution or at
19 * http://www.rtems.org/license/LICENSE.
20 */
21
22#if HAVE_CONFIG_H
23  #include "config.h"
24#endif
25
26#include <rtems/rtems/support.h>
27#include <rtems/score/apimutex.h>
28#include <rtems/score/heapimpl.h>
29#include <rtems/score/threaddispatch.h>
30#include <rtems/score/wkspace.h>
31
32void *rtems_workspace_greedy_allocate(
33  const uintptr_t *block_sizes,
34  size_t block_count
35)
36{
37  void *opaque;
38
39  _RTEMS_Lock_allocator();
40  opaque = _Heap_Greedy_allocate( &_Workspace_Area, block_sizes, block_count );
41  _RTEMS_Unlock_allocator();
42
43  return opaque;
44}
45
46void *rtems_workspace_greedy_allocate_all_except_largest(
47  uintptr_t *allocatable_size
48)
49{
50  void *opaque;
51
52  _RTEMS_Lock_allocator();
53  opaque = _Heap_Greedy_allocate_all_except_largest(
54    &_Workspace_Area,
55    allocatable_size
56  );
57  _RTEMS_Unlock_allocator();
58
59  return opaque;
60}
61
62void rtems_workspace_greedy_free( void *opaque )
63{
64  _RTEMS_Lock_allocator();
65  _Heap_Greedy_free( &_Workspace_Area, opaque );
66  _RTEMS_Unlock_allocator();
67}
Note: See TracBrowser for help on using the repository browser.