X-Git-Url: http://git.onelab.eu/?p=linux-2.6.git;a=blobdiff_plain;f=arch%2Fpowerpc%2Flib%2Frheap.c;fp=arch%2Fpowerpc%2Flib%2Frheap.c;h=57bf991ccd6e11751cf4b37c5f4548ac83e55aba;hp=42c5de2c898f28aaae69db9b370f3db0899ec8ef;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hpb=76828883507a47dae78837ab5dec5a5b4513c667 diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c index 42c5de2c8..57bf991cc 100644 --- a/arch/powerpc/lib/rheap.c +++ b/arch/powerpc/lib/rheap.c @@ -1,6 +1,4 @@ /* - * arch/ppc/syslib/rheap.c - * * A Remote Heap. Remote means that we don't touch the memory that the * heap points to. Normal heap implementations use the memory they manage * to place their list. We cannot do that because the memory we manage may @@ -425,17 +423,21 @@ void *rh_detach_region(rh_info_t * info, void *start, int size) return (void *)s; } -void *rh_alloc(rh_info_t * info, int size, const char *owner) +void *rh_alloc_align(rh_info_t * info, int size, int alignment, const char *owner) { struct list_head *l; rh_block_t *blk; rh_block_t *newblk; void *start; - /* Validate size */ - if (size <= 0) + /* Validate size, (must be power of two) */ + if (size <= 0 || (alignment & (alignment - 1)) != 0) return ERR_PTR(-EINVAL); + /* given alignment larger that default rheap alignment */ + if (alignment > info->alignment) + size += alignment - 1; + /* Align to configured alignment */ size = (size + (info->alignment - 1)) & ~(info->alignment - 1); @@ -478,15 +480,27 @@ void *rh_alloc(rh_info_t * info, int size, const char *owner) attach_taken_block(info, newblk); + /* for larger alignment return fixed up pointer */ + /* this is no problem with the deallocator since */ + /* we scan for pointers that lie in the blocks */ + if (alignment > info->alignment) + start = (void *)(((unsigned long)start + alignment - 1) & + ~(alignment - 1)); + return start; } +void *rh_alloc(rh_info_t * info, int size, const char *owner) +{ + return rh_alloc_align(info, size, info->alignment, owner); +} + /* allocate at precisely the given address */ void *rh_alloc_fixed(rh_info_t * info, void *start, int size, const char *owner) { struct list_head *l; rh_block_t *blk, *newblk1, *newblk2; - unsigned long s, e, m, bs, be; + unsigned long s, e, m, bs = 0, be = 0; /* Validate size */ if (size <= 0)