1 #ifndef __LUNAIX_CAKE_H
2 #define __LUNAIX_CAKE_H
4 #include <lunaix/ds/llist.h>
6 #define PILE_NAME_MAXLEN 20
8 #define PILE_CACHELINE 1
12 typedef void (*pile_cb)(struct cake_pile*, void*);
16 struct llist_header piles;
17 struct llist_header full;
18 struct llist_header partial;
19 struct llist_header free;
21 unsigned int piece_size;
22 unsigned int cakes_count;
23 unsigned int alloced_pieces;
24 unsigned int pieces_per_cake;
25 unsigned int pg_per_cake;
26 char pile_name[PILE_NAME_MAXLEN];
31 typedef unsigned int piece_index_t;
33 #define EO_FREE_PIECE (-1)
37 struct llist_header cakes;
39 unsigned int used_pieces;
40 unsigned int next_free;
41 piece_index_t free_list[0];
48 * @param piece_size 每个蛋糕切块儿的大小
49 * @param pg_per_cake 每个蛋糕所占据的页数
50 * @return struct cake_pile*
53 cake_new_pile(char* name,
54 unsigned int piece_size,
55 unsigned int pg_per_cake,
59 cake_set_constructor(struct cake_pile* pile, pile_cb ctor);
68 cake_grab(struct cake_pile* pile);
77 cake_release(struct cake_pile* pile, void* area);
85 /********** some handy constructor ***********/
88 cake_ctor_zeroing(struct cake_pile* pile, void* piece);
90 #endif /* __LUNAIX_VALLOC_H */