1 | /* |
---|
2 | * BASED UPON SOURCE IN RTEMS, MODIFIED FOR SIMULATOR |
---|
3 | * |
---|
4 | * Workspace Handler |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-2010. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #if HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <rtems/system.h> |
---|
21 | #include <rtems/score/wkspace.h> |
---|
22 | #include <rtems/score/interr.h> |
---|
23 | |
---|
24 | #include <stdlib.h> |
---|
25 | |
---|
26 | #if defined(DEBUG_WORKSPACE) |
---|
27 | #include <stdio.h> |
---|
28 | #endif |
---|
29 | |
---|
30 | /* |
---|
31 | * _Workspace_Handler_initialization |
---|
32 | */ |
---|
33 | void _Workspace_Handler_initialization(void) |
---|
34 | { |
---|
35 | } |
---|
36 | |
---|
37 | /* |
---|
38 | * _Workspace_Allocate |
---|
39 | */ |
---|
40 | void *_Workspace_Allocate( |
---|
41 | size_t size |
---|
42 | ) |
---|
43 | { |
---|
44 | void *memory; |
---|
45 | |
---|
46 | memory = calloc( 1, size ); |
---|
47 | #if defined(DEBUG_WORKSPACE) |
---|
48 | fprintf( |
---|
49 | stderr, |
---|
50 | "Workspace_Allocate(%d) from %p/%p -> %p\n", |
---|
51 | size, |
---|
52 | __builtin_return_address( 0 ), |
---|
53 | __builtin_return_address( 1 ), |
---|
54 | memory |
---|
55 | ); |
---|
56 | #endif |
---|
57 | return memory; |
---|
58 | } |
---|
59 | |
---|
60 | /* |
---|
61 | * _Workspace_Free |
---|
62 | */ |
---|
63 | void _Workspace_Free( |
---|
64 | void *block |
---|
65 | ) |
---|
66 | { |
---|
67 | #if defined(DEBUG_WORKSPACE) |
---|
68 | fprintf( |
---|
69 | stderr, |
---|
70 | block, |
---|
71 | __builtin_return_address( 0 ), |
---|
72 | __builtin_return_address( 1 ) |
---|
73 | ); |
---|
74 | #endif |
---|
75 | free( block ); |
---|
76 | } |
---|
77 | |
---|
78 | /* |
---|
79 | * _Workspace_Allocate_or_fatal_error |
---|
80 | */ |
---|
81 | void *_Workspace_Allocate_or_fatal_error( |
---|
82 | size_t size |
---|
83 | ) |
---|
84 | { |
---|
85 | void *memory; |
---|
86 | |
---|
87 | memory = calloc( 1, size ); |
---|
88 | #if defined(DEBUG_WORKSPACE) |
---|
89 | fprintf( |
---|
90 | stderr, |
---|
91 | "Workspace_Allocate_or_fatal_error(%d) from %p/%p -> %p\n", |
---|
92 | size, |
---|
93 | __builtin_return_address( 0 ), |
---|
94 | __builtin_return_address( 1 ), |
---|
95 | memory |
---|
96 | ); |
---|
97 | #endif |
---|
98 | |
---|
99 | return memory; |
---|
100 | } |
---|