xref: /haiku/src/system/kernel/slab/slab_private.h (revision 7a74a5df454197933bc6e80a542102362ee98703)
1 /*
2  * Copyright 2007, Hugo Santos. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *      Hugo Santos, hugosantos@gmail.com
7  */
8 #ifndef SLAB_PRIVATE_H
9 #define SLAB_PRIVATE_H
10 
11 
12 #include <stddef.h>
13 
14 #include <slab/Slab.h>
15 
16 
17 static const size_t kMinObjectAlignment = 8;
18 
19 
20 void		request_memory_manager_maintenance();
21 
22 void*		block_alloc(size_t size, size_t alignment, uint32 flags);
23 void*		block_alloc_early(size_t size);
24 void		block_free(void* block, uint32 flags);
25 void		block_allocator_init_boot();
26 void		block_allocator_init_rest();
27 
28 
29 template<typename Type>
30 static inline Type*
31 _pop(Type*& head)
32 {
33 	Type* oldHead = head;
34 	head = head->next;
35 	return oldHead;
36 }
37 
38 
39 template<typename Type>
40 static inline void
41 _push(Type*& head, Type* object)
42 {
43 	object->next = head;
44 	head = object;
45 }
46 
47 
48 static inline void*
49 slab_internal_alloc(size_t size, uint32 flags)
50 {
51 	if (flags & CACHE_DURING_BOOT)
52 		return block_alloc_early(size);
53 
54 	return block_alloc(size, 0, flags);
55 }
56 
57 
58 static inline void
59 slab_internal_free(void* buffer, uint32 flags)
60 {
61 	block_free(buffer, flags);
62 }
63 
64 
65 #endif	// SLAB_PRIVATE_H
66