LF OS
Hobby operating system for amd64 with high ambitions
|
Go to the source code of this file.
Typedefs | |
typedef struct tpa | tpa_t |
Functions | |
tpa_t * | tpa_new (allocator_t *alloc, uint64_t entry_size, uint64_t page_size, tpa_t *tpa) |
void | tpa_delete (tpa_t *tpa) |
void * | tpa_get (tpa_t *tpa, size_t idx) |
void | tpa_set (tpa_t *tpa, size_t idx, void *data) |
size_t | tpa_size (tpa_t *tpa) |
ssize_t | tpa_length (tpa_t *tpa) |
size_t | tpa_entries (tpa_t *tpa) |
size_t | tpa_next (tpa_t *tpa, size_t cur) |
void tpa_delete | ( | tpa_t * | tpa | ) |
Deallocate every data in use by the given TPA And the TPA itself
tpa | The TPA to destroy |
Definition at line 61 of file tpa.c.
References tpa::allocator, allocator::dealloc, tpa::first, and tpa_page_header::next.
Counts the number of existing entries in the TPA
tpa | The TPA |
Definition at line 110 of file tpa.c.
References tpa::first, tpa_page_header::next, tpa_entries_per_page(), and tpa_entry_exists_in_page().
Retrieve a given element from the TPA or NULL if the element is not present
tpa | The TPA |
idx | The index of the element to retrieve |
Definition at line 144 of file tpa.c.
References tpa_page_header::start_idx, tpa_entry_exists_in_page(), tpa_get_page_for_idx(), and tpa_offset_in_page().
Retrieve the highest index currently possible without new allocation
tpa | The TPA |
Definition at line 87 of file tpa.c.
References tpa::first, tpa_page_header::next, tpa_page_header::start_idx, and tpa_entries_per_page().
tpa_t * tpa_new | ( | allocator_t * | alloc, |
uint64_t | entry_size, | ||
uint64_t | page_size, | ||
tpa_t * | tpa | ||
) |
Allocate and initialize a new Thin Provisioned Array
alloc | Allocator function to use |
dealloc | Deallocator function to use |
entry_size | Size of each entry |
page_size | Size of each data page |
tpa | Pointer to a memory region to use as tpa, 0 to alloc internally |
Definition at line 48 of file tpa.c.
References allocator::alloc, alloc, tpa::allocator, tpa::entry_size, tpa::first, and tpa::page_size.
Returns the next non-empty element after cur
tpa | The TPA |
cur | The current index |
Definition at line 223 of file tpa.c.
References tpa::first, tpa_page_header::next, tpa_page_header::start_idx, tpa_entries_per_page(), and tpa_get_marker().
Set new data at the given index
tpa | The TPA |
idx | Where to place the new entry |
data | Pointer to the first byte of the data to store |
Definition at line 174 of file tpa.c.
References allocator::alloc, tpa::allocator, tpa::entry_size, tpa::first, memcpy(), memset(), tpa_page_header::next, tpa::page_size, tpa_page_header::prev, tpa_page_header::start_idx, tpa_clean_page(), tpa_entries_per_page(), tpa_get_marker(), tpa_get_page_for_idx(), and tpa_offset_in_page().
Returns the allocated size of the TPA in bytes
Definition at line 72 of file tpa.c.
References tpa::first, tpa_page_header::next, and tpa::page_size.