hollyhock
Loading...
Searching...
No Matches
mem.h
Go to the documentation of this file.
1
8#pragma once
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#define __UCONCAT(a, b) #a b
15#define _UCONCAT(a, b) __UCONCAT(a, b)
16#define UCONCAT(b) _UCONCAT(__USER_LABEL_PREFIX__, b)
17
18#include <stdint.h>
19#include <stddef.h>
20
22 size_t size;
23 struct Mem_FreeListBlock *next;
24};
25
26static void * const heap_start = (void *)0x8c280000;
27static const
28#ifdef __cplusplus
29constexpr
30#endif
31size_t heap_size = 12 * 1024 * 1024; // 12MB
32static void * const heap_end = (void *)0x8ce80000;
33
34extern struct Mem_FreeListBlock ** const free_list_head;
35
41extern void (*Mem_Free)(void *ptr);
42
43extern void *(*_FP_Mem_Malloc)(size_t size) __asm__ (UCONCAT("Mem_Malloc")) __attribute__((alloc_size(1), warn_unused_result));
44
53static void *Mem_Malloc(size_t size) __asm__ (UCONCAT("Mem_Malloc_Wrapper")) __attribute__((malloc, alloc_size(1), assume_aligned(4), unused, warn_unused_result));
54void *Mem_Malloc(size_t size) {
55 return _FP_Mem_Malloc(size);
56}
57
69extern void *(*Mem_Memcpy)(void *destination, const void *source, size_t num)
70#ifndef __clang__
71__attribute__((access(read_only, 2, 3), access(write_only, 1, 3)))
72#endif
73;
74
87extern void *(*Mem_Memset)(void *ptr, int value, size_t num)
88#ifndef __clang__
89__attribute__((access(write_only, 1, 3)))
90#endif
91;
92
101extern void *(*Mem_Sbrk)(long size);
102
111extern signed char (*Mem_SbrkMode)(signed char newMode);
112
113#ifdef __cplusplus
114}
115#endif
void(* Mem_Free)(void *ptr)
signed char(* Mem_SbrkMode)(signed char newMode)
Definition mem.h:21