blob: cea368f480ddf8c55b781e3309b52433263bb880 [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2013, 2014 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
Damiendcced922013-10-21 23:45:08 +010027void gc_init(void *start, void *end);
Damien George443e0182014-04-08 11:31:21 +000028
29// These lock/unlock functions can be nested.
30// They can be used to prevent the GC from allocating/freeing.
31void gc_lock(void);
32void gc_unlock(void);
33
34// A given port must implement gc_collect by using the other collect functions.
35void gc_collect(void);
Damien8b3a7c22013-10-23 20:20:17 +010036void gc_collect_start(void);
Damiendcced922013-10-21 23:45:08 +010037void gc_collect_root(void **ptrs, machine_uint_t len);
Damien8b3a7c22013-10-23 20:20:17 +010038void gc_collect_end(void);
Damien George443e0182014-04-08 11:31:21 +000039
Damien George12bab722014-04-05 20:35:48 +010040void *gc_alloc(machine_uint_t n_bytes, bool has_finaliser);
Damienfd8b6bc2013-10-22 20:26:36 +010041void gc_free(void *ptr);
42machine_uint_t gc_nbytes(void *ptr);
Damiendcced922013-10-21 23:45:08 +010043void *gc_realloc(void *ptr, machine_uint_t n_bytes);
Damieneefcc792013-10-22 15:25:25 +010044
45typedef struct _gc_info_t {
46 machine_uint_t total;
47 machine_uint_t used;
48 machine_uint_t free;
49 machine_uint_t num_1block;
50 machine_uint_t num_2block;
51 machine_uint_t max_block;
52} gc_info_t;
53
54void gc_info(gc_info_t *info);
Paul Sokolovsky550d8042014-02-11 23:53:34 +020055void gc_dump_info(void);
Damien Georgece1162a2014-02-26 22:55:59 +000056void gc_dump_alloc_table(void);