all: Remove the "STATIC" macro and just use "static" instead.
The STATIC macro was introduced a very long time ago in commit
d5df6cd44a. 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>
This commit is contained in:
committed by
Damien George
parent
b3f2f18f92
commit
decf8e6a8b
@@ -73,7 +73,7 @@
|
||||
#if MICROPY_PY_OS_SYNC
|
||||
// sync()
|
||||
// Sync all filesystems.
|
||||
STATIC mp_obj_t mp_os_sync(void) {
|
||||
static mp_obj_t mp_os_sync(void) {
|
||||
#if MICROPY_VFS_FAT
|
||||
for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
|
||||
// this assumes that vfs->obj is fs_user_mount_t with block device functions
|
||||
@@ -93,20 +93,20 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_os_sync_obj, mp_os_sync);
|
||||
#define CONST_RELEASE const
|
||||
#endif
|
||||
|
||||
STATIC const qstr mp_os_uname_info_fields[] = {
|
||||
static const qstr mp_os_uname_info_fields[] = {
|
||||
MP_QSTR_sysname,
|
||||
MP_QSTR_nodename,
|
||||
MP_QSTR_release,
|
||||
MP_QSTR_version,
|
||||
MP_QSTR_machine
|
||||
};
|
||||
STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_sysname_obj, MICROPY_PY_SYS_PLATFORM);
|
||||
STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_nodename_obj, MICROPY_PY_SYS_PLATFORM);
|
||||
STATIC CONST_RELEASE MP_DEFINE_STR_OBJ(mp_os_uname_info_release_obj, MICROPY_VERSION_STRING);
|
||||
STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE MICROPY_BUILD_TYPE_PAREN);
|
||||
STATIC const MP_DEFINE_STR_OBJ(mp_os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME);
|
||||
static const MP_DEFINE_STR_OBJ(mp_os_uname_info_sysname_obj, MICROPY_PY_SYS_PLATFORM);
|
||||
static const MP_DEFINE_STR_OBJ(mp_os_uname_info_nodename_obj, MICROPY_PY_SYS_PLATFORM);
|
||||
static CONST_RELEASE MP_DEFINE_STR_OBJ(mp_os_uname_info_release_obj, MICROPY_VERSION_STRING);
|
||||
static const MP_DEFINE_STR_OBJ(mp_os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE MICROPY_BUILD_TYPE_PAREN);
|
||||
static const MP_DEFINE_STR_OBJ(mp_os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME);
|
||||
|
||||
STATIC MP_DEFINE_ATTRTUPLE(
|
||||
static MP_DEFINE_ATTRTUPLE(
|
||||
mp_os_uname_info_obj,
|
||||
mp_os_uname_info_fields,
|
||||
5,
|
||||
@@ -117,7 +117,7 @@ STATIC MP_DEFINE_ATTRTUPLE(
|
||||
MP_ROM_PTR(&mp_os_uname_info_machine_obj)
|
||||
);
|
||||
|
||||
STATIC mp_obj_t mp_os_uname(void) {
|
||||
static mp_obj_t mp_os_uname(void) {
|
||||
#if MICROPY_PY_OS_UNAME_RELEASE_DYNAMIC
|
||||
const char *release = mp_os_uname_release();
|
||||
mp_os_uname_info_release_obj.len = strlen(release);
|
||||
@@ -125,12 +125,12 @@ STATIC mp_obj_t mp_os_uname(void) {
|
||||
#endif
|
||||
return MP_OBJ_FROM_PTR(&mp_os_uname_info_obj);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_os_uname_obj, mp_os_uname);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_0(mp_os_uname_obj, mp_os_uname);
|
||||
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_OS_DUPTERM_NOTIFY
|
||||
STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) {
|
||||
static mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) {
|
||||
(void)obj_in;
|
||||
for (;;) {
|
||||
int c = mp_os_dupterm_rx_chr();
|
||||
@@ -141,10 +141,10 @@ STATIC mp_obj_t mp_os_dupterm_notify(mp_obj_t obj_in) {
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_1(mp_os_dupterm_notify_obj, mp_os_dupterm_notify);
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||
static const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_os) },
|
||||
|
||||
#if MICROPY_PY_OS_GETENV_PUTENV_UNSETENV
|
||||
@@ -223,7 +223,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&os_mbfs_remove_obj) },
|
||||
#endif
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
|
||||
static MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_os = {
|
||||
.base = { &mp_type_module },
|
||||
|
||||
Reference in New Issue
Block a user