| 1 | module builtin |
| 2 | |
| 3 | // Just define the C functions, so that V does not error because of the missing definitions. |
| 4 | |
| 5 | // Note: they will NOT be used, since calls to them are wrapped with `$if gcboehm ? { }` |
| 6 | |
| 7 | fn C.GC_MALLOC(n usize) voidptr |
| 8 | |
| 9 | fn C.GC_MALLOC_ATOMIC(n usize) voidptr |
| 10 | |
| 11 | fn C.GC_MALLOC_UNCOLLECTABLE(n usize) voidptr |
| 12 | |
| 13 | fn C.GC_REALLOC(ptr voidptr, n usize) voidptr |
| 14 | |
| 15 | fn C.GC_FREE(ptr voidptr) |
| 16 | |
| 17 | fn C.GC_memalign(align isize, size isize) voidptr |
| 18 | |
| 19 | fn C.GC_get_heap_usage_safe(pheap_size &usize, pfree_bytes &usize, punmapped_bytes &usize, pbytes_since_gc &usize, |
| 20 | ptotal_bytes &usize) |
| 21 | |
| 22 | fn C.GC_get_memory_use() usize |
| 23 | |
| 24 | fn C.GC_gcollect() |
| 25 | |
| 26 | // gc_check_leaks is useful for detecting leaks, but it needs the GC to run. |
| 27 | // When GC is not used, it is a NOP. |
| 28 | pub fn gc_check_leaks() {} |
| 29 | |
| 30 | // gc_is_enabled() returns true, if the GC is enabled at runtime. |
| 31 | // It will always return false, with `-gc none`. |
| 32 | // See also gc_disable() and gc_enable(). |
| 33 | pub fn gc_is_enabled() bool { |
| 34 | return false |
| 35 | } |
| 36 | |
| 37 | // gc_enable explicitly enables the GC. |
| 38 | // Note, that garbage collections are done automatically, when needed in most cases, |
| 39 | // and also that by default the GC is on, so you do not need to enable it. |
| 40 | // See also gc_disable() and gc_collect(). |
| 41 | // Note that gc_enable() is a NOP with `-gc none`. |
| 42 | pub fn gc_enable() {} |
| 43 | |
| 44 | // gc_disable explicitly disables the GC. |
| 45 | // Do not forget to enable it again by calling gc_enable(), when your program is otherwise idle, and can afford it. |
| 46 | // See also gc_enable() and gc_collect(). |
| 47 | // Note that gc_disable() is a NOP with `-gc none`. |
| 48 | pub fn gc_disable() {} |
| 49 | |
| 50 | // gc_collect explicitly performs a garbage collection. |
| 51 | // When the GC is not on, (with `-gc none`), it is a NOP. |
| 52 | pub fn gc_collect() {} |
| 53 | |
| 54 | pub type FnGC_WarnCB = fn (msg &char, arg usize) |
| 55 | |
| 56 | fn C.GC_get_warn_proc() FnGC_WarnCB |
| 57 | fn C.GC_set_warn_proc(cb FnGC_WarnCB) |
| 58 | |
| 59 | // gc_get_warn_proc returns the current callback fn, that will be used for printing GC warnings. |
| 60 | // When the GC is not on, it is a NOP. |
| 61 | pub fn gc_get_warn_proc() {} |
| 62 | |
| 63 | // gc_set_warn_proc sets the callback fn, that will be used for printing GC warnings. |
| 64 | // When the GC is not on, it is a NOP. |
| 65 | pub fn gc_set_warn_proc(cb FnGC_WarnCB) {} |
| 66 | |
| 67 | // used by builtin_init |
| 68 | fn internal_gc_warn_proc_none(msg &char, arg usize) {} |
| 69 | |