ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Classes | Macros | Functions
buddy.h File Reference

A Buddy System implementation. More...

#include <datatypes/bitmap.h>
#include <assert.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for buddy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  buddy_state
 The checkpointable memory context of a single buddy system. More...
 
struct  buddy_realloc_res
 

Macros

#define B_TOTAL_EXP   16U
 
#define B_BLOCK_EXP   6U
 
#define next_exp_of_2(i)   (sizeof(i) * CHAR_BIT - intrinsics_clz(i))
 
#define buddy_allocation_block_compute(req_size)   next_exp_of_2(max(req_size, 1U << B_BLOCK_EXP) - 1);
 
#define buddy_left_child(i)   (((i) << 1U) + 1U)
 
#define buddy_right_child(i)   (((i) << 1U) + 2U)
 
#define buddy_parent(i)   ((((i) + 1) >> 1U) - 1U)
 

Functions

void buddy_init (struct buddy_state *self)
 
void * buddy_malloc (struct buddy_state *self, uint_fast8_t req_blks_exp)
 
uint_fast32_t buddy_free (struct buddy_state *self, void *ptr)
 
struct buddy_realloc_res buddy_best_effort_realloc (struct buddy_state *self, void *ptr, size_t req_size)
 
void buddy_dirty_mark (struct buddy_state *self, const void *ptr, size_t s)
 

Detailed Description

A Buddy System implementation.