summaryrefslogtreecommitdiff
path: root/py/modgc.c
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2024-02-27 15:32:29 +1100
committerDamien George <damien@micropython.org>2024-03-07 14:20:42 +1100
commitdecf8e6a8bb940d5829ca3296790631fcece7b21 (patch)
tree55b7cd31de14b73e4b72d49344e9084f402767a9 /py/modgc.c
parentb3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff)
all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit d5df6cd44a433d6253a61cb0f987835fbc06b2de. The original reason for this was to have the option to define it to nothing so that all static functions become global functions and therefore visible to certain debug tools, so one could do function size comparison and other things. This STATIC feature is rarely (if ever) used. And with the use of LTO and heavy inline optimisation, analysing the size of individual functions when they are not static is not a good representation of the size of code when fully optimised. So the macro does not have much use and it's simpler to just remove it. Then you know exactly what it's doing. For example, newcomers don't have to learn what the STATIC macro is and why it exists. Reading the code is also less "loud" with a lowercase static. One other minor point in favour of removing it, is that it stops bugs with `STATIC inline`, which should always be `static inline`. Methodology for this commit was: 1) git ls-files | egrep '\.[ch]$' | \ xargs sed -Ei "s/(^| )STATIC($| )/\1static\2/" 2) Do some manual cleanup in the diff by searching for the word STATIC in comments and changing those back. 3) "git-grep STATIC docs/", manually fixed those cases. 4) "rg -t python STATIC", manually fixed codegen lines that used STATIC. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'py/modgc.c')
-rw-r--r--py/modgc.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/py/modgc.c b/py/modgc.c
index 7b18045b0..47902d8c9 100644
--- a/py/modgc.c
+++ b/py/modgc.c
@@ -31,7 +31,7 @@
#if MICROPY_PY_GC && MICROPY_ENABLE_GC
// collect(): run a garbage collection
-STATIC mp_obj_t py_gc_collect(void) {
+static mp_obj_t py_gc_collect(void) {
gc_collect();
#if MICROPY_PY_GC_COLLECT_RETVAL
return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected));
@@ -42,26 +42,26 @@ STATIC mp_obj_t py_gc_collect(void) {
MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect);
// disable(): disable the garbage collector
-STATIC mp_obj_t gc_disable(void) {
+static mp_obj_t gc_disable(void) {
MP_STATE_MEM(gc_auto_collect_enabled) = 0;
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable);
// enable(): enable the garbage collector
-STATIC mp_obj_t gc_enable(void) {
+static mp_obj_t gc_enable(void) {
MP_STATE_MEM(gc_auto_collect_enabled) = 1;
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable);
-STATIC mp_obj_t gc_isenabled(void) {
+static mp_obj_t gc_isenabled(void) {
return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled));
}
MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled);
// mem_free(): return the number of bytes of available heap RAM
-STATIC mp_obj_t gc_mem_free(void) {
+static mp_obj_t gc_mem_free(void) {
gc_info_t info;
gc_info(&info);
#if MICROPY_GC_SPLIT_HEAP_AUTO
@@ -74,7 +74,7 @@ STATIC mp_obj_t gc_mem_free(void) {
MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_free_obj, gc_mem_free);
// mem_alloc(): return the number of bytes of heap RAM that are allocated
-STATIC mp_obj_t gc_mem_alloc(void) {
+static mp_obj_t gc_mem_alloc(void) {
gc_info_t info;
gc_info(&info);
return MP_OBJ_NEW_SMALL_INT(info.used);
@@ -82,7 +82,7 @@ STATIC mp_obj_t gc_mem_alloc(void) {
MP_DEFINE_CONST_FUN_OBJ_0(gc_mem_alloc_obj, gc_mem_alloc);
#if MICROPY_GC_ALLOC_THRESHOLD
-STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
+static mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
if (MP_STATE_MEM(gc_alloc_threshold) == (size_t)-1) {
return MP_OBJ_NEW_SMALL_INT(-1);
@@ -100,7 +100,7 @@ STATIC mp_obj_t gc_threshold(size_t n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gc_threshold_obj, 0, 1, gc_threshold);
#endif
-STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
+static const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gc) },
{ MP_ROM_QSTR(MP_QSTR_collect), MP_ROM_PTR(&gc_collect_obj) },
{ MP_ROM_QSTR(MP_QSTR_disable), MP_ROM_PTR(&gc_disable_obj) },
@@ -113,7 +113,7 @@ STATIC const mp_rom_map_elem_t mp_module_gc_globals_table[] = {
#endif
};
-STATIC MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
+static MP_DEFINE_CONST_DICT(mp_module_gc_globals, mp_module_gc_globals_table);
const mp_obj_module_t mp_module_gc = {
.base = { &mp_type_module },