Rev 2089 | Rev 3206 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2089 | Rev 2106 | ||
|---|---|---|---|
| Line 42... | Line 42... | ||
| 42 | 42 | ||
| 43 | struct buddy_system; |
43 | struct buddy_system; |
| 44 | 44 | ||
| 45 | /** Buddy system operations to be implemented by each implementation. */ |
45 | /** Buddy system operations to be implemented by each implementation. */ |
| 46 | typedef struct { |
46 | typedef struct { |
| - | 47 | /** |
|
| 47 | /** Return pointer to left-side or right-side buddy for block passed as |
48 | * Return pointer to left-side or right-side buddy for block passed as |
| 48 | * argument. */ |
49 | * argument. |
| - | 50 | */ |
|
| 49 | link_t *(* find_buddy)(struct buddy_system *, link_t *); |
51 | link_t *(* find_buddy)(struct buddy_system *, link_t *); |
| - | 52 | /** |
|
| 50 | /** Bisect the block passed as argument and return pointer to the new |
53 | * Bisect the block passed as argument and return pointer to the new |
| 51 | * right-side buddy. */ |
54 | * right-side buddy. |
| - | 55 | */ |
|
| 52 | link_t *(* bisect)(struct buddy_system *, link_t *); |
56 | link_t *(* bisect)(struct buddy_system *, link_t *); |
| 53 | /** Coalesce two buddies into a bigger block. */ |
57 | /** Coalesce two buddies into a bigger block. */ |
| 54 | link_t *(* coalesce)(struct buddy_system *, link_t *, link_t *); |
58 | link_t *(* coalesce)(struct buddy_system *, link_t *, link_t *); |
| 55 | /** Set order of block passed as argument. */ |
59 | /** Set order of block passed as argument. */ |
| 56 | void (*set_order)(struct buddy_system *, link_t *, uint8_t); |
60 | void (*set_order)(struct buddy_system *, link_t *, uint8_t); |
| Line 73... | Line 77... | ||
| 73 | /** Pointer to be used by the implementation. */ |
77 | /** Pointer to be used by the implementation. */ |
| 74 | void *data; |
78 | void *data; |
| 75 | } buddy_system_t; |
79 | } buddy_system_t; |
| 76 | 80 | ||
| 77 | extern void buddy_system_create(buddy_system_t *b, uint8_t max_order, |
81 | extern void buddy_system_create(buddy_system_t *b, uint8_t max_order, |
| 78 | buddy_system_operations_t *op, void *data); |
82 | buddy_system_operations_t *op, void *data); |
| 79 | extern link_t *buddy_system_alloc(buddy_system_t *b, uint8_t i); |
83 | extern link_t *buddy_system_alloc(buddy_system_t *b, uint8_t i); |
| 80 | extern bool buddy_system_can_alloc(buddy_system_t *b, uint8_t order); |
84 | extern bool buddy_system_can_alloc(buddy_system_t *b, uint8_t order); |
| 81 | extern void buddy_system_free(buddy_system_t *b, link_t *block); |
85 | extern void buddy_system_free(buddy_system_t *b, link_t *block); |
| 82 | extern void buddy_system_structure_print(buddy_system_t *b, size_t elem_size); |
86 | extern void buddy_system_structure_print(buddy_system_t *b, size_t elem_size); |
| 83 | extern size_t buddy_conf_size(int max_order); |
87 | extern size_t buddy_conf_size(int max_order); |