From a65b1a76acb1e75a94e3b0a1e5948b33209fb10c Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Tue, 21 May 2019 14:37:02 +0300 Subject: [PATCH] wait_ns micro-optimisation Use `+ 1` to set the "Thumb" indicator on the `delay_loop` routine address, rather than `| 1`. That makes it something that can be done by the linker, rather than needing to be done at run-time. Saves one instruction and one cycle. --- platform/mbed_wait_api_no_rtos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mbed_wait_api_no_rtos.c b/platform/mbed_wait_api_no_rtos.c index e0c32f448d..a972b063d0 100644 --- a/platform/mbed_wait_api_no_rtos.c +++ b/platform/mbed_wait_api_no_rtos.c @@ -142,7 +142,7 @@ static const uint16_t delay_loop_code[] = { }; /* Take the address of the code, set LSB to indicate Thumb, and cast to void() function pointer */ -#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code | 1)) +#define delay_loop ((void(*)()) ((uintptr_t) delay_loop_code + 1)) /* Some targets may not provide zero-wait-state flash performance. Export this function * to be overridable for targets to provide more accurate implementation like locating