refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h

Remove ~50 duplicate local definitions of ALIGN_UP/ALIGN_DOWN/ALIGN_UP_BY/
ALIGN_DOWN_BY across the codebase and replace them with canonical
ESP_ALIGN_UP/ESP_ALIGN_DOWN from esp_macros.h.
This commit is contained in:
morris
2026-07-06 13:36:06 +08:00
parent 2468defbff
commit 651d6a283f
66 changed files with 241 additions and 309 deletions
@@ -91,6 +91,20 @@ static inline __attribute__((always_inline, __noreturn__)) void esp_infinite_loo
}
#define ESP_INFINITE_LOOP() esp_infinite_loop()
/**
* @brief Round value up to a given alignment (must be a power of 2)
* @param val Value to align
* @param align Alignment value (must be a power of 2)
*/
#define ESP_ALIGN_UP(val, align) (((val) + ((align) - 1)) & ~((align) - 1))
/**
* @brief Round value down to a given alignment (must be a power of 2)
* @param val Value to align
* @param align Alignment value (must be a power of 2)
*/
#define ESP_ALIGN_DOWN(val, align) ((val) & ~((align) - 1))
#ifdef __cplusplus
}
#endif