summaryrefslogtreecommitdiffstatshomepage
path: root/py/nativeglue.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/nativeglue.c
parentb3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff)
downloadmicropython-decf8e6a8bb940d5829ca3296790631fcece7b21.tar.gz
micropython-decf8e6a8bb940d5829ca3296790631fcece7b21.zip
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/nativeglue.c')
-rw-r--r--py/nativeglue.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/py/nativeglue.c b/py/nativeglue.c
index 074b1206ee..4cd090c0a2 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -139,7 +139,7 @@ mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
}
#endif
-STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
+static mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
if (new_globals == NULL) {
// Globals were the originally the same so don't restore them
return NULL;
@@ -155,20 +155,20 @@ STATIC mp_obj_dict_t *mp_native_swap_globals(mp_obj_dict_t *new_globals) {
// wrapper that accepts n_args and n_kw in one argument
// (native emitter can only pass at most 3 arguments to a function)
-STATIC mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) {
+static mp_obj_t mp_native_call_function_n_kw(mp_obj_t fun_in, size_t n_args_kw, const mp_obj_t *args) {
return mp_call_function_n_kw(fun_in, n_args_kw & 0xff, (n_args_kw >> 8) & 0xff, args);
}
// wrapper that makes raise obj and raises it
// END_FINALLY opcode requires that we don't raise if o==None
-STATIC void mp_native_raise(mp_obj_t o) {
+static void mp_native_raise(mp_obj_t o) {
if (o != MP_OBJ_NULL && o != mp_const_none) {
nlr_raise(mp_make_raise_obj(o));
}
}
// wrapper that handles iterator buffer
-STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
+static mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
if (iter == NULL) {
return mp_getiter(obj, NULL);
} else {
@@ -183,7 +183,7 @@ STATIC mp_obj_t mp_native_getiter(mp_obj_t obj, mp_obj_iter_buf_t *iter) {
}
// wrapper that handles iterator buffer
-STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
+static mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
mp_obj_t obj;
if (iter->base.type == MP_OBJ_NULL) {
obj = iter->buf[0];
@@ -193,7 +193,7 @@ STATIC mp_obj_t mp_native_iternext(mp_obj_iter_buf_t *iter) {
return mp_iternext(obj);
}
-STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
+static bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *ret_value) {
mp_vm_return_kind_t ret_kind;
nlr_buf_t nlr_buf;
mp_obj_t throw_value = *ret_value;
@@ -231,22 +231,22 @@ STATIC bool mp_native_yield_from(mp_obj_t gen, mp_obj_t send_value, mp_obj_t *re
#if !MICROPY_PY_BUILTINS_FLOAT
-STATIC mp_obj_t mp_obj_new_float_from_f(float f) {
+static mp_obj_t mp_obj_new_float_from_f(float f) {
(void)f;
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
}
-STATIC mp_obj_t mp_obj_new_float_from_d(double d) {
+static mp_obj_t mp_obj_new_float_from_d(double d) {
(void)d;
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
}
-STATIC float mp_obj_get_float_to_f(mp_obj_t o) {
+static float mp_obj_get_float_to_f(mp_obj_t o) {
(void)o;
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
}
-STATIC double mp_obj_get_float_to_d(mp_obj_t o) {
+static double mp_obj_get_float_to_d(mp_obj_t o) {
(void)o;
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("float unsupported"));
}