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
17static const size_t kMinObjectAlignment = 8;
18
19
20void		request_memory_manager_maintenance();
21
22void*		block_alloc_early(size_t size);
23void		block_allocator_init_boot();
24void		block_allocator_init_rest();
25
26
27template<typename Type>
28static inline Type*
29_pop(Type*& head)
30{
31	Type* oldHead = head;
32	head = head->next;
33	return oldHead;
34}
35
36
37template<typename Type>
38static inline void
39_push(Type*& head, Type* object)
40{
41	object->next = head;
42	head = object;
43}
44
45
46static inline void*
47slab_internal_alloc(size_t size, uint32 flags)
48{
49	if (flags & CACHE_DURING_BOOT)
50		return block_alloc_early(size);
51
52	return malloc_etc(size, flags);
53}
54
55
56static inline void
57slab_internal_free(void* buffer, uint32 flags)
58{
59	free_etc(buffer, flags);
60}
61
62
63#endif	// SLAB_PRIVATE_H
64