-
Notifications
You must be signed in to change notification settings - Fork 0
/
segment.h
35 lines (27 loc) · 1.12 KB
/
segment.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
/* File: segment.h
* ---------------
* An interface to the OS low-level allocator. Used to reserve a large
* segment of memory to be used by a custom heap allocator.
*/
#ifndef _SEGMENT_H_
#define _SEGMENT_H_
#include <stddef.h> // for size_t
/* Function: init_heap_segment
* ---------------------------
* Called to initialize the heap segment and allocate the
* segment to hold total_size bytes. If init_heap_segment
* is called again, it discards the current heap segment and re-configures.
* The function returns the base address of the heap segment if successful
* or NULL if the initialization failed. The base address of the heap segment
* is always aligned to start on a page boundary (page size is 4096 bytes).
*/
void *init_heap_segment(size_t total_size);
/* Functions: heap_segment_start, heap_segment_size
* ------------------------------------------------
* heap_segment_start returns the base address of the current heap segment
* (NULL if no segment has been initialized).
* heap_segment_size returns the current segment size in bytes.
*/
void *heap_segment_start();
size_t heap_segment_size();
#endif