Implements <TestMemoryManager>.
Test-MemoryManager impl | Implements <TestMemoryManager>. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file Test-MemoryManager. |
C-kern/ | Implementation file Test-MemoryManager impl. |
Types | |
struct testmm_block_t | Shortcut for testmm_block_t. |
struct testmm_page_t | Shortcut for testmm_page_t. |
testmm_it | Declares testmm_it as subtype of mm_it. |
testmm_block_t | Describes the header of an allocated memory block. |
Functions | |
alignsize_testmmblock | Aligns a value to the next multiple of KONFIG_MEMALIGN. |
testmm_page_t | Holds one big data block consisting of many vm memory pages. |
lifetime | |
testmm_t | |
static variables | |
s_testmm_interface | Contains single instance of interface testmm_it. |
helper | |
context | |
installold_testmm | Installs the previous mm_t if the current mm is of type testmm_t. |
installnew_testmm | Installs mm_t which must be of type testmm_t. |
lifetime | |
query | |
allocate | |
test |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2012 Jörg Seebohn
Header file Test-MemoryManager.
Implementation file Test-MemoryManager impl.
typedef struct testmm_block_t testmm_block_t
Shortcut for testmm_block_t.
typedef struct testmm_page_t testmm_page_t
Shortcut for testmm_page_t.
Declares testmm_it as subtype of mm_it. See mm_it_DECLARE.
struct testmm_block_t
Describes the header of an allocated memory block.
Functions | |
alignsize_testmmblock | Aligns a value to the next multiple of KONFIG_MEMALIGN. |
static inline size_t alignsize_testmmblock( size_t bytesize )
Aligns a value to the next multiple of KONFIG_MEMALIGN. If KONFIG_MEMALIGN is less than sizeof(void*) the value sizeof(void*) is chosen instead of KONFIG_MEMALIGN.
KONFIG_MEMALIGN must be a power of two for this algorithm to work.
return (bytesize + (memalign-1)) & (~(memalign-1)) ; memalign == 0b001000 (~(memalign-1)) == ~ (0b001000 - 1) == ~ (0b000111) == 0b111000
struct testmm_page_t
Holds one big data block consisting of many vm memory pages. The memory allocation strategy is simple. Memory allocation requests are always satified from the beginning of the last free block. If it is too small allocation fails. Freed blocks are only marked as freed. If a memory block marked as free is directly before the last free block it is merged with. The last free block grows in this manner until all freed blocks are merged.
static variables | |
s_testmm_interface | Contains single instance of interface testmm_it. |
helper | |
context | |
installold_testmm | Installs the previous mm_t if the current mm is of type testmm_t. |
installnew_testmm | Installs mm_t which must be of type testmm_t. |
lifetime | |
query | |
allocate | |
test |
static testmm_it s_testmm_interface
Contains single instance of interface testmm_it.
static int installnew_testmm( const mm_t * testmm )
Installs mm_t which must be of type testmm_t. The previous mm is stored in the first allocated block of testmm.
Shortcut for testmm_block_t.
typedef struct testmm_block_t testmm_block_t
Describes the header of an allocated memory block.
struct testmm_block_t
Shortcut for testmm_page_t.
typedef struct testmm_page_t testmm_page_t
Holds one big data block consisting of many vm memory pages.
struct testmm_page_t
The function table describing the interface to a memory manager.
struct mm_it
Aligns a value to the next multiple of KONFIG_MEMALIGN.
static inline size_t alignsize_testmmblock( size_t bytesize )
Contains single instance of interface testmm_it.
static testmm_it s_testmm_interface
Installs the previous mm_t if the current mm is of type testmm_t.
static int installold_testmm( /*out*/mm_t * testmm )
Installs mm_t which must be of type testmm_t.
static int installnew_testmm( const mm_t * testmm )
Implements mm_it.mm_it_DECLARE.
#define mm_it_DECLARE( declared_it, memorymanager_t ) typedef struct declared_it declared_it ; struct declared_it { int (* malloc) (memorymanager_t * mman, size_t size, /*out*/struct memblock_t * memblock) ; int (* mresize) (memorymanager_t * mman, size_t newsize, struct memblock_t * memblock) ; int (* mfree) (memorymanager_t * mman, struct memblock_t * memblock) ; size_t (* sizeallocated) (memorymanager_t * mman) ; } ;