mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-22 00:46:54 +00:00
fix(hal): Wrap LL macros with atomic env in do-while for control safety
- Standardize all LL macros using atomic env variables with `do { ... } while (0)` - Prevent potential macro misuse in control flow constructs (e.g., if/else) - Affected targets: esp32, esp32c2, esp32c5, esp32s3, esp32p4, etc. - Affected modules include: LCD, I2S, TIMER, and others
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -48,7 +48,10 @@ static inline void systimer_ll_enable_bus_clock(bool enable)
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
|
||||
#define systimer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; systimer_ll_enable_bus_clock(__VA_ARGS__)
|
||||
#define systimer_ll_enable_bus_clock(...) do { \
|
||||
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
|
||||
systimer_ll_enable_bus_clock(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Reset the systimer module
|
||||
@@ -63,7 +66,10 @@ static inline void systimer_ll_reset_register(void)
|
||||
|
||||
/// use a macro to wrap the function, force the caller to use it in a critical section
|
||||
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
|
||||
#define systimer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; systimer_ll_reset_register(__VA_ARGS__)
|
||||
#define systimer_ll_reset_register(...) do { \
|
||||
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
|
||||
systimer_ll_reset_register(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
/******************* Counter *************************/
|
||||
|
||||
|
Reference in New Issue
Block a user