source: rtems/cpukit/score/src/wkspace.c @ 5b33dc80

4.104.114.9
Last change on this file since 5b33dc80 was 5b33dc80, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 9, 2008 at 10:35:10 PM

2008-01-09 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/wkspace.h, score/inline/rtems/score/wkspace.inl, score/src/wkspace.c: Do not inline _Workspace_Free or _Workspace_Allocate since they are not always inlined and actually smaller overall as subroutines. They are not particularly time critical so inlining is not absolutely necessary.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  Workspace Handler
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/score/wkspace.h>
20#include <rtems/score/interr.h>
21#include <rtems/config.h>
22
23#include <string.h>  /* for memset */
24
25/*
26 *  _Workspace_Handler_initialization
27 */
28void _Workspace_Handler_initialization(
29  void       *starting_address,
30  size_t      size
31)
32{
33  uint32_t    memory_available;
34
35  if ( !starting_address || !_Addresses_Is_aligned( starting_address ) )
36    _Internal_error_Occurred(
37      INTERNAL_ERROR_CORE,
38      TRUE,
39      INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS
40    );
41
42  if ( _Configuration_Table->do_zero_of_workspace )
43   memset( starting_address, 0, size );
44
45  memory_available = _Heap_Initialize(
46    &_Workspace_Area,
47    starting_address,
48    size,
49    CPU_HEAP_ALIGNMENT
50  );
51
52  if ( memory_available == 0 )
53    _Internal_error_Occurred(
54      INTERNAL_ERROR_CORE,
55      TRUE,
56      INTERNAL_ERROR_TOO_LITTLE_WORKSPACE
57    );
58}
59
60/*
61 *  _Workspace_Allocate
62 */
63void *_Workspace_Allocate(
64  size_t   size
65)
66{
67   return _Heap_Allocate( &_Workspace_Area, size );
68}
69
70/*
71 *  _Workspace_Allocate
72 */
73boolean _Workspace_Free(
74  void *block
75)
76{
77   return _Heap_Free( &_Workspace_Area, block );
78}
79
80/*
81 *  _Workspace_Allocate_or_fatal_error
82 */
83void *_Workspace_Allocate_or_fatal_error(
84  size_t      size
85)
86{
87  void        *memory;
88
89  memory = _Workspace_Allocate( size );
90
91  if ( memory == NULL )
92    _Internal_error_Occurred(
93      INTERNAL_ERROR_CORE,
94      TRUE,
95      INTERNAL_ERROR_WORKSPACE_ALLOCATION
96    );
97
98  return memory;
99}
Note: See TracBrowser for help on using the repository browser.