ck_bag: Support user-defined block size (in units of cache lines).

ck_pring
Samy Al Bahra 13 years ago
parent 85c37ef251
commit a80ade3eef

@ -33,12 +33,6 @@
#include <stdbool.h>
#include <string.h>
#if CK_MD_CACHELINE > 128
#define CK_BAG_CL_SIZE 128
#else
#define CK_BAG_CL_SIZE CK_MD_CACHELINE
#endif
#ifndef CK_BAG_PAGESIZE
#define CK_BAG_PAGESIZE CK_MD_PAGESIZE
#endif
@ -72,15 +66,14 @@ ck_bag_init(struct ck_bag *bag,
block_overhead = sizeof(struct ck_bag_block) + allocator_overhead;
if (n_block_entries == CK_BAG_DEFAULT) {
bag->info.max = ((CK_BAG_PAGESIZE - block_overhead) / sizeof(void *));
bag->info.max = (CK_BAG_PAGESIZE - block_overhead) / sizeof(void *);
} else {
bag->info.max = ((CK_BAG_CL_SIZE - block_overhead) / sizeof(void *));
bag->info.max = (n_block_entries * CK_MD_CACHELINE - block_overhead) / sizeof(void *);
if (n_block_entries > bag->info.max)
bag->info.max = n_block_entries;
}
bag->info.bytes = block_overhead + sizeof(void *) * bag->info.max;
return true;
}

Loading…
Cancel
Save