1 #ifndef __LWP_HEAP_INL__
2 #define __LWP_HEAP_INL__
4 static __inline__ heap_block* __lwp_heap_head(heap_cntrl *theheap)
6 return (heap_block*)&theheap->start;
9 static __inline__ heap_block* __lwp_heap_tail(heap_cntrl *heap)
11 return (heap_block*)&heap->final;
14 static __inline__ heap_block* __lwp_heap_prevblock(heap_block *block)
16 return (heap_block*)((char*)block - (block->back_flag&~HEAP_BLOCK_USED));
19 static __inline__ heap_block* __lwp_heap_nextblock(heap_block *block)
21 return (heap_block*)((char*)block + (block->front_flag&~HEAP_BLOCK_USED));
24 static __inline__ heap_block* __lwp_heap_blockat(heap_block *block,u32 offset)
26 return (heap_block*)((char*)block + offset);
29 static __inline__ heap_block* __lwp_heap_usrblockat(void *ptr)
31 u32 offset = *(((u32*)ptr)-1);
32 return __lwp_heap_blockat(ptr,-offset+-HEAP_BLOCK_USED_OVERHEAD);
35 static __inline__ bool __lwp_heap_prev_blockfree(heap_block *block)
37 return !(block->back_flag&HEAP_BLOCK_USED);
40 static __inline__ bool __lwp_heap_blockfree(heap_block *block)
42 return !(block->front_flag&HEAP_BLOCK_USED);
45 static __inline__ bool __lwp_heap_blockused(heap_block *block)
47 return (block->front_flag&HEAP_BLOCK_USED);
50 static __inline__ u32 __lwp_heap_blocksize(heap_block *block)
52 return (block->front_flag&~HEAP_BLOCK_USED);
55 static __inline__ void* __lwp_heap_startuser(heap_block *block)
57 return (void*)&block->next;
60 static __inline__ bool __lwp_heap_blockin(heap_cntrl *heap,heap_block *block)
62 return ((u32)block>=(u32)heap->start && (u32)block<=(u32)heap->final);
65 static __inline__ bool __lwp_heap_pgsize_valid(u32 pgsize)
67 return (pgsize!=0 && ((pgsize%PPC_ALIGNMENT)==0));
70 static __inline__ u32 __lwp_heap_buildflag(u32 size,u32 flag)