summaryrefslogtreecommitdiff
path: root/include/mimalloc-internal.h
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2019-08-10 17:48:00 -0700
committerdaan <daanl@outlook.com>2019-08-10 17:48:00 -0700
commited785253bf5bcf98374db95992b0e7f1fc952a7a (patch)
tree49e028efdeb20b124729d85543679305af0a8d90 /include/mimalloc-internal.h
parentc0258b2d298e3f62b1fa0093bb94bd57b8671bf6 (diff)
restructure the page flags to use explicit masks
Diffstat (limited to 'include/mimalloc-internal.h')
-rw-r--r--include/mimalloc-internal.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index ad9b3ec..151cd00 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -314,16 +314,37 @@ static inline mi_page_queue_t* mi_page_queue(const mi_heap_t* heap, size_t size)
return &((mi_heap_t*)heap)->pages[_mi_bin(size)];
}
+
+//-----------------------------------------------------------
+// Page flags
+//-----------------------------------------------------------
static inline uintptr_t mi_page_thread_id(const mi_page_t* page) {
- return (page->flags.xthread_id << MI_PAGE_FLAGS_BITS);
+ return (page->flags & ~MI_PAGE_FLAGS_MASK);
}
static inline void mi_page_init_flags(mi_page_t* page, uintptr_t thread_id) {
- page->flags.value = 0;
- page->flags.xthread_id = (thread_id >> MI_PAGE_FLAGS_BITS);
- mi_assert(page->flags.value == thread_id);
+ page->flags = thread_id;
+}
+
+static inline bool mi_page_is_in_full(const mi_page_t* page) {
+ return ((page->flags & 0x01) != 0);
+}
+
+static inline void mi_page_set_in_full(mi_page_t* page, bool in_full) {
+ if (in_full) page->flags |= 0x01;
+ else page->flags &= ~0x01;
}
+static inline bool mi_page_has_aligned(const mi_page_t* page) {
+ return ((page->flags & 0x02) != 0);
+}
+
+static inline void mi_page_set_has_aligned(mi_page_t* page, bool has_aligned) {
+ if (has_aligned) page->flags |= 0x02;
+ else page->flags &= ~0x02;
+}
+
+
// -------------------------------------------------------------------
// Encoding/Decoding the free list next pointers
// -------------------------------------------------------------------