summaryrefslogtreecommitdiff
path: root/extmod/machine_signal.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/machine_signal.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/machine_signal.c')
-rw-r--r--extmod/machine_signal.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/extmod/machine_signal.c b/extmod/machine_signal.c
index 63fd0fe47..6295a496b 100644
--- a/extmod/machine_signal.c
+++ b/extmod/machine_signal.c
@@ -41,7 +41,7 @@ typedef struct _machine_signal_t {
bool invert;
} machine_signal_t;
-STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+static mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_obj_t pin;
bool invert = false;
@@ -113,7 +113,7 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
return MP_OBJ_FROM_PTR(o);
}
-STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
+static mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
(void)errcode;
machine_signal_t *self = MP_OBJ_TO_PTR(self_in);
@@ -130,7 +130,7 @@ STATIC mp_uint_t signal_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg
}
// fast method for getting/setting signal value
-STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+static mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
if (n_args == 0) {
// get pin
@@ -142,32 +142,32 @@ STATIC mp_obj_t signal_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
}
}
-STATIC mp_obj_t signal_value(size_t n_args, const mp_obj_t *args) {
+static mp_obj_t signal_value(size_t n_args, const mp_obj_t *args) {
return signal_call(args[0], n_args - 1, 0, args + 1);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(signal_value_obj, 1, 2, signal_value);
+static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(signal_value_obj, 1, 2, signal_value);
-STATIC mp_obj_t signal_on(mp_obj_t self_in) {
+static mp_obj_t signal_on(mp_obj_t self_in) {
mp_virtual_pin_write(self_in, 1);
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_on_obj, signal_on);
+static MP_DEFINE_CONST_FUN_OBJ_1(signal_on_obj, signal_on);
-STATIC mp_obj_t signal_off(mp_obj_t self_in) {
+static mp_obj_t signal_off(mp_obj_t self_in) {
mp_virtual_pin_write(self_in, 0);
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(signal_off_obj, signal_off);
+static MP_DEFINE_CONST_FUN_OBJ_1(signal_off_obj, signal_off);
-STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = {
+static const mp_rom_map_elem_t signal_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&signal_value_obj) },
{ MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&signal_on_obj) },
{ MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&signal_off_obj) },
};
-STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table);
+static MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table);
-STATIC const mp_pin_p_t signal_pin_p = {
+static const mp_pin_p_t signal_pin_p = {
.ioctl = signal_ioctl,
};