5
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 | |
---|
32 | void *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 | |
---|
46 | void *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 | |
---|
62 | void 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.