forked from len0rd/rockbox
Remove all tabs within codec path.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24862 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c1bb06c3af
commit
398b37124e
84 changed files with 8801 additions and 8801 deletions
|
|
@ -34,8 +34,8 @@ static inline uint64_t ByteSwap64(uint64_t x)
|
|||
#elif defined(ARCH_X86)
|
||||
static inline unsigned short ByteSwap16(unsigned short x)
|
||||
{
|
||||
__asm("xchgb %b0,%h0" :
|
||||
"=q" (x) :
|
||||
__asm("xchgb %b0,%h0" :
|
||||
"=q" (x) :
|
||||
"0" (x));
|
||||
return x;
|
||||
}
|
||||
|
|
@ -44,13 +44,13 @@ static inline unsigned short ByteSwap16(unsigned short x)
|
|||
static inline unsigned int ByteSwap32(unsigned int x)
|
||||
{
|
||||
#if __CPU__ > 386
|
||||
__asm("bswap %0":
|
||||
__asm("bswap %0":
|
||||
"=r" (x) :
|
||||
#else
|
||||
__asm("xchgb %b0,%h0\n"
|
||||
" rorl $16,%0\n"
|
||||
" xchgb %b0,%h0":
|
||||
"=q" (x) :
|
||||
__asm("xchgb %b0,%h0\n"
|
||||
" rorl $16,%0\n"
|
||||
" xchgb %b0,%h0":
|
||||
"=q" (x) :
|
||||
#endif
|
||||
"0" (x));
|
||||
return x;
|
||||
|
|
@ -61,7 +61,7 @@ static inline unsigned long long int ByteSwap64(unsigned long long int x)
|
|||
{
|
||||
register union { __extension__ uint64_t __ll;
|
||||
uint32_t __l[2]; } __x;
|
||||
asm("xchgl %0,%1":
|
||||
asm("xchgl %0,%1":
|
||||
"=r"(__x.__l[0]),"=r"(__x.__l[1]):
|
||||
"0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
|
||||
return __x.__ll;
|
||||
|
|
@ -71,17 +71,17 @@ static inline unsigned long long int ByteSwap64(unsigned long long int x)
|
|||
#elif defined(ARCH_SH4)
|
||||
|
||||
static inline uint16_t ByteSwap16(uint16_t x) {
|
||||
__asm__("swap.b %0,%0":"=r"(x):"0"(x));
|
||||
return x;
|
||||
__asm__("swap.b %0,%0":"=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
static inline uint32_t ByteSwap32(uint32_t x) {
|
||||
__asm__(
|
||||
"swap.b %0,%0\n"
|
||||
"swap.w %0,%0\n"
|
||||
"swap.b %0,%0\n"
|
||||
:"=r"(x):"0"(x));
|
||||
return x;
|
||||
__asm__(
|
||||
"swap.b %0,%0\n"
|
||||
"swap.w %0,%0\n"
|
||||
"swap.b %0,%0\n"
|
||||
:"=r"(x):"0"(x));
|
||||
return x;
|
||||
}
|
||||
|
||||
#define bswap_16(x) ByteSwap16(x)
|
||||
|
|
@ -124,9 +124,9 @@ static inline uint64_t ByteSwap64(uint64_t x)
|
|||
}
|
||||
#define bswap_64(x) ByteSwap64(x)
|
||||
|
||||
#endif /* !ARCH_X86 */
|
||||
#endif /* !ARCH_X86 */
|
||||
|
||||
#endif /* !HAVE_BYTESWAP_H */
|
||||
#endif /* !HAVE_BYTESWAP_H */
|
||||
|
||||
// be2me ... BigEndian to MachineEndian
|
||||
// le2me ... LittleEndian to MachineEndian
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ int main (void)
|
|||
//exec_time = (((double)end-(double)start)/CLOCKS_PER_SEC);
|
||||
for(j = 0; j < FFT_SIZE; j++)
|
||||
{
|
||||
printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2)));
|
||||
printf("%8.4f\n", sqrt(pow(fixtof32(z[j].re),2)+ pow(fixtof32(z[j].im), 2)));
|
||||
//getchar();
|
||||
}
|
||||
printf("muls = %d, adds = %d\n", muls, adds);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@
|
|||
#ifdef CPU_COLDFIRE
|
||||
/*
|
||||
* onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
|
||||
* fp2-fp7 for 68881.
|
||||
* fp2-fp7 for 68881.
|
||||
* All else recovered by under/over(flow) handling.
|
||||
*/
|
||||
#define _JBLEN 34
|
||||
#define _JBLEN 34
|
||||
#endif
|
||||
|
||||
#ifdef CPU_MIPS
|
||||
|
|
@ -48,9 +48,9 @@
|
|||
|
||||
#ifdef _JBLEN
|
||||
#ifdef _JBTYPE
|
||||
typedef _JBTYPE jmp_buf[_JBLEN];
|
||||
typedef _JBTYPE jmp_buf[_JBLEN];
|
||||
#else
|
||||
typedef int jmp_buf[_JBLEN];
|
||||
typedef int jmp_buf[_JBLEN];
|
||||
#endif
|
||||
#else
|
||||
typedef int jmp_buf;
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
in both interworked and non-interworked environments as well as with
|
||||
older processors which do not have the BX instruction we do the
|
||||
following:
|
||||
Test the return address.
|
||||
If the bottom bit is clear perform an "old style" function exit.
|
||||
(We know that we are in ARM mode and returning to an ARM mode caller).
|
||||
Otherwise use the BX instruction to perform the function exit.
|
||||
Test the return address.
|
||||
If the bottom bit is clear perform an "old style" function exit.
|
||||
(We know that we are in ARM mode and returning to an ARM mode caller).
|
||||
Otherwise use the BX instruction to perform the function exit.
|
||||
|
||||
We know that we will never attempt to perform the BX instruction on
|
||||
an older processor, because that kind of processor will never be
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
test the bottom bit, because this is part of the processor status.
|
||||
Instead we just do a normal return, since we know that we cannot be
|
||||
returning to a Thumb caller - the Thumb does not support APCS-26.
|
||||
|
||||
|
||||
Function entry is much simpler. If we are compiling for the Thumb we
|
||||
just switch into ARM mode and then drop through into the rest of the
|
||||
function. The function exit code will take care of the restore to
|
||||
|
|
@ -56,18 +56,18 @@
|
|||
For Thumb-2 do everything in Thumb mode. */
|
||||
|
||||
#ifdef __APCS_26__
|
||||
#define RET movs pc, lr
|
||||
#define RET movs pc, lr
|
||||
#elif defined(__thumb2__)
|
||||
#define RET bx lr
|
||||
#define RET bx lr
|
||||
#else
|
||||
#define RET tst lr, #1; \
|
||||
moveq pc, lr ; \
|
||||
.word 0xe12fff1e /* bx lr */
|
||||
#define RET tst lr, #1; \
|
||||
moveq pc, lr ; \
|
||||
.word 0xe12fff1e /* bx lr */
|
||||
#endif
|
||||
|
||||
#ifdef __thumb2__
|
||||
.macro COND where when
|
||||
i\where \when
|
||||
i\where \when
|
||||
.endm
|
||||
#else
|
||||
.macro COND where when
|
||||
|
|
@ -77,96 +77,96 @@
|
|||
#if defined(__thumb2__)
|
||||
.syntax unified
|
||||
.macro MODE
|
||||
.thumb
|
||||
.thumb_func
|
||||
.thumb
|
||||
.thumb_func
|
||||
.endm
|
||||
.macro PROLOGUE name
|
||||
.endm
|
||||
|
||||
#elif defined(__thumb__)
|
||||
#define MODE .thumb_func
|
||||
#define MODE .thumb_func
|
||||
.macro PROLOGUE name
|
||||
.code 16
|
||||
bx pc
|
||||
nop
|
||||
.code 32
|
||||
.code 16
|
||||
bx pc
|
||||
nop
|
||||
.code 32
|
||||
SYM (.arm_start_of.\name):
|
||||
.endm
|
||||
#else /* Arm */
|
||||
#define MODE .code 32
|
||||
#define MODE .code 32
|
||||
.macro PROLOGUE name
|
||||
.endm
|
||||
#endif
|
||||
|
||||
|
||||
.macro FUNC_START name
|
||||
.text
|
||||
.align 2
|
||||
MODE
|
||||
.globl SYM (\name)
|
||||
TYPE (\name)
|
||||
.text
|
||||
.align 2
|
||||
MODE
|
||||
.globl SYM (\name)
|
||||
TYPE (\name)
|
||||
SYM (\name):
|
||||
PROLOGUE \name
|
||||
PROLOGUE \name
|
||||
.endm
|
||||
|
||||
.macro FUNC_END name
|
||||
RET
|
||||
SIZE (\name)
|
||||
RET
|
||||
SIZE (\name)
|
||||
.endm
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
int setjmp (jmp_buf);
|
||||
-------------------------------------------------------------------- */
|
||||
|
||||
FUNC_START setjmp
|
||||
|
||||
FUNC_START setjmp
|
||||
|
||||
/* Save all the callee-preserved registers into the jump buffer. */
|
||||
/* Save all the callee-preserved registers into the jump buffer. */
|
||||
#ifdef __thumb2__
|
||||
stmea a1!, { v1-v7, fp, ip, lr }
|
||||
str sp, [a1],#+4
|
||||
stmea a1!, { v1-v7, fp, ip, lr }
|
||||
str sp, [a1],#+4
|
||||
#else
|
||||
stmea a1!, { v1-v7, fp, ip, sp, lr }
|
||||
stmea a1!, { v1-v7, fp, ip, sp, lr }
|
||||
#endif
|
||||
|
||||
#if 0 /* Simulator does not cope with FP instructions yet. */
|
||||
|
||||
#if 0 /* Simulator does not cope with FP instructions yet. */
|
||||
#ifndef __SOFTFP__
|
||||
/* Save the floating point registers. */
|
||||
sfmea f4, 4, [a1]
|
||||
/* Save the floating point registers. */
|
||||
sfmea f4, 4, [a1]
|
||||
#endif
|
||||
#endif
|
||||
/* When setting up the jump buffer return 0. */
|
||||
mov a1, #0
|
||||
#endif
|
||||
/* When setting up the jump buffer return 0. */
|
||||
mov a1, #0
|
||||
|
||||
FUNC_END setjmp
|
||||
|
||||
FUNC_END setjmp
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
volatile void longjmp (jmp_buf, int);
|
||||
volatile void longjmp (jmp_buf, int);
|
||||
-------------------------------------------------------------------- */
|
||||
|
||||
FUNC_START longjmp
|
||||
|
||||
FUNC_START longjmp
|
||||
|
||||
/* If we have stack extension code it ought to be handled here. */
|
||||
|
||||
/* Restore the registers, retrieving the state when setjmp() was called. */
|
||||
/* If we have stack extension code it ought to be handled here. */
|
||||
|
||||
/* Restore the registers, retrieving the state when setjmp() was called. */
|
||||
#ifdef __thumb2__
|
||||
ldmfd a1!, { v1-v7, fp, ip, lr }
|
||||
ldr sp, [a1],#+4
|
||||
ldmfd a1!, { v1-v7, fp, ip, lr }
|
||||
ldr sp, [a1],#+4
|
||||
#else
|
||||
ldmfd a1!, { v1-v7, fp, ip, sp, lr }
|
||||
ldmfd a1!, { v1-v7, fp, ip, sp, lr }
|
||||
#endif
|
||||
|
||||
#if 0 /* Simulator does not cope with FP instructions yet. */
|
||||
|
||||
#if 0 /* Simulator does not cope with FP instructions yet. */
|
||||
#ifndef __SOFTFP__
|
||||
/* Restore floating point registers as well. */
|
||||
lfmfd f4, 4, [a1]
|
||||
/* Restore floating point registers as well. */
|
||||
lfmfd f4, 4, [a1]
|
||||
#endif
|
||||
#endif
|
||||
/* Put the return value into the integer result register.
|
||||
But if it is zero then return 1 instead. */
|
||||
movs a1, a2
|
||||
#endif
|
||||
/* Put the return value into the integer result register.
|
||||
But if it is zero then return 1 instead. */
|
||||
movs a1, a2
|
||||
#ifdef __thumb2__
|
||||
it eq
|
||||
it eq
|
||||
#endif
|
||||
moveq a1, #1
|
||||
moveq a1, #1
|
||||
|
||||
FUNC_END longjmp
|
||||
FUNC_END longjmp
|
||||
|
||||
|
|
|
|||
|
|
@ -34,46 +34,46 @@
|
|||
.global SYM (longjmp)
|
||||
|
||||
SYM (setjmp):
|
||||
moveal sp@(4),a0
|
||||
movel sp@(0),a0@(12)
|
||||
movel sp,a0@(8)
|
||||
moveml d2-d7/a2-a6,a0@(20)
|
||||
clrl d0
|
||||
rts
|
||||
moveal sp@(4),a0
|
||||
movel sp@(0),a0@(12)
|
||||
movel sp,a0@(8)
|
||||
moveml d2-d7/a2-a6,a0@(20)
|
||||
clrl d0
|
||||
rts
|
||||
|
||||
SYM (longjmp):
|
||||
moveal sp@(4),a0
|
||||
movel sp@(8),d0
|
||||
bne 1f
|
||||
movel &1,d0
|
||||
moveal sp@(4),a0
|
||||
movel sp@(8),d0
|
||||
bne 1f
|
||||
movel &1,d0
|
||||
1:
|
||||
moveml a0@(20),d2-d7/a2-a6
|
||||
moveal a0@(8),sp
|
||||
movel a0@(12),sp@
|
||||
rts
|
||||
moveml a0@(20),d2-d7/a2-a6
|
||||
moveal a0@(8),sp
|
||||
movel a0@(12),sp@
|
||||
rts
|
||||
|
||||
#ifdef M68881
|
||||
.global SYM (setjmp_68881)
|
||||
.global SYM (longjmp_68881)
|
||||
|
||||
SYM (setjmp_68881):
|
||||
moveal sp@(4),a0
|
||||
movel sp@(0),a0@(12)
|
||||
movel sp,a0@(8)
|
||||
moveml d2-d7/a2-a6,a0@(20)
|
||||
fmovemx fp2-fp7,a0@(64)
|
||||
clrl d0
|
||||
rts
|
||||
moveal sp@(4),a0
|
||||
movel sp@(0),a0@(12)
|
||||
movel sp,a0@(8)
|
||||
moveml d2-d7/a2-a6,a0@(20)
|
||||
fmovemx fp2-fp7,a0@(64)
|
||||
clrl d0
|
||||
rts
|
||||
|
||||
SYM (longjmp_68881):
|
||||
moveal sp@(4),a0
|
||||
fmovemx a0@(64),fp2-fp7
|
||||
movel sp@(8),d0
|
||||
bne 1f
|
||||
movel &1,d0
|
||||
moveal sp@(4),a0
|
||||
fmovemx a0@(64),fp2-fp7
|
||||
movel sp@(8),d0
|
||||
bne 1f
|
||||
movel &1,d0
|
||||
1:
|
||||
moveml a0@(20),d2-d7/a2-a6
|
||||
moveal a0@(8),sp
|
||||
movel a0@(12),sp@
|
||||
rts
|
||||
moveml a0@(20),d2-d7/a2-a6
|
||||
moveal a0@(8),sp
|
||||
movel a0@(12),sp@
|
||||
rts
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -56,19 +56,19 @@
|
|||
#include <string.h>
|
||||
|
||||
#ifndef TLSF_USE_LOCKS
|
||||
#define TLSF_USE_LOCKS (0)
|
||||
#define TLSF_USE_LOCKS (0)
|
||||
#endif
|
||||
|
||||
#ifndef TLSF_STATISTIC
|
||||
#define TLSF_STATISTIC (0)
|
||||
#define TLSF_STATISTIC (0)
|
||||
#endif
|
||||
|
||||
#ifndef USE_MMAP
|
||||
#define USE_MMAP (0)
|
||||
#define USE_MMAP (0)
|
||||
#endif
|
||||
|
||||
#ifndef USE_SBRK
|
||||
#define USE_SBRK (0)
|
||||
#define USE_SBRK (0)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -82,18 +82,18 @@
|
|||
#endif
|
||||
|
||||
#if TLSF_STATISTIC
|
||||
#define TLSF_ADD_SIZE(tlsf, b) do { \
|
||||
tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
|
||||
if (tlsf->used_size > tlsf->max_size) \
|
||||
tlsf->max_size = tlsf->used_size; \
|
||||
} while(0)
|
||||
#define TLSF_ADD_SIZE(tlsf, b) do { \
|
||||
tlsf->used_size += (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
|
||||
if (tlsf->used_size > tlsf->max_size) \
|
||||
tlsf->max_size = tlsf->used_size; \
|
||||
} while(0)
|
||||
|
||||
#define TLSF_REMOVE_SIZE(tlsf, b) do { \
|
||||
tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
|
||||
} while(0)
|
||||
#define TLSF_REMOVE_SIZE(tlsf, b) do { \
|
||||
tlsf->used_size -= (b->size & BLOCK_SIZE) + BHDR_OVERHEAD; \
|
||||
} while(0)
|
||||
#else
|
||||
#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
|
||||
#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
|
||||
#define TLSF_ADD_SIZE(tlsf, b) do{}while(0)
|
||||
#define TLSF_REMOVE_SIZE(tlsf, b) do{}while(0)
|
||||
#endif
|
||||
|
||||
#if USE_MMAP || USE_SBRK
|
||||
|
|
@ -125,37 +125,37 @@
|
|||
/* Unlike the preview TLSF versions, now they are statics */
|
||||
#define BLOCK_ALIGN (sizeof(void *) * 2)
|
||||
|
||||
#define MAX_FLI (30)
|
||||
#define MAX_LOG2_SLI (5)
|
||||
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */
|
||||
#define MAX_FLI (30)
|
||||
#define MAX_LOG2_SLI (5)
|
||||
#define MAX_SLI (1 << MAX_LOG2_SLI) /* MAX_SLI = 2^MAX_LOG2_SLI */
|
||||
|
||||
#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
|
||||
#define FLI_OFFSET (6) /* tlsf structure just will manage blocks bigger */
|
||||
/* than 128 bytes */
|
||||
#define SMALL_BLOCK (128)
|
||||
#define REAL_FLI (MAX_FLI - FLI_OFFSET)
|
||||
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
|
||||
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
|
||||
#define TLSF_SIGNATURE (0x2A59FA59)
|
||||
#define SMALL_BLOCK (128)
|
||||
#define REAL_FLI (MAX_FLI - FLI_OFFSET)
|
||||
#define MIN_BLOCK_SIZE (sizeof (free_ptr_t))
|
||||
#define BHDR_OVERHEAD (sizeof (bhdr_t) - MIN_BLOCK_SIZE)
|
||||
#define TLSF_SIGNATURE (0x2A59FA59)
|
||||
|
||||
#define PTR_MASK (sizeof(void *) - 1)
|
||||
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)
|
||||
#define PTR_MASK (sizeof(void *) - 1)
|
||||
#define BLOCK_SIZE (0xFFFFFFFF - PTR_MASK)
|
||||
|
||||
#define GET_NEXT_BLOCK(_addr, _r) ((bhdr_t *) ((char *) (_addr) + (_r)))
|
||||
#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
|
||||
#define MEM_ALIGN ((BLOCK_ALIGN) - 1)
|
||||
#define ROUNDUP_SIZE(_r) (((_r) + MEM_ALIGN) & ~MEM_ALIGN)
|
||||
#define ROUNDDOWN_SIZE(_r) ((_r) & ~MEM_ALIGN)
|
||||
#define ROUNDUP(_x, _v) ((((~(_x)) + 1) & ((_v)-1)) + (_x))
|
||||
|
||||
#define BLOCK_STATE (0x1)
|
||||
#define PREV_STATE (0x2)
|
||||
#define BLOCK_STATE (0x1)
|
||||
#define PREV_STATE (0x2)
|
||||
|
||||
/* bit 0 of the block size */
|
||||
#define FREE_BLOCK (0x1)
|
||||
#define USED_BLOCK (0x0)
|
||||
#define FREE_BLOCK (0x1)
|
||||
#define USED_BLOCK (0x0)
|
||||
|
||||
/* bit 1 of the block size */
|
||||
#define PREV_FREE (0x2)
|
||||
#define PREV_USED (0x0)
|
||||
#define PREV_FREE (0x2)
|
||||
#define PREV_USED (0x0)
|
||||
|
||||
|
||||
#define DEFAULT_AREA_SIZE (1024*10)
|
||||
|
|
@ -352,46 +352,46 @@ static __inline__ bhdr_t *FIND_SUITABLE_BLOCK(tlsf_t * _tlsf, int *_fl, int *_sl
|
|||
}
|
||||
|
||||
|
||||
#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
|
||||
_tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
|
||||
if (_tlsf -> matrix[_fl][_sl]) \
|
||||
_tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
|
||||
else { \
|
||||
clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
|
||||
if (!_tlsf -> sl_bitmap [_fl]) \
|
||||
clear_bit (_fl, &_tlsf -> fl_bitmap); \
|
||||
} \
|
||||
_b -> ptr.free_ptr.prev = NULL; \
|
||||
_b -> ptr.free_ptr.next = NULL; \
|
||||
}while(0)
|
||||
#define EXTRACT_BLOCK_HDR(_b, _tlsf, _fl, _sl) do { \
|
||||
_tlsf -> matrix [_fl] [_sl] = _b -> ptr.free_ptr.next; \
|
||||
if (_tlsf -> matrix[_fl][_sl]) \
|
||||
_tlsf -> matrix[_fl][_sl] -> ptr.free_ptr.prev = NULL; \
|
||||
else { \
|
||||
clear_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
|
||||
if (!_tlsf -> sl_bitmap [_fl]) \
|
||||
clear_bit (_fl, &_tlsf -> fl_bitmap); \
|
||||
} \
|
||||
_b -> ptr.free_ptr.prev = NULL; \
|
||||
_b -> ptr.free_ptr.next = NULL; \
|
||||
}while(0)
|
||||
|
||||
|
||||
#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
|
||||
if (_b -> ptr.free_ptr.next) \
|
||||
_b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
|
||||
if (_b -> ptr.free_ptr.prev) \
|
||||
_b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
|
||||
if (_tlsf -> matrix [_fl][_sl] == _b) { \
|
||||
_tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
|
||||
if (!_tlsf -> matrix [_fl][_sl]) { \
|
||||
clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
|
||||
if (!_tlsf -> sl_bitmap [_fl]) \
|
||||
clear_bit (_fl, &_tlsf -> fl_bitmap); \
|
||||
} \
|
||||
} \
|
||||
_b -> ptr.free_ptr.prev = NULL; \
|
||||
_b -> ptr.free_ptr.next = NULL; \
|
||||
} while(0)
|
||||
#define EXTRACT_BLOCK(_b, _tlsf, _fl, _sl) do { \
|
||||
if (_b -> ptr.free_ptr.next) \
|
||||
_b -> ptr.free_ptr.next -> ptr.free_ptr.prev = _b -> ptr.free_ptr.prev; \
|
||||
if (_b -> ptr.free_ptr.prev) \
|
||||
_b -> ptr.free_ptr.prev -> ptr.free_ptr.next = _b -> ptr.free_ptr.next; \
|
||||
if (_tlsf -> matrix [_fl][_sl] == _b) { \
|
||||
_tlsf -> matrix [_fl][_sl] = _b -> ptr.free_ptr.next; \
|
||||
if (!_tlsf -> matrix [_fl][_sl]) { \
|
||||
clear_bit (_sl, &_tlsf -> sl_bitmap[_fl]); \
|
||||
if (!_tlsf -> sl_bitmap [_fl]) \
|
||||
clear_bit (_fl, &_tlsf -> fl_bitmap); \
|
||||
} \
|
||||
} \
|
||||
_b -> ptr.free_ptr.prev = NULL; \
|
||||
_b -> ptr.free_ptr.next = NULL; \
|
||||
} while(0)
|
||||
|
||||
#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
|
||||
_b -> ptr.free_ptr.prev = NULL; \
|
||||
_b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
|
||||
if (_tlsf -> matrix [_fl][_sl]) \
|
||||
_tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
|
||||
_tlsf -> matrix [_fl][_sl] = _b; \
|
||||
set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
|
||||
set_bit (_fl, &_tlsf -> fl_bitmap); \
|
||||
} while(0)
|
||||
#define INSERT_BLOCK(_b, _tlsf, _fl, _sl) do { \
|
||||
_b -> ptr.free_ptr.prev = NULL; \
|
||||
_b -> ptr.free_ptr.next = _tlsf -> matrix [_fl][_sl]; \
|
||||
if (_tlsf -> matrix [_fl][_sl]) \
|
||||
_tlsf -> matrix [_fl][_sl] -> ptr.free_ptr.prev = _b; \
|
||||
_tlsf -> matrix [_fl][_sl] = _b; \
|
||||
set_bit (_sl, &_tlsf -> sl_bitmap [_fl]); \
|
||||
set_bit (_fl, &_tlsf -> fl_bitmap); \
|
||||
} while(0)
|
||||
|
||||
#if USE_SBRK || USE_MMAP
|
||||
static __inline__ void *get_new_area(size_t * size)
|
||||
|
|
@ -656,9 +656,9 @@ void *tlsf_realloc(void *ptr, size_t size)
|
|||
void *ret;
|
||||
|
||||
#if USE_MMAP || USE_SBRK
|
||||
if (!mp) {
|
||||
return tlsf_malloc(size);
|
||||
}
|
||||
if (!mp) {
|
||||
return tlsf_malloc(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
TLSF_ACQUIRE_LOCK(&((tlsf_t *)mp)->lock);
|
||||
|
|
@ -813,7 +813,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
|
|||
new_size = (new_size < MIN_BLOCK_SIZE) ? MIN_BLOCK_SIZE : ROUNDUP_SIZE(new_size);
|
||||
tmp_size = (b->size & BLOCK_SIZE);
|
||||
if (new_size <= tmp_size) {
|
||||
TLSF_REMOVE_SIZE(tlsf, b);
|
||||
TLSF_REMOVE_SIZE(tlsf, b);
|
||||
if (next_b->size & FREE_BLOCK) {
|
||||
MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
|
||||
EXTRACT_BLOCK(next_b, tlsf, fl, sl);
|
||||
|
|
@ -833,12 +833,12 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
|
|||
INSERT_BLOCK(tmp_b, tlsf, fl, sl);
|
||||
b->size = new_size | (b->size & PREV_STATE);
|
||||
}
|
||||
TLSF_ADD_SIZE(tlsf, b);
|
||||
TLSF_ADD_SIZE(tlsf, b);
|
||||
return (void *) b->ptr.buffer;
|
||||
}
|
||||
if ((next_b->size & FREE_BLOCK)) {
|
||||
if (new_size <= (tmp_size + (next_b->size & BLOCK_SIZE))) {
|
||||
TLSF_REMOVE_SIZE(tlsf, b);
|
||||
TLSF_REMOVE_SIZE(tlsf, b);
|
||||
MAPPING_INSERT(next_b->size & BLOCK_SIZE, &fl, &sl);
|
||||
EXTRACT_BLOCK(next_b, tlsf, fl, sl);
|
||||
b->size += (next_b->size & BLOCK_SIZE) + BHDR_OVERHEAD;
|
||||
|
|
@ -856,7 +856,7 @@ void *realloc_ex(void *ptr, size_t new_size, void *mem_pool)
|
|||
INSERT_BLOCK(tmp_b, tlsf, fl, sl);
|
||||
b->size = new_size | (b->size & PREV_STATE);
|
||||
}
|
||||
TLSF_ADD_SIZE(tlsf, b);
|
||||
TLSF_ADD_SIZE(tlsf, b);
|
||||
return (void *) b->ptr.buffer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue