This repository has been archived by the owner on Jun 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgc.d
209 lines (145 loc) · 5.84 KB
/
gc.d
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
module gc;
import core.stdc.config;
struct GC_stack_base
{
version (IA64)
void* reg_base;
void* mem_base;
}
enum GC_TIME_UNLIMITED = 999999;
enum GC_PROTECTS_NONE = 0;
enum GC_PROTECTS_POINTER_HEAP = 1;
enum GC_PROTECTS_PTRFREE_HEAP = 2;
enum GC_PROTECTS_STATIC_DATA = 4;
enum GC_PROTECTS_STACK = 8;
enum GC_SUCCESS = 0;
enum GC_DUPLICATE = 1;
enum GC_NO_THREADS = 2;
enum GC_UNIMPLEMENTED = 3;
extern (C)
{
alias void function() gc_finalizer_callback_fun;
alias int function() gc_stop_func_fun;
alias void function(void*, void*) gc_finalization_proc_fun;
alias void function(char*, size_t) gc_warn_proc_fun;
alias void* function(void*) gc_fn_type_fun;
alias void* function(GC_stack_base*, void*) gc_stack_base_func_fun;
extern __gshared
{
size_t GC_gc_no;
int GC_parallel;
int GC_find_leak;
int GC_all_interior_pointers;
int GC_finalize_on_demand;
int GC_java_finalization;
gc_finalizer_callback_fun GC_finalizer_notifier;
int GC_dont_gc;
int GC_dont_expand;
int GC_use_entire_heap;
int GC_full_freq;
size_t GC_non_gc_bytes;
int GC_no_dls;
size_t GC_free_space_divisor;
size_t GC_max_retries;
char* GC_stackbottom;
int GC_dont_precollect;
c_ulong GC_time_limit;
}
nothrow
{
void GC_init();
void* GC_malloc(size_t size_in_bytes);
void* GC_malloc_atomic(size_t size_in_bytes);
char* GC_strdup(const(char)* str);
void* GC_malloc_uncollectable(size_t size_in_bytes);
void* GC_malloc_stubborn(size_t size_in_bytes);
void* gc_malloc_atomic_uncollectable(size_t size_in_bytes);
void GC_free(void* object_addr);
void GC_change_stubborn(void* object_addr);
void GC_end_stubborn_change(void* object_addr);
void* GC_base(void* displaced_pointer);
size_t GC_size(void* object_addr);
void* GC_realloc(void* old_object,
size_t new_size_in_bytes);
int GC_expand_hp(size_t number_of_bytes);
void GC_set_max_heap_size(size_t n);
void GC_exclude_static_roots(void* low_address,
void* high_address_plus_1);
void GC_clear_roots();
void GC_add_roots(void* low_address,
void* high_address_plus_1);
void GC_remove_roots(void* low_address,
void* high_address_plus_1);
void GC_register_displacement(size_t n);
void GC_gcollect();
int GC_try_to_collect(gc_stop_func_fun stop_func);
size_t GC_get_heap_size();
size_t GC_get_free_bytes();
size_t GC_get_bytes_since_gc();
size_t GC_get_total_bytes();
void GC_disable();
void GC_enable();
void GC_enable_incremental();
int GC_incremental_protection_needs();
int GC_collect_a_little();
void* GC_malloc_ignore_off_page(size_t lb);
void* GC_malloc_atomic_ignore_off_page(size_t lb);
void GC_register_finalizer(void* obj,
gc_finalization_proc_fun fn,
void* cd,
gc_finalization_proc_fun* ofn,
void** ocd);
void GC_register_finalizer_ignore_self(void* obj,
gc_finalization_proc_fun fn,
void* cd,
gc_finalization_proc_fun* ofn,
void** ocd);
void GC_register_finalizer_no_order(void* obj,
gc_finalization_proc_fun fn,
void* cd,
gc_finalization_proc_fun* ofn,
void** ocd);
void GC_register_finalizer_unreachable(void* obj,
gc_finalization_proc_fun fn,
void* cd,
gc_finalization_proc_fun* ofn,
void** ocd);
int GC_register_disappearing_link(void** link);
int GC_general_register_disappearing_link(void** link,
void* obj);
int GC_unregister_disappearing_link(void** link);
int GC_should_invoke_finalizers();
int GC_invoke_finalizers();
gc_warn_proc_fun GC_set_warn_proc(gc_warn_proc_fun p);
size_t GC_set_free_space_divisor(size_t value);
void* GC_call_with_alloc_lock(gc_fn_type_fun fn,
void* client_data);
void* GC_call_with_stack_base(gc_stack_base_func_fun fn,
void* arg);
int GC_register_my_thread(GC_stack_base* sb);
int GC_unregister_my_thread();
int GC_get_stack_base(GC_stack_base* sb);
void GC_dump();
size_t GC_make_descriptor(size_t*, size_t len);
void* GC_malloc_explicitly_typed(size_t size_in_bytes,
size_t d);
void* GC_malloc_explicitly_typed_ignore_off_page(size_t size_in_bytes,
size_t d);
void* GC_calloc_explicitly_typed(size_t nelements,
size_t element_size_in_bytes,
size_t d);
}
}
void* hidePointer(void* ptr) nothrow
{
return cast(void*)~cast(size_t)ptr;
}
void* revealPointer(void* ptr) nothrow
{
return hidePointer(ptr);
}
private __gshared void* dummy;
void reachableHere(void* ptr) nothrow
{
dummy = ptr;
}