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

@@ -31,7 +31,7 @@
// Workaround for setting file translation mode: we must distinguish toolsets
// since mingw has no _set_fmode, and altering msvc's _fmode directly has no effect
STATIC int set_fmode_impl(int mode) {
static int set_fmode_impl(int mode) {
#ifndef _MSC_VER
_fmode = mode;
return 0;

View File

@@ -38,14 +38,14 @@ HANDLE std_in = NULL;
HANDLE con_out = NULL;
DWORD orig_mode = 0;
STATIC void assure_stdin_handle() {
static void assure_stdin_handle() {
if (!std_in) {
std_in = GetStdHandle(STD_INPUT_HANDLE);
assert(std_in != INVALID_HANDLE_VALUE);
}
}
STATIC void assure_conout_handle() {
static void assure_conout_handle() {
if (!con_out) {
con_out = CreateFile("CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -143,7 +143,7 @@ typedef struct item_t {
} item_t;
// map virtual key codes to key sequences known by MicroPython's readline implementation
STATIC item_t keyCodeMap[] = {
static item_t keyCodeMap[] = {
{VK_UP, "[A"},
{VK_DOWN, "[B"},
{VK_RIGHT, "[C"},
@@ -155,7 +155,7 @@ STATIC item_t keyCodeMap[] = {
};
// likewise, but with Ctrl key down
STATIC item_t ctrlKeyCodeMap[] = {
static item_t ctrlKeyCodeMap[] = {
{VK_LEFT, "b"},
{VK_RIGHT, "f"},
{VK_DELETE, "d"},
@@ -163,9 +163,9 @@ STATIC item_t ctrlKeyCodeMap[] = {
{0, ""} // sentinel
};
STATIC const char *cur_esc_seq = NULL;
static const char *cur_esc_seq = NULL;
STATIC int esc_seq_process_vk(WORD vk, bool ctrl_key_down) {
static int esc_seq_process_vk(WORD vk, bool ctrl_key_down) {
for (item_t *p = (ctrl_key_down ? ctrlKeyCodeMap : keyCodeMap); p->vkey != 0; ++p) {
if (p->vkey == vk) {
cur_esc_seq = p->seq;
@@ -175,7 +175,7 @@ STATIC int esc_seq_process_vk(WORD vk, bool ctrl_key_down) {
return 0; // nothing found
}
STATIC int esc_seq_chr() {
static int esc_seq_chr() {
if (cur_esc_seq) {
const char c = *cur_esc_seq++;
if (c) {