@@ -32,7 +32,12 @@ PONY_EXTERN_C_BEGIN
3232 * and 16 bytes for the memalign and message passing pool implementations.
3333 */
3434
35+ #ifndef POOL_USE_DEFAULT
36+ #define POOL_MIN_BITS 4
37+ #else
3538#define POOL_MIN_BITS 5
39+ #endif
40+
3641#define POOL_MAX_BITS 20
3742#define POOL_ALIGN_BITS 10
3843
@@ -57,6 +62,28 @@ size_t ponyint_pool_used_size(size_t index);
5762
5863size_t ponyint_pool_adjust_size (size_t size );
5964
65+ #ifndef POOL_USE_DEFAULT
66+ #define POOL_INDEX (SIZE ) \
67+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 0)), 0, \
68+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 1)), 1, \
69+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 2)), 2, \
70+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 3)), 3, \
71+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 4)), 4, \
72+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 5)), 5, \
73+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 6)), 6, \
74+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 7)), 7, \
75+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 8)), 8, \
76+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 9)), 9, \
77+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 10)), 10, \
78+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 11)), 11, \
79+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 12)), 12, \
80+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 13)), 13, \
81+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 14)), 14, \
82+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 15)), 15, \
83+ __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 16)), 16, \
84+ EXPR_NONE \
85+ )))))))))))))))))
86+ #else
6087#define POOL_INDEX (SIZE ) \
6188 __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 0)), 0, \
6289 __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 1)), 1, \
@@ -76,6 +103,7 @@ size_t ponyint_pool_adjust_size(size_t size);
76103 __pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 15)), 15, \
77104 EXPR_NONE \
78105 ))))))))))))))))
106+ #endif
79107
80108#define POOL_ALLOC (TYPE ) \
81109 (TYPE*) ponyint_pool_alloc(POOL_INDEX(sizeof(TYPE)))
0 commit comments