#include <ccan/likely/likely.h>
#include <ccan/alignof/alignof.h>
#include <ccan/short_types/short_types.h>
+#include <ccan/compiler/compiler.h>
#include "config.h"
/*
static unsigned int small_page_bits(unsigned long poolsize)
{
- return fls(poolsize / MAX_SMALL_PAGES / 2);
+ return fls(poolsize / MAX_SMALL_PAGES - 1);
}
static struct page_header *from_pgnum(struct header *head,
/* Add the rest of the pages as large pages. */
i = SMALL_PAGES_PER_LARGE_PAGE;
while ((i << sp_bits) + (1 << lp_bits) <= poolsize) {
+ assert(i < MAX_SMALL_PAGES);
ph = from_pgnum(head, i, sp_bits);
ph->elements_used = 0;
add_large_page_to_freelist(head, ph, sp_bits);
}
/* They want something really big. Aim for contiguous pages (slow). */
-static void *unlikely_func huge_alloc(void *pool, unsigned long poolsize,
- unsigned long size, unsigned long align)
+static COLD_ATTRIBUTE
+void *huge_alloc(void *pool, unsigned long poolsize,
+ unsigned long size, unsigned long align)
{
struct header *head = pool;
struct huge_alloc *ha;
return (char *)pool + ha->off;
}
-static void unlikely_func huge_free(struct header *head,
- unsigned long poolsize, void *free)
+static COLD_ATTRIBUTE void
+huge_free(struct header *head, unsigned long poolsize, void *free)
{
unsigned long i, off, pgnum, free_off = (char *)free - (char *)head;
unsigned int sp_bits, lp_bits;
alloc_free(head, poolsize, ha);
}
-static unsigned long unlikely_func huge_size(struct header *head, void *p)
+static COLD_ATTRIBUTE unsigned long
+huge_size(struct header *head, void *p)
{
unsigned long i, off = (char *)p - (char *)head;
struct huge_alloc *ha;