forked from digego/extempore
-
Notifications
You must be signed in to change notification settings - Fork 1
/
EXTZONES.h
73 lines (58 loc) · 2.04 KB
/
EXTZONES.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include <UNIV.h>
#include <cinttypes>
#define DEBUG_ZONE_STACK 0
#define DEBUG_ZONE_ALLOC 0
struct zone_hooks_t {
uint64_t space; // here just so we don't get <i8*,i8*>
void* hook; // xtlang closure of type [void]*
zone_hooks_t* hooks;
};
// WARNING WARNING WARNING - HERE BE DRAGONS
// THIS STRUCTURE IS REFERENCED FROM GENERATED CODE
// DO NOT ALTER IT!!!
struct llvm_zone_t {
void* memory;
uint64_t offset;
uint64_t mark;
uint64_t size;
zone_hooks_t* cleanup_hooks;
llvm_zone_t* memories;
};
struct llvm_zone_stack
{
llvm_zone_t* head;
llvm_zone_stack* tail;
};
extern THREAD_LOCAL llvm_zone_stack* tls_llvm_zone_stack;
extern THREAD_LOCAL uint64_t tls_llvm_zone_stacksize;
namespace extemp {
namespace EXTZONES {
const unsigned LLVM_ZONE_ALIGN = 32; // MUST BE POWER OF 2!
const unsigned LLVM_ZONE_ALIGNPAD = LLVM_ZONE_ALIGN - 1;
llvm_zone_t* llvm_zone_create(uint64_t size);
EXPORT void llvm_zone_destroy(llvm_zone_t* Zone);
llvm_zone_t* llvm_zone_reset(llvm_zone_t* Zone);
EXPORT void* llvm_zone_malloc(llvm_zone_t* zone, uint64_t size);
llvm_zone_stack* llvm_threads_get_zone_stack();
void llvm_threads_set_zone_stack(llvm_zone_stack* Stack);
void llvm_push_zone_stack(llvm_zone_t* Zone);
llvm_zone_t* llvm_peek_zone_stack();
EXPORT llvm_zone_t* llvm_pop_zone_stack();
void llvm_threads_inc_zone_stacksize();
void llvm_threads_dec_zone_stacksize();
uint64_t llvm_threads_get_zone_stacksize();
// things that were not in the header before:
// or in the namespace
EXPORT void llvm_zone_print(llvm_zone_t* zone);
EXPORT uint64_t llvm_zone_ptr_size(void* ptr);
EXPORT bool llvm_zone_copy_ptr(void* ptr1, void* ptr2);
EXPORT bool llvm_ptr_in_zone(llvm_zone_t* zone, void* ptr);
EXPORT void* llvm_zone_malloc_from_current_zone(uint64_t size);
EXPORT bool llvm_ptr_in_current_zone(void* ptr);
EXPORT llvm_zone_t* llvm_peek_zone_stack_extern();
EXPORT void llvm_push_zone_stack_extern(llvm_zone_t* Zone);
EXPORT llvm_zone_t* llvm_zone_create_extern(uint64_t Size);
EXPORT llvm_zone_t* llvm_zone_callback_setup();
}
}