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:
Angus Gratton
2024-02-27 15:32:29 +11:00
committed by Damien George
parent b3f2f18f92
commit decf8e6a8b
482 changed files with 6287 additions and 6293 deletions

View File

@@ -41,30 +41,30 @@
#endif
// Command line options, with their defaults
STATIC uint emit_opt = MP_EMIT_OPT_NONE;
static uint emit_opt = MP_EMIT_OPT_NONE;
mp_uint_t mp_verbose_flag = 0;
// Heap size of GC heap (if enabled)
// Make it larger on a 64 bit machine, because pointers are larger.
long heap_size = 1024 * 1024 * (sizeof(mp_uint_t) / 4);
STATIC void stdout_print_strn(void *env, const char *str, size_t len) {
static void stdout_print_strn(void *env, const char *str, size_t len) {
(void)env;
ssize_t dummy = write(STDOUT_FILENO, str, len);
(void)dummy;
}
STATIC const mp_print_t mp_stdout_print = {NULL, stdout_print_strn};
static const mp_print_t mp_stdout_print = {NULL, stdout_print_strn};
STATIC void stderr_print_strn(void *env, const char *str, size_t len) {
static void stderr_print_strn(void *env, const char *str, size_t len) {
(void)env;
ssize_t dummy = write(STDERR_FILENO, str, len);
(void)dummy;
}
STATIC const mp_print_t mp_stderr_print = {NULL, stderr_print_strn};
static const mp_print_t mp_stderr_print = {NULL, stderr_print_strn};
STATIC int compile_and_save(const char *file, const char *output_file, const char *source_file) {
static int compile_and_save(const char *file, const char *output_file, const char *source_file) {
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
mp_lexer_t *lex;
@@ -117,7 +117,7 @@ STATIC int compile_and_save(const char *file, const char *output_file, const cha
}
}
STATIC int usage(char **argv) {
static int usage(char **argv) {
printf(
"usage: %s [<opts>] [-X <implopt>] [--] <input filename>\n"
"Options:\n"
@@ -155,7 +155,7 @@ STATIC int usage(char **argv) {
}
// Process options which set interpreter init options
STATIC void pre_process_options(int argc, char **argv) {
static void pre_process_options(int argc, char **argv) {
for (int a = 1; a < argc; a++) {
if (argv[a][0] == '-') {
if (strcmp(argv[a], "-X") == 0) {
@@ -201,7 +201,7 @@ STATIC void pre_process_options(int argc, char **argv) {
}
}
STATIC char *backslash_to_forwardslash(char *path) {
static char *backslash_to_forwardslash(char *path) {
for (char *p = path; p != NULL && *p != '\0'; ++p) {
if (*p == '\\') {
*p = '/';