git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
7-ps2_keyboard.md and 8-multitasking.md (#29)
[lunaix-os.git]
/
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 81321f87b898c7ce1b6bd05b50f35d342dc5d8ff..bf92b268e21cb228a88a2397352436ac5ce3eb1c 100644
(file)
--- 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 <lunaix/ds/llist.h>
#define __LUNAIX_CAKE_H
#include <lunaix/ds/llist.h>
+#include <lunaix/spike.h>
#define PILE_NAME_MAXLEN 20
#define PILE_NAME_MAXLEN 20
-#define PILE_
CACHELIN
E 1
+#define PILE_
ALIGN_CACH
E 1
struct cake_pile;
struct cake_pile;
@@
-17,12
+18,12
@@
struct cake_pile
struct llist_header full;
struct llist_header partial;
struct llist_header free;
struct llist_header full;
struct llist_header partial;
struct llist_header free;
- u
nsigned in
t offset;
- u
nsigned in
t piece_size;
- u
nsigned in
t cakes_count;
- u
nsigned in
t alloced_pieces;
- u
nsigned in
t pieces_per_cake;
- u
nsigned in
t pg_per_cake;
+ u
32_
t offset;
+ u
32_
t piece_size;
+ u
32_
t cakes_count;
+ u
32_
t alloced_pieces;
+ u
32_
t pieces_per_cake;
+ u
32_
t pg_per_cake;
char pile_name[PILE_NAME_MAXLEN];
pile_cb ctor;
char pile_name[PILE_NAME_MAXLEN];
pile_cb ctor;
@@
-30,7
+31,7
@@
struct cake_pile
typedef unsigned int piece_index_t;
typedef unsigned int piece_index_t;
-#define EO_FREE_PIECE (-1)
+#define EO_FREE_PIECE (
(u32_t)
-1)
struct cake_s
{
struct cake_s
{
@@
-87,4
+88,13
@@
cake_export();
void
cake_ctor_zeroing(struct cake_pile* pile, void* piece);
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 */
#endif /* __LUNAIX_VALLOC_H */