diff options
author | Pablo MartÃnez <[email protected]> | 2025-05-22 15:31:15 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2025-05-22 23:31:15 +1000 |
commit | 955809bd5aee8b1444595b450eeeef1f42799995 (patch) | |
tree | 08da1f696605925286f681a2b738fa5f35cd0386 /platforms | |
parent | fa24b0fcce2c5f3330f2d798c3caf91a130babdb (diff) | |
download | qmk_firmware-955809bd5aee8b1444595b450eeeef1f42799995.tar.gz qmk_firmware-955809bd5aee8b1444595b450eeeef1f42799995.zip |
Add `compiler_support.h` (#25274)
Diffstat (limited to 'platforms')
-rw-r--r-- | platforms/atomic_util.h | 12 | ||||
-rw-r--r-- | platforms/avr/drivers/i2c_slave.h | 4 | ||||
-rw-r--r-- | platforms/avr/gpio.h | 6 | ||||
-rw-r--r-- | platforms/chibios/chibios_config.h | 4 | ||||
-rw-r--r-- | platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c | 6 |
5 files changed, 21 insertions, 11 deletions
diff --git a/platforms/atomic_util.h b/platforms/atomic_util.h index 21286d72eb..8e81eacdb8 100644 --- a/platforms/atomic_util.h +++ b/platforms/atomic_util.h @@ -15,17 +15,19 @@ */ #pragma once +#include "compiler_support.h" + // Macro to help make GPIO and other controls atomic. #ifndef IGNORE_ATOMIC_BLOCK # if __has_include_next("atomic_util.h") # include_next "atomic_util.h" /* Include the platforms atomic.h */ # else -# define ATOMIC_BLOCK _Static_assert(0, "ATOMIC_BLOCK not implemented") -# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented") -# define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON not implemented") -# define ATOMIC_FORCEON _Static_assert(0, "ATOMIC_FORCEON not implemented") -# define ATOMIC_RESTORESTATE _Static_assert(0, "ATOMIC_RESTORESTATE not implemented") +# define ATOMIC_BLOCK STATIC_ASSERT(0, "ATOMIC_BLOCK not implemented") +# define ATOMIC_BLOCK_RESTORESTATE STATIC_ASSERT(0, "ATOMIC_BLOCK_RESTORESTATE not implemented") +# define ATOMIC_BLOCK_FORCEON STATIC_ASSERT(0, "ATOMIC_BLOCK_FORCEON not implemented") +# define ATOMIC_FORCEON STATIC_ASSERT(0, "ATOMIC_FORCEON not implemented") +# define ATOMIC_RESTORESTATE STATIC_ASSERT(0, "ATOMIC_RESTORESTATE not implemented") # endif #else /* do nothing atomic macro */ # define ATOMIC_BLOCK(t) for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0) diff --git a/platforms/avr/drivers/i2c_slave.h b/platforms/avr/drivers/i2c_slave.h index 178b6a29df..8614bd865a 100644 --- a/platforms/avr/drivers/i2c_slave.h +++ b/platforms/avr/drivers/i2c_slave.h @@ -22,6 +22,8 @@ #pragma once +#include "compiler_support.h" + #ifndef I2C_SLAVE_REG_COUNT # if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) @@ -33,7 +35,7 @@ #endif // I2C_SLAVE_REG_COUNT -_Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); +STATIC_ASSERT(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; diff --git a/platforms/avr/gpio.h b/platforms/avr/gpio.h index 6f089bc663..4c09619772 100644 --- a/platforms/avr/gpio.h +++ b/platforms/avr/gpio.h @@ -16,6 +16,8 @@ #pragma once #include <avr/io.h> + +#include "compiler_support.h" #include "pin_defs.h" typedef uint8_t pin_t; @@ -24,9 +26,9 @@ typedef uint8_t pin_t; #define gpio_set_pin_input(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) #define gpio_set_pin_input_high(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) -#define gpio_set_pin_input_low(pin) _Static_assert(0, "GPIO pulldowns in input mode are not available on AVR") +#define gpio_set_pin_input_low(pin) STATIC_ASSERT(0, "GPIO pulldowns in input mode are not available on AVR") #define gpio_set_pin_output_push_pull(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF)) -#define gpio_set_pin_output_open_drain(pin) _Static_assert(0, "Open-drain outputs are not available on AVR") +#define gpio_set_pin_output_open_drain(pin) STATIC_ASSERT(0, "Open-drain outputs are not available on AVR") #define gpio_set_pin_output(pin) gpio_set_pin_output_push_pull(pin) #define gpio_write_pin_high(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index 9ef8e9b4fe..41546e3e50 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -15,6 +15,8 @@ */ #pragma once +#include "compiler_support.h" + #ifndef USB_VBUS_PIN # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used #endif @@ -26,7 +28,7 @@ # define REALTIME_COUNTER_CLOCK 1000000 # define USE_GPIOV1 -# define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible"); +# define PAL_OUTPUT_TYPE_OPENDRAIN STATIC_ASSERT(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible"); /* Aliases for GPIO PWM channels - every pin has at least one PWM channel * assigned */ diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c index 9bfc68f9d2..2f3c7c58ca 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c @@ -6,13 +6,15 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include <stdbool.h> + #include "pico/bootrom.h" #include "hardware/flash.h" #include "hardware/sync.h" #include "hardware/structs/ssi.h" #include "hardware/structs/ioqspi.h" -#include <stdbool.h> +#include "compiler_support.h" #include "timer.h" #include "wear_leveling.h" #include "wear_leveling_rp2040_flash_config.h" @@ -178,7 +180,7 @@ bool backing_store_erase(void) { #endif // Ensure the backing size can be cleanly subtracted from the flash size without alignment issues. - _Static_assert((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE"); + STATIC_ASSERT((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE"); interrupts = save_and_disable_interrupts(); flash_range_erase((WEAR_LEVELING_RP2040_FLASH_BASE), (WEAR_LEVELING_BACKING_SIZE)); |