diff options
author | Angus Gratton <angus@redyak.com.au> | 2024-02-27 15:32:29 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-03-07 14:20:42 +1100 |
commit | decf8e6a8bb940d5829ca3296790631fcece7b21 (patch) | |
tree | 55b7cd31de14b73e4b72d49344e9084f402767a9 /extmod/btstack/btstack_hci_uart.c | |
parent | b3f2f18f927fa2fad10daf63d8c391331f5edf58 (diff) | |
download | micropython-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 'extmod/btstack/btstack_hci_uart.c')
-rw-r--r-- | extmod/btstack/btstack_hci_uart.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/extmod/btstack/btstack_hci_uart.c b/extmod/btstack/btstack_hci_uart.c index 19cdfc4b9d..fb90f550cb 100644 --- a/extmod/btstack/btstack_hci_uart.c +++ b/extmod/btstack/btstack_hci_uart.c @@ -48,17 +48,17 @@ // interface to an HCI UART provided by the port. // We pass the bytes directly to the UART during a send, but then notify btstack in the next poll. -STATIC bool send_done; -STATIC void (*send_handler)(void); +static bool send_done; +static void (*send_handler)(void); // btstack issues a read of len bytes, and gives us a buffer to asynchronously fill up. -STATIC uint8_t *recv_buf; -STATIC size_t recv_len; -STATIC size_t recv_idx; -STATIC void (*recv_handler)(void); -STATIC bool init_success = false; +static uint8_t *recv_buf; +static size_t recv_len; +static size_t recv_idx; +static void (*recv_handler)(void); +static bool init_success = false; -STATIC int btstack_uart_init(const btstack_uart_config_t *uart_config) { +static int btstack_uart_init(const btstack_uart_config_t *uart_config) { (void)uart_config; send_done = false; @@ -81,45 +81,45 @@ STATIC int btstack_uart_init(const btstack_uart_config_t *uart_config) { return 0; } -STATIC int btstack_uart_open(void) { +static int btstack_uart_open(void) { return init_success ? 0 : 1; } -STATIC int btstack_uart_close(void) { +static int btstack_uart_close(void) { mp_bluetooth_hci_controller_deinit(); mp_bluetooth_hci_uart_deinit(); return 0; } -STATIC void btstack_uart_set_block_received(void (*block_handler)(void)) { +static void btstack_uart_set_block_received(void (*block_handler)(void)) { recv_handler = block_handler; } -STATIC void btstack_uart_set_block_sent(void (*block_handler)(void)) { +static void btstack_uart_set_block_sent(void (*block_handler)(void)) { send_handler = block_handler; } -STATIC int btstack_uart_set_baudrate(uint32_t baudrate) { +static int btstack_uart_set_baudrate(uint32_t baudrate) { mp_bluetooth_hci_uart_set_baudrate(baudrate); return 0; } -STATIC int btstack_uart_set_parity(int parity) { +static int btstack_uart_set_parity(int parity) { (void)parity; return 0; } -STATIC int btstack_uart_set_flowcontrol(int flowcontrol) { +static int btstack_uart_set_flowcontrol(int flowcontrol) { (void)flowcontrol; return 0; } -STATIC void btstack_uart_receive_block(uint8_t *buf, uint16_t len) { +static void btstack_uart_receive_block(uint8_t *buf, uint16_t len) { recv_buf = buf; recv_len = len; } -STATIC void btstack_uart_send_block(const uint8_t *buf, uint16_t len) { +static void btstack_uart_send_block(const uint8_t *buf, uint16_t len) { #if HCI_TRACE printf(COL_GREEN "< [% 8d] %02x", (int)mp_hal_ticks_ms(), buf[0]); for (size_t i = 1; i < len; ++i) { @@ -136,16 +136,16 @@ STATIC void btstack_uart_send_block(const uint8_t *buf, uint16_t len) { mp_bluetooth_hci_poll_now(); } -STATIC int btstack_uart_get_supported_sleep_modes(void) { +static int btstack_uart_get_supported_sleep_modes(void) { return 0; } -STATIC void btstack_uart_set_sleep(btstack_uart_sleep_mode_t sleep_mode) { +static void btstack_uart_set_sleep(btstack_uart_sleep_mode_t sleep_mode) { (void)sleep_mode; // printf("btstack_uart_set_sleep %u\n", sleep_mode); } -STATIC void btstack_uart_set_wakeup_handler(void (*wakeup_handler)(void)) { +static void btstack_uart_set_wakeup_handler(void (*wakeup_handler)(void)) { (void)wakeup_handler; // printf("btstack_uart_set_wakeup_handler\n"); } |