X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Falloc%2Falloc.c;h=e6f21f887e1a756c29667615db064db246259e80;hp=e9aaf3ddea8c7c7727f6a65c5ccd4a516209307c;hb=74257cee33ae3033f961d5f22a0313b8cb1b18d4;hpb=fbc7877063275421c4313ea30a65378d48dd4f07 diff --git a/ccan/alloc/alloc.c b/ccan/alloc/alloc.c index e9aaf3dd..e6f21f88 100644 --- a/ccan/alloc/alloc.c +++ b/ccan/alloc/alloc.c @@ -1,3 +1,4 @@ +/* Licensed under LGPLv2.1+ - see LICENSE file for details */ #include #include #include @@ -124,7 +125,7 @@ static unsigned long bucket_to_size(unsigned int bucket) */ static unsigned int size_to_bucket(unsigned long size) { - unsigned int base = fls(size/2); + unsigned int base = afls(size/2); unsigned long overshoot; overshoot = size - (1UL << base); @@ -134,7 +135,7 @@ static unsigned int size_to_bucket(unsigned long size) static unsigned int small_page_bits(unsigned long poolsize) { - return fls(poolsize / MAX_SMALL_PAGES - 1); + return afls(poolsize / MAX_SMALL_PAGES - 1); } static struct page_header *from_pgnum(struct header *head, @@ -313,7 +314,7 @@ static unsigned int find_free_bit(const unsigned long bitmap[]) unsigned int i; for (i = 0; bitmap[i] == -1UL; i++); - return (i*BITS_PER_LONG) + ffsl(~bitmap[i]) - 1; + return (i*BITS_PER_LONG) + affsl(~bitmap[i]) - 1; } /* How many elements can we fit in a page? */ @@ -422,7 +423,8 @@ static void del_large_from_small_free_list(struct header *head, for (i = 0; i < SMALL_PAGES_PER_LARGE_PAGE; i++) { del_from_list(head, &head->small_free_list, - (void *)ph + (i << sp_bits), + (struct page_header *)((char *)ph + + (i << sp_bits)), sp_bits); } }