OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [memalloc/] [common/] [current/] [include/] [memvar.hxx] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_MEMALLOC_MEMVAR_HXX
2
#define CYGONCE_MEMALLOC_MEMVAR_HXX
3
 
4
//==========================================================================
5
//
6
//      memvar.hxx
7
//
8
//      Memory pool with variable block class declarations
9
//
10
//==========================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later
19
// version.
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
29
//
30
// As a special exception, if other files instantiate templates or use
31
// macros or inline functions from this file, or you compile this file
32
// and link it with other works to produce a work based on this file,
33
// this file does not by itself cause the resulting work to be covered by
34
// the GNU General Public License. However the source code for this file
35
// must still be made available in accordance with section (3) of the GNU
36
// General Public License v2.
37
//
38
// This exception does not invalidate any other reasons why a work based
39
// on this file might be covered by the GNU General Public License.
40
// -------------------------------------------
41
// ####ECOSGPLCOPYRIGHTEND####
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    dsm, jlarmour
46
// Contributors:
47
// Date:         2000-06-12
48
// Purpose:      Define Memvar class interface
49
// Description:  Inline class for constructing a variable block allocator
50
// Usage:        #include 
51
//
52
//
53
//####DESCRIPTIONEND####
54
//
55
//==========================================================================
56
 
57
// CONFIGURATION
58
 
59
#include 
60
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE
61
# include 
62
# ifdef CYGPKG_KERNEL
63
#  include 
64
# endif
65
#endif
66
 
67
// when used as an implementation for malloc, we need the following
68
// to let the system know the name of the class
69
#define CYGCLS_MEMALLOC_MALLOC_IMPL Cyg_Mempool_Variable
70
 
71
// if the implementation is all that's required, don't output anything else
72
#ifndef __MALLOC_IMPL_WANTED
73
// INCLUDES
74
 
75
#include         // types
76
#include          // assertion macros
77
 
78
#ifdef CYGFUN_KERNEL_THREADS_TIMER
79
# include         // cyg_tick_count
80
#endif
81
 
82
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE
83
# include   // kernel safe mempool template
84
#endif
85
 
86
#include    // implementation of a variable mem pool
87
#include      // Common memory allocator infra
88
 
89
 
90
// TYPE DEFINITIONS
91
 
92
class Cyg_Mempool_Variable
93
{
94
protected:
95
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE
96
    Cyg_Mempolt2 mypool;
97
#else
98
    Cyg_Mempool_Variable_Implementation mypool;
99
#endif
100
 
101
public:
102
    // This API makes concrete a class which implements a thread-safe
103
    // kernel-savvy memory pool which manages variable size blocks.
104
 
105
    // Constructor: gives the base and size of the arena in which memory is
106
    // to be carved out, note that management structures are taken from the
107
    // same arena.
108
    Cyg_Mempool_Variable( cyg_uint8 * /* base */, cyg_int32  /* size */,
109
                          cyg_int32 /* alignment */=8);
110
 
111
    // Destructor
112
    ~Cyg_Mempool_Variable();
113
 
114
    // get some memory; wait if none available
115
    // if we aren't configured to be thread-aware this is irrelevant
116
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE
117
    cyg_uint8 *
118
    alloc( cyg_int32 /* size */ );
119
 
120
# ifdef CYGFUN_KERNEL_THREADS_TIMER
121
    // get some memory with a timeout
122
    cyg_uint8 *
123
    alloc( cyg_int32 /* size */, cyg_tick_count /* delay_timeout */ );
124
# endif
125
#endif
126
 
127
    // get some memory, return NULL if none available
128
    cyg_uint8 *
129
    try_alloc( cyg_int32 /* size */ );
130
 
131
    // resize existing allocation, if oldsize is non-NULL, previous
132
    // allocation size is placed into it. If previous size not available,
133
    // it is set to 0. NB previous allocation size may have been rounded up.
134
    // Occasionally the allocation can be adjusted *backwards* as well as,
135
    // or instead of forwards, therefore the address of the resized
136
    // allocation is returned, or NULL if no resizing was possible.
137
    // Note that this differs from ::realloc() in that no attempt is
138
    // made to call malloc() if resizing is not possible - that is left
139
    // to higher layers. The data is copied from old to new though.
140
    // The effects of alloc_ptr==NULL or newsize==0 are undefined
141
    cyg_uint8 *
142
    resize_alloc( cyg_uint8 * /* alloc_ptr */, cyg_int32 /* newsize */,
143
                  cyg_int32 * /* oldsize */ =NULL );
144
 
145
    // free the memory back to the pool
146
    // returns true on success
147
    cyg_bool
148
    free( cyg_uint8 * /* ptr */, cyg_int32 /* size */ =0 );
149
 
150
    // Get memory pool status
151
    // flags is a bitmask of requested fields to fill in. The flags are
152
    // defined in common.hxx
153
    void
154
    get_status( cyg_mempool_status_flag_t /* flags */,
155
                Cyg_Mempool_Status & /* status */ );
156
 
157
    CYGDBG_DEFINE_CHECK_THIS
158
};
159
 
160
#endif // ifndef __MALLOC_IMPL_WANTED
161
 
162
#endif // ifndef CYGONCE_MEMALLOC_MEMVAR_HXX
163
// EOF memvar.hxx

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.