Support to multi-threading and pthread interface (POSIX.1-2008) (#23)
[lunaix-os.git] / lunaix-os / includes / lunaix / mm / cake.h
index 18d67e0bf3659bae32488122ef6c930aa88d8fc8..bf92b268e21cb228a88a2397352436ac5ce3eb1c 100644 (file)
@@ -2,10 +2,11 @@
 #define __LUNAIX_CAKE_H
 
 #include <lunaix/ds/llist.h>
+#include <lunaix/spike.h>
 
 #define PILE_NAME_MAXLEN 20
 
-#define PILE_CACHELINE 1
+#define PILE_ALIGN_CACHE 1
 
 struct cake_pile;
 
@@ -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 */