Mercurial > ecos-v2_0-branch
comparison packages/services/memalloc/common/current/include/memfixed.hxx @ 115:6ed91473a1cd ecos-sw-2000-08-21
Merge from eCos master repository on 2000-08-21-22:40:54-BST
| author | jlarmour |
|---|---|
| date | Fri, 25 Aug 2000 17:32:38 +0000 |
| parents | |
| children | d63db767121d |
comparison
equal
deleted
inserted
replaced
| 114:5ad2b71d525e | 115:6ed91473a1cd |
|---|---|
| 1 #ifndef CYGONCE_MEMALLOC_MEMFIXED_HXX | |
| 2 #define CYGONCE_MEMALLOC_MEMFIXED_HXX | |
| 3 | |
| 4 //========================================================================== | |
| 5 // | |
| 6 // memfixed.hxx | |
| 7 // | |
| 8 // Memory pool with fixed block class declarations | |
| 9 // | |
| 10 //========================================================================== | |
| 11 //####COPYRIGHTBEGIN#### | |
| 12 // | |
| 13 // ------------------------------------------- | |
| 14 // The contents of this file are subject to the Red Hat eCos Public License | |
| 15 // Version 1.1 (the "License"); you may not use this file except in | |
| 16 // compliance with the License. You may obtain a copy of the License at | |
| 17 // http://www.redhat.com/ | |
| 18 // | |
| 19 // Software distributed under the License is distributed on an "AS IS" | |
| 20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 21 // License for the specific language governing rights and limitations under | |
| 22 // the License. | |
| 23 // | |
| 24 // The Original Code is eCos - Embedded Configurable Operating System, | |
| 25 // released September 30, 1998. | |
| 26 // | |
| 27 // The Initial Developer of the Original Code is Red Hat. | |
| 28 // Portions created by Red Hat are | |
| 29 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 30 // All Rights Reserved. | |
| 31 // ------------------------------------------- | |
| 32 // | |
| 33 //####COPYRIGHTEND#### | |
| 34 //========================================================================== | |
| 35 //#####DESCRIPTIONBEGIN#### | |
| 36 // | |
| 37 // Author(s): hmt | |
| 38 // Contributors: jlarmour | |
| 39 // Date: 2000-06-12 | |
| 40 // Purpose: Define Memfixed class interface | |
| 41 // Description: Inline class for constructing a fixed block allocator | |
| 42 // Usage: #include <cyg/memalloc/memfixed.hxx> | |
| 43 // | |
| 44 // | |
| 45 //####DESCRIPTIONEND#### | |
| 46 // | |
| 47 //========================================================================== | |
| 48 | |
| 49 // CONFIGURATION | |
| 50 | |
| 51 #include <pkgconf/memalloc.h> | |
| 52 #ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE | |
| 53 # include <pkgconf/system.h> | |
| 54 # ifdef CYGPKG_KERNEL | |
| 55 # include <pkgconf/kernel.h> | |
| 56 # endif | |
| 57 #endif | |
| 58 | |
| 59 | |
| 60 // INCLUDES | |
| 61 | |
| 62 #include <cyg/infra/cyg_type.h> // types | |
| 63 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 64 | |
| 65 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 66 # include <cyg/kernel/ktypes.h> // cyg_tick_count | |
| 67 #endif | |
| 68 | |
| 69 #ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE | |
| 70 # include <cyg/memalloc/mempolt2.hxx> // kernel safe mempool template | |
| 71 #endif | |
| 72 | |
| 73 #include <cyg/memalloc/mfiximpl.hxx> // implementation of a fixed mem pool | |
| 74 #include <cyg/memalloc/common.hxx> // Common memory allocator infra | |
| 75 | |
| 76 | |
| 77 // TYPE DEFINITIONS | |
| 78 | |
| 79 class Cyg_Mempool_Fixed | |
| 80 { | |
| 81 protected: | |
| 82 #ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE | |
| 83 Cyg_Mempolt2<Cyg_Mempool_Fixed_Implementation> mypool; | |
| 84 #else | |
| 85 Cyg_Mempool_Fixed_Implementation mypool; | |
| 86 #endif | |
| 87 | |
| 88 public: | |
| 89 // this API makes concrete a class which implements a thread-safe | |
| 90 // kernel-savvy memory pool which manages fixed size blocks. | |
| 91 | |
| 92 // Constructor: gives the base and size of the arena in which memory is | |
| 93 // to be carved out, note that management structures are taken from the | |
| 94 // same arena. Alloc_unit is the blocksize allocated. | |
| 95 Cyg_Mempool_Fixed( | |
| 96 cyg_uint8 *base, | |
| 97 cyg_int32 size, | |
| 98 CYG_ADDRWORD alloc_unit ); | |
| 99 | |
| 100 // Destructor | |
| 101 ~Cyg_Mempool_Fixed(); | |
| 102 | |
| 103 #ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE | |
| 104 // get some memory; wait if none available | |
| 105 cyg_uint8 *alloc(); | |
| 106 | |
| 107 # ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 108 // get some memory with a timeout | |
| 109 cyg_uint8 *alloc( cyg_tick_count delay_timeout ); | |
| 110 # endif | |
| 111 #endif | |
| 112 | |
| 113 // get some memory, return NULL if none available | |
| 114 cyg_uint8 *try_alloc(); | |
| 115 | |
| 116 // supposedly resize existing allocation. This is defined in the | |
| 117 // fixed block allocator purely for API consistency. It will return | |
| 118 // an error (false) for all values, except for the blocksize | |
| 119 // returns true on success | |
| 120 cyg_uint8 * | |
| 121 resize_alloc( cyg_uint8 *alloc_ptr, cyg_int32 newsize, | |
| 122 cyg_int32 *oldsize=NULL ); | |
| 123 | |
| 124 // free the memory back to the pool | |
| 125 cyg_bool free( cyg_uint8 *p ); | |
| 126 | |
| 127 // Get memory pool status | |
| 128 // flags is a bitmask of requested fields to fill in. The flags are | |
| 129 // defined in common.hxx | |
| 130 void get_status( cyg_mempool_status_flag_t /* flags */, | |
| 131 Cyg_Mempool_Status & /* status */ ); | |
| 132 | |
| 133 CYGDBG_DEFINE_CHECK_THIS | |
| 134 }; | |
| 135 | |
| 136 #endif // ifndef CYGONCE_MEMALLOC_MEMFIXED_HXX | |
| 137 // EOF memfixed.hxx |
