-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocators.h
92 lines (81 loc) · 2.86 KB
/
locators.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#include "vma_definitions.h"
/*
* @brief -> checks if the given interval is already allocated
* @param -> arena (arena_t *)
* @param -> address = miniblock start adress (const uint64_t)
* @param -> size = miniblock size (const uint64_t)
* @return -> 1 if true, else 0
*/
uint8_t zone_is_free(arena_t *arena, const uint64_t address,
const uint64_t size);
/*
* @brief -> checks if the new block will share the start address
* with another block and returns the index
* @param -> b_list = block list a.k.a. alloc_list (list_t *)
* @param -> start_address (const uint64_t)
* @return -> the neighbour block's index
*/
int64_t share_start(list_t *b_list, const uint64_t start_address);
/*
* @brief -> checks if the new block will share the end address
* with another block and returns the index
* @param -> b_list = block list a.k.a. alloc_list (list_t *)
* @param -> end_address (const uint64_t)
* @return -> the neighbour block's index
*/
int64_t share_end(list_t *b_list, const uint64_t end_address);
/*
* @brief -> determine the index of the last block before
* the given address
* @param -> arena (arena_t *)
* @param -> address (const uint64_t)
* @return -> the block's index
*/
uint64_t index_last_block_from_address(arena_t *arena, const uint64_t address);
/*
* @brief -> determine the block containing the given address
* @param -> arena (arena_t *)
* @param -> address (const uint64_t)
* @return -> the block
*/
block_t *block_containing_address(arena_t *arena, const uint64_t address);
/*
* @brief -> determine the index of the block in alloc_list
* @param -> arena (arena_t *)
* @param -> address (const uint64_t)
* @return -> the block's index
*/
int64_t index_block(arena_t *arena, const uint64_t address);
/*
* @brief -> determine the miniblock at the given address
* @param -> arena (arena_t *)
* @param -> address (const uint64_t)
* @return -> the miniblock
*/
miniblock_t *miniblock_at_address(arena_t *arena, const uint64_t address);
/*
* @brief -> determine the index of the miniblock in miniblock list
* @param -> arena (arena_t *)
* @param -> address (const uint64_t)
* @return -> the miniblock's index
*/
int64_t index_miniblock(arena_t *arena, const uint64_t address);
/*
* @brief -> sum of miniblock sizes within a given interval in m_list
* @param -> m_list = miniblock list (list_t *)
* @param -> start_index (uint64_t)
* @param -> end_index (const uint64_t)
* @return -> value of sum
*/
uint64_t miniblock_size_sum(list_t *m_list, uint64_t start_index,
const uint64_t end_index);
/*
* @brief -> counts miniblocks within a given interval in m_list
* @param -> m_list = miniblock list (list_t *)
* @param -> start_index (uint64_t)
* @param -> end_index (const uint64_t)
* @return -> number of miniblocks
*/
uint64_t miniblock_num(list_t *m_list, uint64_t start_index,
const uint64_t end_index);