mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Make PDBox use the copy of TLSF in the codecs folder (and remove the old copy).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22802 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
073e2062da
commit
b11a7fde08
10 changed files with 2 additions and 1376 deletions
|
@ -3,7 +3,6 @@ pdbox-net.c
|
|||
pdbox-func.c
|
||||
pdbox-gui.c
|
||||
|
||||
TLSF-2.4.4/src/tlsf.c
|
||||
/*
|
||||
wfirstfit.c
|
||||
*/
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
LICENSE INFORMATION
|
||||
|
||||
TLSF is released as LGPL and GPL. A copy of both licences can be found in this
|
||||
directoy. For the GPL licence, the following exception applies.
|
||||
|
||||
|
||||
TLSF is free software; you can redistribute it and/or modify it under terms of
|
||||
the GNU General Public License as published by the Free Software Foundation;
|
||||
either version 2, or (at your option) any later version. TLSF 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. You should have received a
|
||||
copy of the GNU General Public License along with TLSF; see file COPYING. If
|
||||
not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
|
||||
USA.
|
||||
|
||||
As a special exception, including TLSF header files in a file, or linking with
|
||||
other files objects to produce an executable application, is merely considered
|
||||
normal use of the library, and does *not* fall under the heading of "derived
|
||||
work". Therfore does not by itself cause the resulting executable application
|
||||
to be covered by the GNU General Public License. This exception does not
|
||||
however invalidate any other reasons why the executable file might be covered
|
||||
by the GNU Public License.
|
|
@ -1,119 +0,0 @@
|
|||
Version History
|
||||
---------------
|
||||
-v2.4.4 (October 13 2008)
|
||||
* Corrected minor syntactic bug on statistic gathering code.
|
||||
Reported by Tim Cussins and P. Mantegazza.
|
||||
|
||||
-v2.4.3 (July 30 2008)
|
||||
* Minor fixes to compile with the greenhills compiler.
|
||||
Reported by "Kaya, Sinan SEA" <sinan.kaya@siemens.com>
|
||||
* Small change in the license in order to include TLSF in the RTEMS
|
||||
project.
|
||||
|
||||
-v2.4.2 (May 16 2008) (Herman ten Brugge)
|
||||
* Memory usage statistics added again, with cleaner and more compacted
|
||||
code.
|
||||
|
||||
-v2.4.1 (April 30 2008)
|
||||
* Fixed a bug in the tlsf_realloc function: init the pool automatically
|
||||
on the first call.
|
||||
Reported by: Alejandro Mery <amery@geeks.cl>
|
||||
|
||||
-v2.4 (Feb 19 2008)
|
||||
* "rtl_*" functions renamed to "tlsf_*".
|
||||
* Added the add_new_area function to insert new memory areas to an
|
||||
existing memory pool.
|
||||
* A single TLSF pool can manage non-contiguous memory areas.
|
||||
* Support for mmap and sbrk added.
|
||||
* The init_memory_pool is not longer needed when used on a system
|
||||
with mmap or sbrk.
|
||||
* Removed the get_used_size counting.The same functionality can be
|
||||
implemented outside the TLSF code.
|
||||
|
||||
-v2.3.2 (Sep 27 2007)
|
||||
* Minor cosmetic code improvements.
|
||||
|
||||
-v2.3.1 (Jul 30 2007)
|
||||
* Fixed some minor bugs in the version 2.3. Herman ten Brugge
|
||||
<hermantenbrugge@home.nl>
|
||||
|
||||
-v2.3 (Jul 28 2007) Released a new version with all the contributions
|
||||
received from Herman ten Brugge <hermantenbrugge@home.nl>
|
||||
(This is his summary of changes in the TLSF's code):
|
||||
* Add 64 bit support. It now runs on x86_64 and solaris64.
|
||||
* I also tested this on vxworks/32 and solaris/32 and i386/32
|
||||
processors.
|
||||
* Remove assembly code. I could not measure any performance difference
|
||||
on my core2 processor. This also makes the code more portable.
|
||||
* Moved defines/typedefs from tlsf.h to tlsf.c
|
||||
* Changed MIN_BLOCK_SIZE to sizeof (free_ptr_t) and BHDR_OVERHEAD to
|
||||
(sizeof (bhdr_t) - MIN_BLOCK_SIZE). This does not change the fact
|
||||
that the minumum size is still sizeof (bhdr_t).
|
||||
* Changed all C++ comment style to C style. (// -> /* ... *./)
|
||||
* Used ls_bit instead of ffs and ms_bit instead of fls. I did this to
|
||||
avoid confusion with the standard ffs function which returns
|
||||
different values.
|
||||
* Created set_bit/clear_bit fuctions because they are not present
|
||||
on x86_64.
|
||||
* Added locking support + extra file target.h to show how to use it.
|
||||
* Added get_used_size function
|
||||
* Added rtl_realloc and rtl_calloc function
|
||||
* Implemented realloc clever support.
|
||||
* Added some test code in the example directory.
|
||||
|
||||
-- Thank you very much for your help Herman!
|
||||
|
||||
-v2.2.1 (Oct 23 2006)
|
||||
* Support for ARMv5 implemented by Adam Scislowicz
|
||||
<proteuskor@gmail.com>. Thank you for your contribution.
|
||||
|
||||
- v2.2.0 (Jun 30 2006) Miguel Masmano & Ismael Ripoll.
|
||||
|
||||
* Blocks smaller than 128 bytes are stored on a single
|
||||
segregated list. The already existing bits maps and data
|
||||
structures are used.
|
||||
* Minor code speed-up improvements.
|
||||
* Worst case response time both on malloc and free improved.
|
||||
* External fragmantation also improved!.
|
||||
* Segragared lists are AGAIN sorted by LIFO order. Version
|
||||
2.1b was proven to be no better than 2.1.
|
||||
|
||||
- v2.1b: Allocation policy has been always a LIFO Good-Fit, that
|
||||
is, between several free blocks in the same range, TLSF will
|
||||
always allocate the most recently released. In this version of
|
||||
TLSF, we have implemented a FIFO Good-Fit. However,
|
||||
fragmentation doesn't seems to be altered so is it worth it?.
|
||||
|
||||
- v2.1: Realloc and calloc included again in TLSF 2.0.
|
||||
|
||||
- v2.0: In this version, TLSF has been programmed from scratch.
|
||||
Now the allocator is provided as an unique file. Realloc and
|
||||
calloc are not longer implemented.
|
||||
|
||||
|
||||
- v1.4: Created the section "Version History". Studied real
|
||||
behaviour of actual applications (regular applications tend
|
||||
to require small memory blocks (less than 16 bytes) whereas
|
||||
TLSF is optimised to be used with blocks larger than 16
|
||||
bytes: Added special lists to deal with blocks smaller than
|
||||
16 bytes.
|
||||
|
||||
|
||||
- v1.3: Change of concept, now the main TLSF structure is created
|
||||
inside of the beginning of the block instead of being an
|
||||
static structure, allowing multiple TLSFs working at the
|
||||
same time. Now, TLSF uses specific processor instructions to
|
||||
deal with bitmaps. TLSF sanity functions added to find TLSF
|
||||
overflows. The TLSF code will not be RTLinux-oriented any
|
||||
more.
|
||||
|
||||
- v1.1 ... v1.2: Many little bugs fixed, code cleaned and splitted
|
||||
in several files because of cosmetic requirements.
|
||||
Starting from TLSF v1.1, MaRTE OS
|
||||
(http://marte.unican.es) uses the TLSF allocator
|
||||
as its default memory allocator.
|
||||
|
||||
- v0.1 ... v1.0: First implementations were created for testing and
|
||||
research purposes. Basically TLSF is implemented to
|
||||
be used by RTLinux-GPL (www.rtlinux-gpl.org), so
|
||||
it is RTLinux-oriented.
|
|
@ -1,163 +0,0 @@
|
|||
|
||||
TLSF Memory Storage allocator implementation.
|
||||
Version 2.4 Feb 2008
|
||||
|
||||
Authors: Miguel Masmano, Ismael Ripoll & Alfons Crespo.
|
||||
Copyright UPVLC, OCERA Consortium.
|
||||
|
||||
TLSF is released in the GPL/LGPL licence. The exact terms of the licence
|
||||
are described in the COPYING file.
|
||||
|
||||
This component provides basic memory allocation functions:
|
||||
malloc and free, as defined in the standard "C" library.
|
||||
|
||||
This allocator was designed to provide real-time performance, that is:
|
||||
1.- Bounded time malloc and free.
|
||||
2.- Fast response time.
|
||||
3.- Efficient memory management, that is low fragmentation.
|
||||
|
||||
|
||||
The worst response time for both malloc and free is O(1).
|
||||
|
||||
|
||||
|
||||
How to use it:
|
||||
|
||||
This code is prepared to be used as a stand-alone code that can be
|
||||
linked with a regular application or it can be compiled to be a Linux
|
||||
module (which required the BigPhysicalArea patch). Initially the
|
||||
module was designed to work jointly with RTLinux-GPL, but it can be
|
||||
used as a stand alone Linux module.
|
||||
|
||||
When compiled as a regular linux process the API is:
|
||||
|
||||
Initialisation and destruction functions
|
||||
----------------------------------------
|
||||
|
||||
init_memory_pool may be called before any request or release call:
|
||||
|
||||
- size_t init_memory_pool(size_t, void *);
|
||||
- void destroy_memory_pool(void *);
|
||||
|
||||
Request and release functions
|
||||
-----------------------------
|
||||
|
||||
As can be seen, there are two functions for each traditional memory
|
||||
allocation function (malloc, free, realloc, and calloc). One with the
|
||||
prefix "tlsf_" and the other with the suffix "_ex".
|
||||
|
||||
The versions with the prefix "tlsf_" provides the expected behaviour,
|
||||
that is, allocating/releasing memory from the default memory pool. The
|
||||
default memory pool is the last pool initialised by the
|
||||
init_memory_pool function.
|
||||
|
||||
On the other hand, the functions with the prefix "_ex" enable the use of several memory pools.
|
||||
|
||||
- void *tlsf_malloc(size_t);
|
||||
- void *malloc_ex(size_t, void *);
|
||||
|
||||
- void tlsf_free(void *ptr);
|
||||
- void free_ex(void *, void *);
|
||||
|
||||
- void *tlsf_realloc(void *ptr, size_t size);
|
||||
- void *realloc_ex(void *, size_t, void *);
|
||||
|
||||
- void *tlsf_calloc(size_t nelem, size_t elem_size);
|
||||
- void *calloc_ex(size_t, size_t, void *);
|
||||
|
||||
EXAMPLE OF USE:
|
||||
|
||||
char memory_pool[1024*1024];
|
||||
|
||||
{
|
||||
...
|
||||
|
||||
init_memory_pool(1024*1024, memory_pool);
|
||||
|
||||
...
|
||||
|
||||
ptr1=malloc_ex(100, memory_pool);
|
||||
ptr2=tlsf_malloc(100); // This function will use memory_pool
|
||||
|
||||
...
|
||||
|
||||
tlsf_free(ptr2);
|
||||
free_ex(ptr1, memory_pool);
|
||||
}
|
||||
|
||||
Growing the memory pool
|
||||
-----------------------
|
||||
|
||||
Starting from the version 2.4, the function add_new_area adds an
|
||||
memory area to an existing memory pool.
|
||||
|
||||
- size_t add_new_area(void *, size_t, void *);
|
||||
|
||||
This feature is pretty useful when an existing memory pool is running
|
||||
low and we want to add more free memory to it.
|
||||
EXAMPLE OF USE:
|
||||
|
||||
char memory_pool[1024*1024];
|
||||
char memory_pool2[1024*1024];
|
||||
|
||||
{
|
||||
...
|
||||
|
||||
init_memory_pool(1024*1024, memory_pool);
|
||||
|
||||
...
|
||||
|
||||
ptr[0]=malloc_ex(1024*256 memory_pool);
|
||||
ptr[1]=malloc_ex(1024*512, memory_pool);
|
||||
add_new_area(memory_pool2, 1024*1024, memory_pool);
|
||||
// Now we have an extra free memory area of 1Mb
|
||||
// The next malloc may not fail
|
||||
ptr[2]=malloc_ex(1024*512, memory_pool);
|
||||
|
||||
...
|
||||
|
||||
}
|
||||
|
||||
|
||||
SBRK and MMAP support
|
||||
---------------------
|
||||
|
||||
The version 2.4 can use the functions SBRK and MMAP to _automatically_
|
||||
growing the memory pool, before running out of memory.
|
||||
|
||||
So, when this feature is enabled, unless the operating system were out
|
||||
of memory, a malloc operation would not fail due to an "out-of-memory"
|
||||
error.
|
||||
|
||||
To enable this support, compile tlsf.c with the FLAGS -DUSE_MMAP=1 or
|
||||
-DUSE_SBRK=1 depending on whether you want to use "mmap" or "sbrk" or both.
|
||||
|
||||
** By default (default Makefile) this feature is enabled.
|
||||
|
||||
EXAMPLE OF USE:
|
||||
|
||||
gcc -o tlsf.o -O2 -Wall -DUSE_MMAP=1 -DUSE_SBRK=1
|
||||
|
||||
---
|
||||
|
||||
If the sbrk/mmap support is enabled and we are _only_ going to use one
|
||||
memory pool, it is not necessary to call init_memory_pool
|
||||
|
||||
EXAMPLE OF USE (with MMAP/SBRK support enabled):
|
||||
|
||||
{
|
||||
...
|
||||
|
||||
ptr2=tlsf_malloc(100); // This function will use memory_pool
|
||||
|
||||
...
|
||||
|
||||
tlsf_free(ptr2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
This work has been supported by the followin projects:
|
||||
EUROPEAN: IST-2001-35102(OCERA) http://www.ocera.org.
|
||||
SPANISH: TIN2005-08665-C3-03
|
|
@ -1,9 +0,0 @@
|
|||
To do list
|
||||
==========
|
||||
|
||||
* Add mmap/sbrk support (DONE - V2.4).
|
||||
|
||||
* TLSF rounds-up request size to the head of a free list.
|
||||
It has been shown to be a good policy for small blocks (<2048).
|
||||
But for larger blocks this policy may cause excesive fragmentation.
|
||||
A deeper analisys should be done.
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef _TARGET_H_
|
||||
#define _TARGET_H_
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define TLSF_MLOCK_T pthread_mutex_t
|
||||
#define TLSF_CREATE_LOCK(l) pthread_mutex_init (l, NULL)
|
||||
#define TLSF_DESTROY_LOCK(l) pthread_mutex_destroy(l)
|
||||
#define TLSF_ACQUIRE_LOCK(l) pthread_mutex_lock(l)
|
||||
#define TLSF_RELEASE_LOCK(l) pthread_mutex_unlock(l)
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load diff
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Two Levels Segregate Fit memory allocator (TLSF)
|
||||
* Version 2.4.4
|
||||
*
|
||||
* Written by Miguel Masmano Tello <mimastel@doctor.upv.es>
|
||||
*
|
||||
* Thanks to Ismael Ripoll for his suggestions and reviews
|
||||
*
|
||||
* Copyright (C) 2008, 2007, 2006, 2005, 2004
|
||||
*
|
||||
* This code is released using a dual license strategy: GPL/LGPL
|
||||
* You can choose the licence that better fits your requirements.
|
||||
*
|
||||
* Released under the terms of the GNU General Public License Version 2.0
|
||||
* Released under the terms of the GNU Lesser General Public License Version 2.1
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TLSF_H_
|
||||
#define _TLSF_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
extern size_t init_memory_pool(size_t, void *);
|
||||
extern size_t get_used_size(void *);
|
||||
extern size_t get_max_size(void *);
|
||||
extern void destroy_memory_pool(void *);
|
||||
extern size_t add_new_area(void *, size_t, void *);
|
||||
extern void *malloc_ex(size_t, void *);
|
||||
extern void free_ex(void *, void *);
|
||||
extern void *realloc_ex(void *, size_t, void *);
|
||||
extern void *calloc_ex(size_t, size_t, void *);
|
||||
|
||||
extern void *tlsf_malloc(size_t size);
|
||||
extern void tlsf_free(void *ptr);
|
||||
extern void *tlsf_realloc(void *ptr, size_t size);
|
||||
extern void *tlsf_calloc(size_t nelem, size_t elem_size);
|
||||
|
||||
#endif
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#if 1
|
||||
/* Use TLSF. */
|
||||
#include "tlsf.h"
|
||||
#include "codecs/lib/tlsf/src/tlsf.h"
|
||||
#endif
|
||||
|
||||
/* Pure Data */
|
||||
|
|
|
@ -18,7 +18,7 @@ PDBOX_OBJ := $(call c2obj, $(PDBOX_SRC))
|
|||
# add source files to OTHERSRC to get automatic dependencies
|
||||
OTHERSRC += $(PDBOX_SRC)
|
||||
|
||||
$(PDBOXBUILDDIR)/pdbox.rock: $(PDBOX_OBJ)
|
||||
$(PDBOXBUILDDIR)/pdbox.rock: $(PDBOX_OBJ) $(MPEG_OBJ) $(CODECDIR)/libtlsf.a
|
||||
|
||||
PDBOXFLAGS = $(PLUGINFLAGS) \
|
||||
-DFIXEDPOINT -DSTATIC -DPD -DUSEAPI_ROCKBOX \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue