summaryrefslogtreecommitdiff
path: root/extmod/modmachine.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 /extmod/modmachine.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 'extmod/modmachine.c')
-rw-r--r--extmod/modmachine.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/extmod/modmachine.c b/extmod/modmachine.c
index a64b8ba79..90e2a38a7 100644
--- a/extmod/modmachine.c
+++ b/extmod/modmachine.c
@@ -37,20 +37,20 @@
// The port must provide implementations of these low-level machine functions.
-STATIC void mp_machine_idle(void);
+static void mp_machine_idle(void);
#if MICROPY_PY_MACHINE_BOOTLOADER
NORETURN void mp_machine_bootloader(size_t n_args, const mp_obj_t *args);
#endif
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
-STATIC mp_obj_t mp_machine_unique_id(void);
-NORETURN STATIC void mp_machine_reset(void);
-STATIC mp_int_t mp_machine_reset_cause(void);
-STATIC mp_obj_t mp_machine_get_freq(void);
-STATIC void mp_machine_set_freq(size_t n_args, const mp_obj_t *args);
-STATIC void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args);
-NORETURN STATIC void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args);
+static mp_obj_t mp_machine_unique_id(void);
+NORETURN static void mp_machine_reset(void);
+static mp_int_t mp_machine_reset_cause(void);
+static mp_obj_t mp_machine_get_freq(void);
+static void mp_machine_set_freq(size_t n_args, const mp_obj_t *args);
+static void mp_machine_lightsleep(size_t n_args, const mp_obj_t *args);
+NORETURN static void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args);
#endif
// The port can provide additional machine-module implementation in this file.
@@ -58,11 +58,11 @@ NORETURN STATIC void mp_machine_deepsleep(size_t n_args, const mp_obj_t *args);
#include MICROPY_PY_MACHINE_INCLUDEFILE
#endif
-STATIC mp_obj_t machine_soft_reset(void) {
+static mp_obj_t machine_soft_reset(void) {
pyexec_system_exit = PYEXEC_FORCED_EXIT;
mp_raise_type(&mp_type_SystemExit);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
+static MP_DEFINE_CONST_FUN_OBJ_0(machine_soft_reset_obj, machine_soft_reset);
#if MICROPY_PY_MACHINE_BOOTLOADER
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
@@ -71,30 +71,30 @@ NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_bootloader_obj, 0, 1, machine_bootloader);
#endif
-STATIC mp_obj_t machine_idle(void) {
+static mp_obj_t machine_idle(void) {
mp_machine_idle();
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle);
+static MP_DEFINE_CONST_FUN_OBJ_0(machine_idle_obj, machine_idle);
#if MICROPY_PY_MACHINE_BARE_METAL_FUNCS
-STATIC mp_obj_t machine_unique_id(void) {
+static mp_obj_t machine_unique_id(void) {
return mp_machine_unique_id();
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id);
-NORETURN STATIC mp_obj_t machine_reset(void) {
+NORETURN static mp_obj_t machine_reset(void) {
mp_machine_reset();
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset);
-STATIC mp_obj_t machine_reset_cause(void) {
+static mp_obj_t machine_reset_cause(void) {
return MP_OBJ_NEW_SMALL_INT(mp_machine_reset_cause());
}
MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_cause_obj, machine_reset_cause);
-STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
+static mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
return mp_machine_get_freq();
} else {
@@ -104,13 +104,13 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_freq_obj, 0, 1, machine_freq);
-STATIC mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) {
+static mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) {
mp_machine_lightsleep(n_args, args);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lightsleep_obj, 0, 1, machine_lightsleep);
-NORETURN STATIC mp_obj_t machine_deepsleep(size_t n_args, const mp_obj_t *args) {
+NORETURN static mp_obj_t machine_deepsleep(size_t n_args, const mp_obj_t *args) {
mp_machine_deepsleep(n_args, args);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_deepsleep_obj, 0, 1, machine_deepsleep);
@@ -119,22 +119,22 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_deepsleep_obj, 0, 1, machine_deepsle
#if MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ
-STATIC mp_obj_t machine_disable_irq(void) {
+static mp_obj_t machine_disable_irq(void) {
uint32_t state = MICROPY_BEGIN_ATOMIC_SECTION();
return mp_obj_new_int(state);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
+static MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
-STATIC mp_obj_t machine_enable_irq(mp_obj_t state_in) {
+static mp_obj_t machine_enable_irq(mp_obj_t state_in) {
uint32_t state = mp_obj_get_int(state_in);
MICROPY_END_ATOMIC_SECTION(state);
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);
+static MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);
#endif
-STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
+static const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_machine) },
// Memory access objects.
@@ -230,7 +230,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
MICROPY_PY_MACHINE_EXTRA_GLOBALS
#endif
};
-STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table);
+static MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table);
const mp_obj_module_t mp_module_machine = {
.base = { &mp_type_module },