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

4.104.114.95
Last change on this file since 5b33dc80 was 5b33dc80, checked in by Joel Sherrill <joel.sherrill@…>, on 01/09/08 at 22:35:10

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
RevLine 
[ac7d5ef0]1/*
2 *  Workspace Handler
3 *
[976162a6]4 *  COPYRIGHT (c) 1989-2007.
[ac7d5ef0]5 *  On-Line Applications Research Corporation (OAR).
6 *
[98e4ebf5]7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
[dd687d97]9 *  http://www.rtems.com/license/LICENSE.
[ac7d5ef0]10 *
[63edbb3f]11 *  $Id$
[ac7d5ef0]12 */
13
[a8eed23]14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
[ac7d5ef0]18#include <rtems/system.h>
[5e9b32b]19#include <rtems/score/wkspace.h>
20#include <rtems/score/interr.h>
[976162a6]21#include <rtems/config.h>
22
23#include <string.h>  /* for memset */
[ac7d5ef0]24
[5b33dc80]25/*
[8faca06]26 *  _Workspace_Handler_initialization
27 */
28void _Workspace_Handler_initialization(
29  void       *starting_address,
[37c7bfcb]30  size_t      size
[8faca06]31)
32{
[3127180]33  uint32_t    memory_available;
[05279b84]34
[8faca06]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    );
[05279b84]41
[976162a6]42  if ( _Configuration_Table->do_zero_of_workspace )
43   memset( starting_address, 0, size );
[05279b84]44
[8faca06]45  memory_available = _Heap_Initialize(
46    &_Workspace_Area,
47    starting_address,
48    size,
49    CPU_HEAP_ALIGNMENT
50  );
[05279b84]51
[8faca06]52  if ( memory_available == 0 )
53    _Internal_error_Occurred(
54      INTERNAL_ERROR_CORE,
55      TRUE,
56      INTERNAL_ERROR_TOO_LITTLE_WORKSPACE
57    );
58}
59
[5b33dc80]60/*
61 *  _Workspace_Allocate
[ac7d5ef0]62 */
[5b33dc80]63void *_Workspace_Allocate(
64  size_t   size
65)
66{
67   return _Heap_Allocate( &_Workspace_Area, size );
68}
[ac7d5ef0]69
[5b33dc80]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 */
[ac7d5ef0]83void *_Workspace_Allocate_or_fatal_error(
[37c7bfcb]84  size_t      size
[ac7d5ef0]85)
86{
87  void        *memory;
88
89  memory = _Workspace_Allocate( size );
90
91  if ( memory == NULL )
[3a4ae6c]92    _Internal_error_Occurred(
93      INTERNAL_ERROR_CORE,
94      TRUE,
95      INTERNAL_ERROR_WORKSPACE_ALLOCATION
96    );
[ac7d5ef0]97
98  return memory;
99}
Note: See TracBrowser for help on using the repository browser.