Changeset 578:f375bbe921b8

Show
Ignore:
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:
3 modified
4 moved

Legend:

Unmodified
Added
Removed
  • nxos/base/lib/memalloc/_tlsf.c.inc

    r425 r578  
    1 /*  
     1/* 
    22 * Two Levels Segregate Fit memory allocator (TLSF) 
    33 * Version 2.3.2 
     
    2424 * - Add 64 bit support. It now runs on x86_64 and solaris64. 
    2525 * - 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 
    2727 *   on my core2 processor. This also makes the code more portable. 
    2828 * - 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 
    3232 *   (bhdr_t). 
    3333 * - 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 
    3636 *   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 
    3838 *   on x86_64. 
    3939 * - Added locking support + extra file target.h to show how to use it. 
     
    4242 * - Implemented realloc clever support. 
    4343 * - Added some test code in the example directory. 
    44  *         
    45  * 
    46  * (Oct 23 2006) Adam Scislowicz:  
     44 * 
     45 * 
     46 * (Oct 23 2006) Adam Scislowicz: 
    4747 * 
    4848 * - Support for ARMv5 implemented 
     
    6363#endif 
    6464 
    65 #include "_tlsf.h" 
     65#include "base/lib/memalloc/_tlsf.h" 
    6666 
    6767#if !defined(__GNUC__) 
     
    404404/******************************************************************/ 
    405405void *rtl_realloc(void *ptr, size_t size) { 
    406 /******************************************************************/    
     406/******************************************************************/ 
    407407    void *ret; 
    408408#if TLSF_USE_LOCKS 
     
    420420/******************************************************************/ 
    421421void *rtl_calloc(size_t nelem, size_t elem_size) { 
    422 /******************************************************************/    
     422/******************************************************************/ 
    423423    void *ret; 
    424424#if TLSF_USE_LOCKS 
  • nxos/base/lib/memalloc/memalloc.c

    r570 r578  
    1212#include "base/util.h" 
    1313 
    14 #include "base/memalloc.h" 
     14#include "base/lib/memalloc/memalloc.h" 
    1515 
    1616/* This is really ugly and I should be taken out and shot for even doing 
     
    1919 * the calls to TLSF. 
    2020 */ 
    21 #include "base/_tlsf.h" 
     21#include "base/lib/memalloc/_tlsf.h" 
    2222#define printf(fmt, ...) /* Nothing, we don't printf. */ 
    23 #include "base/_tlsf.c.inc" 
     23#include "base/lib/memalloc/_tlsf.c.inc" 
    2424 
    2525inline void nx_memalloc_init_full(void *mem_pool, U32 mem_pool_size) { 
  • nxos/base/lib/memalloc/memalloc.h

    r570 r578  
    1616#include "base/types.h" 
    1717 
    18 /** @addtogroup kernel */ 
     18/** @addtogroup lib */ 
    1919/*@{*/ 
    2020 
    21 /** @defgroup memalloc Memory allocation 
     21/** @defgroup memalloc Memory allocator library 
    2222 * 
    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 
    2727 * 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. 
    3128 * 
    3229 * @note If you do want to use the allocator, you will first need to 
  • nxos/systems/marvin/main.c

    r490 r578  
    1 /* Copyright (C) 2007 the NxOS developers 
     1/* Copyright (c) 2007,2008 the NxOS developers 
    22 * 
    33 * See AUTHORS for a full list of the developers. 
     
    99#include "base/types.h" 
    1010#include "base/display.h" 
    11 #include "base/memalloc.h" 
     11#include "base/lib/memalloc/memalloc.h" 
    1212#include "base/drivers/systick.h" 
    1313#include "base/drivers/sound.h" 
  • nxos/systems/marvin/scheduler.c

    r496 r578  
    1 /* Copyright (C) 2007 the NxOS developers 
     1/* Copyright (c) 2007,2008 the NxOS developers 
    22 * 
    33 * See AUTHORS for a full list of the developers. 
     
    88 
    99#include "base/core.h" 
    10 #include "base/memalloc.h" 
    1110#include "base/assert.h" 
    1211#include "base/interrupts.h" 
     
    1413#include "base/drivers/systick.h" 
    1514#include "base/drivers/avr.h" 
     15#include "base/lib/memalloc/memalloc.h" 
    1616 
    1717#include "marvin/_task.h" 
  • nxos/systems/marvin/semaphore.c

    r486 r578  
    1 /* Copyright (C) 2007 the NxOS developers 
     1/* Copyright (c) 2007,2008 the NxOS developers 
    22 * 
    33 * See AUTHORS for a full list of the developers. 
     
    99#include "base/types.h" 
    1010#include "base/assert.h" 
    11 #include "base/memalloc.h" 
    1211#include "base/display.h" 
     12#include "base/lib/memalloc/memalloc.h" 
    1313 
    1414#include "marvin/list.h"