4.115
Last change
on this file since d0d357ed was
d0d357ed,
checked in by Sebastian Huber <sebastian.huber@…>, on 06/25/13 at 10:09:50
|
heap: Add _Heap_Greedy_allocate_all_except_largest
Add rtems_workspace_greedy_allocate_all_except_largest() and
rtems_heap_greedy_allocate_all_except_largest().
|
-
Property mode set to
100644
|
File size:
1.3 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.com/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/wkspace.h> |
---|
28 | |
---|
29 | void *rtems_workspace_greedy_allocate( |
---|
30 | const uintptr_t *block_sizes, |
---|
31 | size_t block_count |
---|
32 | ) |
---|
33 | { |
---|
34 | void *opaque; |
---|
35 | |
---|
36 | _Thread_Disable_dispatch(); |
---|
37 | opaque = _Heap_Greedy_allocate( &_Workspace_Area, block_sizes, block_count ); |
---|
38 | _Thread_Enable_dispatch(); |
---|
39 | |
---|
40 | return opaque; |
---|
41 | } |
---|
42 | |
---|
43 | void *rtems_workspace_greedy_allocate_all_except_largest( |
---|
44 | uintptr_t *allocatable_size |
---|
45 | ) |
---|
46 | { |
---|
47 | void *opaque; |
---|
48 | |
---|
49 | _Thread_Disable_dispatch(); |
---|
50 | opaque = _Heap_Greedy_allocate_all_except_largest( |
---|
51 | &_Workspace_Area, |
---|
52 | allocatable_size |
---|
53 | ); |
---|
54 | _Thread_Enable_dispatch(); |
---|
55 | |
---|
56 | return opaque; |
---|
57 | } |
---|
58 | |
---|
59 | void rtems_workspace_greedy_free( void *opaque ) |
---|
60 | { |
---|
61 | _Thread_Disable_dispatch(); |
---|
62 | _Heap_Greedy_free( &_Workspace_Area, opaque ); |
---|
63 | _Thread_Enable_dispatch(); |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.