X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/ea77b9c3fc7fb9bf9d7f9604fc187c8049212a2a..bdc143a7aa3f51a46eceec62b0b364599533fa21:/lunaix-os/includes/lunaix/mm/cake.h diff --git a/lunaix-os/includes/lunaix/mm/cake.h b/lunaix-os/includes/lunaix/mm/cake.h index 81321f8..cf1c16e 100644 --- a/lunaix-os/includes/lunaix/mm/cake.h +++ b/lunaix-os/includes/lunaix/mm/cake.h @@ -2,10 +2,11 @@ #define __LUNAIX_CAKE_H #include +#include #define PILE_NAME_MAXLEN 20 -#define PILE_CACHELINE 1 +#define PILE_ALIGN_CACHE 1 struct cake_pile; @@ -17,20 +18,20 @@ struct cake_pile struct llist_header full; struct llist_header partial; struct llist_header free; - unsigned int offset; - unsigned int piece_size; - unsigned int cakes_count; - unsigned int alloced_pieces; - unsigned int pieces_per_cake; - unsigned int pg_per_cake; - char pile_name[PILE_NAME_MAXLEN]; + u32_t offset; + u32_t piece_size; + u32_t cakes_count; + u32_t alloced_pieces; + u32_t pieces_per_cake; + u32_t pg_per_cake; + char pile_name[PILE_NAME_MAXLEN+1]; pile_cb ctor; }; typedef unsigned int piece_index_t; -#define EO_FREE_PIECE (-1) +#define EO_FREE_PIECE ((u32_t)-1) struct cake_s { @@ -87,4 +88,13 @@ cake_export(); void cake_ctor_zeroing(struct cake_pile* pile, void* piece); +#define DEADCAKE_MARK 0xdeadcafeUL + +static inline void +cake_ensure_valid(void* area) { + if (unlikely(*(unsigned int*)area == DEADCAKE_MARK)) { + fail("access to freed cake piece"); + } +} + #endif /* __LUNAIX_VALLOC_H */