Changeset 578:f375bbe921b8
- Timestamp:
- 06/04/08 22:06:55 (7 months ago)
- Author:
- David Anderson <dave@…>
- Branch:
- default
- Message:
-
Make the TLSF memory allocator into a library.
- Location:
- nxos
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r425
|
r578
|
|
| 1 | | /* |
| | 1 | /* |
| 2 | 2 | * Two Levels Segregate Fit memory allocator (TLSF) |
| 3 | 3 | * Version 2.3.2 |
| … |
… |
|
| 24 | 24 | * - Add 64 bit support. It now runs on x86_64 and solaris64. |
| 25 | 25 | * - I also tested this on vxworks/32and solaris/32 and i386/32 processors. |
| 26 | | * - Remove assembly code. I could not measure any performance difference |
| | 26 | * - Remove assembly code. I could not measure any performance difference |
| 27 | 27 | * on my core2 processor. This also makes the code more portable. |
| 28 | 28 | * - Moved defines/typedefs from tlsf.h to tlsf.c |
| 29 | | * - Changed MIN_BLOCK_SIZE to sizeof (free_ptr_t) and BHDR_OVERHEAD to |
| 30 | | * (sizeof (bhdr_t) - MIN_BLOCK_SIZE). This does not change the fact |
| 31 | | * that the minumum size is still sizeof |
| | 29 | * - Changed MIN_BLOCK_SIZE to sizeof (free_ptr_t) and BHDR_OVERHEAD to |
| | 30 | * (sizeof (bhdr_t) - MIN_BLOCK_SIZE). This does not change the fact |
| | 31 | * that the minumum size is still sizeof |
| 32 | 32 | * (bhdr_t). |
| 33 | 33 | * - Changed all C++ comment style to C style. (// -> /.* ... *./) |
| 34 | | * - Used ls_bit instead of ffs and ms_bit instead of fls. I did this to |
| 35 | | * avoid confusion with the standard ffs function which returns |
| | 34 | * - Used ls_bit instead of ffs and ms_bit instead of fls. I did this to |
| | 35 | * avoid confusion with the standard ffs function which returns |
| 36 | 36 | * different values. |
| 37 | | * - Created set_bit/clear_bit fuctions because they are not present |
| | 37 | * - Created set_bit/clear_bit fuctions because they are not present |
| 38 | 38 | * on x86_64. |
| 39 | 39 | * - Added locking support + extra file target.h to show how to use it. |
| … |
… |
|
| 42 | 42 | * - Implemented realloc clever support. |
| 43 | 43 | * - Added some test code in the example directory. |
| 44 | | * |
| 45 | | * |
| 46 | | * (Oct 23 2006) Adam Scislowicz: |
| | 44 | * |
| | 45 | * |
| | 46 | * (Oct 23 2006) Adam Scislowicz: |
| 47 | 47 | * |
| 48 | 48 | * - Support for ARMv5 implemented |
| … |
… |
|
| 63 | 63 | #endif |
| 64 | 64 | |
| 65 | | #include "_tlsf.h" |
| | 65 | #include "base/lib/memalloc/_tlsf.h" |
| 66 | 66 | |
| 67 | 67 | #if !defined(__GNUC__) |
| … |
… |
|
| 404 | 404 | /******************************************************************/ |
| 405 | 405 | void *rtl_realloc(void *ptr, size_t size) { |
| 406 | | /******************************************************************/ |
| | 406 | /******************************************************************/ |
| 407 | 407 | void *ret; |
| 408 | 408 | #if TLSF_USE_LOCKS |
| … |
… |
|
| 420 | 420 | /******************************************************************/ |
| 421 | 421 | void *rtl_calloc(size_t nelem, size_t elem_size) { |
| 422 | | /******************************************************************/ |
| | 422 | /******************************************************************/ |
| 423 | 423 | void *ret; |
| 424 | 424 | #if TLSF_USE_LOCKS |
-
|
r570
|
r578
|
|
| 12 | 12 | #include "base/util.h" |
| 13 | 13 | |
| 14 | | #include "base/memalloc.h" |
| | 14 | #include "base/lib/memalloc/memalloc.h" |
| 15 | 15 | |
| 16 | 16 | /* This is really ugly and I should be taken out and shot for even doing |
| … |
… |
|
| 19 | 19 | * the calls to TLSF. |
| 20 | 20 | */ |
| 21 | | #include "base/_tlsf.h" |
| | 21 | #include "base/lib/memalloc/_tlsf.h" |
| 22 | 22 | #define printf(fmt, ...) /* Nothing, we don't printf. */ |
| 23 | | #include "base/_tlsf.c.inc" |
| | 23 | #include "base/lib/memalloc/_tlsf.c.inc" |
| 24 | 24 | |
| 25 | 25 | inline void nx_memalloc_init_full(void *mem_pool, U32 mem_pool_size) { |
-
|
r570
|
r578
|
|
| 16 | 16 | #include "base/types.h" |
| 17 | 17 | |
| 18 | | /** @addtogroup kernel */ |
| | 18 | /** @addtogroup lib */ |
| 19 | 19 | /*@{*/ |
| 20 | 20 | |
| 21 | | /** @defgroup memalloc Memory allocation |
| | 21 | /** @defgroup memalloc Memory allocator library |
| 22 | 22 | * |
| 23 | | * The NxOS baseplate optionally provides the TLSF memory allocator for |
| 24 | | * use by application kernels. The TLSF allocator performs all |
| 25 | | * allocation functions in constant (O(1)) time, and is optimized to |
| 26 | | * minimize fragmentation, making it ideal for low resource embedded |
| | 23 | * This optional library provides the TLSF memory allocator to |
| | 24 | * application kernels. The TLSF allocator performs all allocation |
| | 25 | * functions in constant (O(1)) time and is optimized to minimize |
| | 26 | * memory fragmentation, making it ideal for low resource embedded |
| 27 | 27 | * systems such as the NXT. |
| 28 | | * |
| 29 | | * No parts of the baseplate uses the allocator, so if you do not want |
| 30 | | * or need it, it will not be compiled into your application kernel. |
| 31 | 28 | * |
| 32 | 29 | * @note If you do want to use the allocator, you will first need to |
-
|
r490
|
r578
|
|
| 1 | | /* Copyright (C) 2007 the NxOS developers |
| | 1 | /* Copyright (c) 2007,2008 the NxOS developers |
| 2 | 2 | * |
| 3 | 3 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 9 | 9 | #include "base/types.h" |
| 10 | 10 | #include "base/display.h" |
| 11 | | #include "base/memalloc.h" |
| | 11 | #include "base/lib/memalloc/memalloc.h" |
| 12 | 12 | #include "base/drivers/systick.h" |
| 13 | 13 | #include "base/drivers/sound.h" |
-
|
r496
|
r578
|
|
| 1 | | /* Copyright (C) 2007 the NxOS developers |
| | 1 | /* Copyright (c) 2007,2008 the NxOS developers |
| 2 | 2 | * |
| 3 | 3 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 8 | 8 | |
| 9 | 9 | #include "base/core.h" |
| 10 | | #include "base/memalloc.h" |
| 11 | 10 | #include "base/assert.h" |
| 12 | 11 | #include "base/interrupts.h" |
| … |
… |
|
| 14 | 13 | #include "base/drivers/systick.h" |
| 15 | 14 | #include "base/drivers/avr.h" |
| | 15 | #include "base/lib/memalloc/memalloc.h" |
| 16 | 16 | |
| 17 | 17 | #include "marvin/_task.h" |
-
|
r486
|
r578
|
|
| 1 | | /* Copyright (C) 2007 the NxOS developers |
| | 1 | /* Copyright (c) 2007,2008 the NxOS developers |
| 2 | 2 | * |
| 3 | 3 | * See AUTHORS for a full list of the developers. |
| … |
… |
|
| 9 | 9 | #include "base/types.h" |
| 10 | 10 | #include "base/assert.h" |
| 11 | | #include "base/memalloc.h" |
| 12 | 11 | #include "base/display.h" |
| | 12 | #include "base/lib/memalloc/memalloc.h" |
| 13 | 13 | |
| 14 | 14 | #include "marvin/list.h" |