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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_MEMALLOC_MEMJOIN_HXX
2
#define CYGONCE_MEMALLOC_MEMJOIN_HXX
3
 
4
//==========================================================================
5
//
6
//      memjoin.hxx
7
//
8
//      Pseudo memory pool used to join together other memory pools
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):    jlarmour
46
// Contributors:
47
// Date:         2000-06-12
48
// Purpose:      Define joined up memory pool class interface
49
// Description:  Inline class for constructing a pseudo allocator that contains
50
//               multiple other allocators. It caters solely to the requirements
51
//               of the malloc implementation.
52
// Usage:        #include 
53
//
54
//
55
//####DESCRIPTIONEND####
56
//
57
//==========================================================================
58
 
59
// CONFIGURATION
60
 
61
#include 
62
 
63
// INCLUDES
64
 
65
#include         // types
66
//#include          // assertion macros
67
 
68
#include      // Common memory allocator infra
69
 
70
 
71
// TYPE DEFINITIONS
72
 
73
template 
74
class Cyg_Mempool_Joined
75
{
76
protected:
77
    struct pooldesc {
78
        const cyg_uint8 *startaddr;
79
        const cyg_uint8 *endaddr;
80
        T *pool;
81
    };
82
    struct pooldesc *pools;
83
    cyg_uint8 poolcount;
84
 
85
    T *
86
    find_pool_for_ptr( const cyg_uint8 * /* ptr */ );
87
 
88
public:
89
    // Constructor
90
    Cyg_Mempool_Joined( cyg_uint8 /* num_heaps */, T * /* heaps */[] );
91
 
92
    // Destructor
93
    ~Cyg_Mempool_Joined();
94
 
95
    // get some memory, return NULL if none available
96
    cyg_uint8 *
97
    try_alloc( cyg_int32 /* size */ );
98
 
99
    // resize existing allocation, if oldsize is non-NULL, previous
100
    // allocation size is placed into it. If previous size not available,
101
    // it is set to 0. NB previous allocation size may have been rounded up.
102
    // Occasionally the allocation can be adjusted *backwards* as well as,
103
    // or instead of forwards, therefore the address of the resized
104
    // allocation is returned, or NULL if no resizing was possible.
105
    // Note that this differs from ::realloc() in that no attempt is
106
    // made to call malloc() if resizing is not possible - that is left
107
    // to higher layers. The data is copied from old to new though.
108
    // The effects of alloc_ptr==NULL or newsize==0 are undefined
109
    cyg_uint8 *
110
    resize_alloc( cyg_uint8 * /* alloc_ptr */, cyg_int32 /* newsize */,
111
                  cyg_int32 * /* oldsize */ =NULL );
112
 
113
    // free the memory back to the pool
114
    // returns true on success
115
    cyg_bool
116
    free( cyg_uint8 * /* ptr */, cyg_int32 /* size */ =0 );
117
 
118
    // Get memory pool status
119
    // flags is a bitmask of requested fields to fill in. The flags are
120
    // defined in common.hxx
121
    void
122
    get_status( cyg_mempool_status_flag_t /* flags */,
123
                Cyg_Mempool_Status & /* status */ );
124
 
125
};
126
 
127
#include 
128
 
129
#endif // ifndef CYGONCE_MEMALLOC_MEMJOIN_HXX
130
// EOF memjoin.hxx

powered by: WebSVN 2.1.0

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