XenevaOS
Loading...
Searching...
No Matches
buddy.h
Go to the documentation of this file.
1
30#ifndef __BUDDY_H__
31#define __BUDDY_H__
32
33#include <stdint.h>
34
35#if 0
36
37#define BUDDY_MAGIC 0x160602
38/*
39 * BuddyBlock size should be
40 * aligned to 32 byte
41 */
42#pragma pack(push,1)
43typedef struct _buddy_block_ {
44 _buddy_block_ *next;
45 _buddy_block_ *prev;
46 void* head;
47 uint32_t buddy_magic;
48 uint32_t size;
49}BuddyBlock;
50#pragma pack(pop)
51
52typedef struct _buddy_free_list_ {
53 BuddyBlock *first;
54}BuddyFreeList;
55
56
57/*
58* AuBuddyInitialise -- initialise the buddy allocator
59*/
60extern void AuBuddyInitialise();
61
62/*
63* AuBuddyGetLevel -- Return the buddy level by its size
64* @param size -- required size
65*/
66extern size_t AuBuddyGetLevel(size_t size);
67
68/*
69* __AuBuddyAlloc -- allocates a memory from given level
70* @param level -- level to check
71*/
72extern void* __AuBuddyAlloc(size_t level);
73
74/*
75* AuBuddyAlloc -- Allocate some memory
76* @param sz -- Size to allocate
77*/
78extern void* AuBuddyAlloc(size_t sz);
79
80/*
81* AuBuddyFree -- frees up an allocated
82* object
83* @param p -- Pointer to memory block
84*/
85extern void AuBuddyFree(void* p);
86
87#endif
88
89#endif
unsigned int uint32_t
Definition acefiex.h:163