Add compiler_support.h
(#25274)
This commit is contained in:
parent
fa24b0fcce
commit
955809bd5a
36 changed files with 142 additions and 81 deletions
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "musical_notes.h"
|
||||
#include "song_list.h"
|
||||
#include "voices.h"
|
||||
|
@ -38,7 +40,7 @@ typedef union audio_config_t {
|
|||
};
|
||||
} audio_config_t;
|
||||
|
||||
_Static_assert(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec.");
|
||||
|
||||
/*
|
||||
* a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre
|
||||
|
|
|
@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
#ifndef BACKLIGHT_LEVELS
|
||||
# define BACKLIGHT_LEVELS 3
|
||||
#elif BACKLIGHT_LEVELS > 31
|
||||
|
@ -44,7 +46,7 @@ typedef union backlight_config_t {
|
|||
};
|
||||
} backlight_config_t;
|
||||
|
||||
_Static_assert(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec.");
|
||||
|
||||
void backlight_init(void);
|
||||
void backlight_toggle(void);
|
||||
|
|
15
quantum/compiler_support.h
Normal file
15
quantum/compiler_support.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2025 QMK Contributors
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
/**
|
||||
* @brief Perfom an assertion at compile time.
|
||||
*
|
||||
* `_Static_assert` is C<23, while `static_assert` is C++/C23.
|
||||
*/
|
||||
#if !defined(STATIC_ASSERT)
|
||||
# ifdef __cplusplus
|
||||
# define STATIC_ASSERT static_assert
|
||||
# else
|
||||
# define STATIC_ASSERT _Static_assert
|
||||
# endif
|
||||
#endif
|
|
@ -3,6 +3,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "util.h"
|
||||
|
||||
/**
|
||||
|
@ -29,7 +31,7 @@ typedef union connection_config_t {
|
|||
connection_host_t desired_host : 8;
|
||||
} PACKED connection_config_t;
|
||||
|
||||
_Static_assert(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec.");
|
||||
|
||||
/**
|
||||
* \brief Initialize the subsystem.
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
#ifndef HAPTIC_DEFAULT_FEEDBACK
|
||||
# define HAPTIC_DEFAULT_FEEDBACK 0
|
||||
#endif
|
||||
|
@ -42,7 +44,7 @@ typedef union haptic_config_t {
|
|||
};
|
||||
} haptic_config_t;
|
||||
|
||||
_Static_assert(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec.");
|
||||
|
||||
typedef enum HAPTIC_FEEDBACK {
|
||||
KEY_PRESS,
|
||||
|
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define _Static_assert static_assert
|
||||
#endif
|
||||
#include "compiler_support.h"
|
||||
|
||||
#include "eeconfig.h"
|
||||
#include "keycode.h"
|
||||
|
@ -47,6 +45,6 @@ typedef union keymap_config_t {
|
|||
};
|
||||
} keymap_config_t;
|
||||
|
||||
_Static_assert(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec.");
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
# include INTROSPECTION_KEYMAP_C
|
||||
#endif // INTROSPECTION_KEYMAP_C
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "keymap_introspection.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -30,9 +31,9 @@ __attribute__((weak)) uint8_t keymap_layer_count(void) {
|
|||
}
|
||||
|
||||
#ifdef DYNAMIC_KEYMAP_ENABLE
|
||||
_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT");
|
||||
STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT");
|
||||
#else
|
||||
_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
|
||||
STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
|
||||
#endif
|
||||
|
||||
uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) {
|
||||
|
@ -61,7 +62,7 @@ __attribute__((weak)) uint8_t encodermap_layer_count(void) {
|
|||
return encodermap_layer_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers");
|
||||
STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers");
|
||||
|
||||
uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) {
|
||||
if (layer_num < NUM_ENCODERMAP_LAYERS_RAW && encoder_idx < NUM_ENCODERS) {
|
||||
|
@ -106,7 +107,7 @@ __attribute__((weak)) uint16_t combo_count(void) {
|
|||
return combo_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?");
|
||||
STATIC_ASSERT(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?");
|
||||
|
||||
combo_t* combo_get_raw(uint16_t combo_idx) {
|
||||
if (combo_idx >= combo_count_raw()) {
|
||||
|
@ -133,7 +134,7 @@ __attribute__((weak)) uint16_t tap_dance_count(void) {
|
|||
return tap_dance_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?");
|
||||
STATIC_ASSERT(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?");
|
||||
|
||||
tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx) {
|
||||
if (tap_dance_idx >= tap_dance_count_raw()) {
|
||||
|
@ -161,7 +162,7 @@ __attribute__((weak)) uint16_t key_override_count(void) {
|
|||
return key_override_count_raw();
|
||||
}
|
||||
|
||||
_Static_assert(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?");
|
||||
STATIC_ASSERT(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?");
|
||||
|
||||
const key_override_t* key_override_get_raw(uint16_t key_override_idx) {
|
||||
if (key_override_idx >= key_override_count_raw()) {
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "util.h"
|
||||
|
||||
#if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES)
|
||||
|
@ -82,4 +84,4 @@ typedef union led_eeconfig_t {
|
|||
};
|
||||
} led_eeconfig_t;
|
||||
|
||||
_Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec.");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2024 Nick Brassel (@tzarc)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "keycodes.h"
|
||||
#include "eeprom.h"
|
||||
#include "dynamic_keymap.h"
|
||||
|
@ -25,10 +26,10 @@
|
|||
# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1)
|
||||
#endif
|
||||
|
||||
_Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver");
|
||||
STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver");
|
||||
|
||||
// Due to usage of uint16_t check for max 65535
|
||||
_Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536");
|
||||
STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536");
|
||||
|
||||
// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h,
|
||||
#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
|
||||
|
@ -56,7 +57,7 @@ _Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_M
|
|||
// The keyboard should override DYNAMIC_KEYMAP_LAYER_COUNT to reduce it,
|
||||
// or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has
|
||||
// more than the default.
|
||||
_Static_assert((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available.");
|
||||
STATIC_ASSERT((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available.");
|
||||
|
||||
#ifndef TOTAL_EEPROM_BYTE_COUNT
|
||||
# error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps.
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h> // offsetof
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "eeconfig.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -58,4 +60,4 @@ typedef struct PACKED {
|
|||
// Size of EEPROM being used, other code can refer to this for available EEPROM
|
||||
#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE))
|
||||
|
||||
_Static_assert((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect");
|
||||
STATIC_ASSERT((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect");
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "qp_stream.h"
|
||||
#include "qp_internal.h"
|
||||
#include "qgf.h"
|
||||
|
@ -36,7 +37,7 @@ typedef struct QP_PACKED qff_font_descriptor_v1_t {
|
|||
uint8_t transparency_index; // palette index used for transparent pixels (not yet implemented)
|
||||
} qff_font_descriptor_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF");
|
||||
STATIC_ASSERT(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF");
|
||||
|
||||
#define QFF_MAGIC 0x464651
|
||||
|
||||
|
@ -54,14 +55,14 @@ typedef struct QP_PACKED qff_ascii_glyph_v1_t {
|
|||
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
|
||||
} qff_ascii_glyph_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF");
|
||||
STATIC_ASSERT(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF");
|
||||
|
||||
typedef struct QP_PACKED qff_ascii_glyph_table_v1_t {
|
||||
qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 }
|
||||
qff_ascii_glyph_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E
|
||||
} qff_ascii_glyph_table_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + (95 * sizeof(qff_ascii_glyph_v1_t))), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF");
|
||||
STATIC_ASSERT(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + (95 * sizeof(qff_ascii_glyph_v1_t))), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF");
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Unicode glyph table descriptor
|
||||
|
@ -73,7 +74,7 @@ typedef struct QP_PACKED qff_unicode_glyph_v1_t {
|
|||
uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined
|
||||
} qff_unicode_glyph_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF");
|
||||
STATIC_ASSERT(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF");
|
||||
|
||||
typedef struct QP_PACKED qff_unicode_glyph_table_v1_t {
|
||||
qgf_block_header_v1_t header; // = { .type_id = 0x02, .neg_type_id = (~0x02), .length = (N * 6) }
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "qp_stream.h"
|
||||
#include "qp_internal.h"
|
||||
|
||||
|
@ -24,7 +25,7 @@ typedef struct QP_PACKED qgf_block_header_v1_t {
|
|||
uint32_t length : 24; // 24-bit blob length, allowing for block sizes of a maximum of 16MB.
|
||||
} qgf_block_header_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF");
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Graphics descriptor
|
||||
|
@ -42,7 +43,7 @@ typedef struct QP_PACKED qgf_graphics_descriptor_v1_t {
|
|||
uint16_t frame_count; // minimum of 1
|
||||
} qgf_graphics_descriptor_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF");
|
||||
|
||||
#define QGF_MAGIC 0x464751
|
||||
|
||||
|
@ -56,7 +57,7 @@ typedef struct QP_PACKED qgf_frame_offsets_v1_t {
|
|||
uint32_t offset[0]; // '0' signifies that this struct is immediately followed by the frame offsets
|
||||
} qgf_frame_offsets_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_frame_offsets_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_frame_offsets_v1_t must only contain qgf_block_header_v1_t in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_frame_offsets_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_frame_offsets_v1_t must only contain qgf_block_header_v1_t in v1 of QGF");
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Frame descriptor
|
||||
|
@ -72,7 +73,7 @@ typedef struct QP_PACKED qgf_frame_v1_t {
|
|||
uint16_t delay; // frame delay time for animations (in units of milliseconds)
|
||||
} qgf_frame_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF");
|
||||
|
||||
#define QGF_FRAME_FLAG_DELTA 0x02
|
||||
#define QGF_FRAME_FLAG_TRANSPARENT 0x01
|
||||
|
@ -88,14 +89,14 @@ typedef struct QP_PACKED qgf_palette_entry_v1_t {
|
|||
uint8_t v; // value component: `[0,1]` is mapped to `[0,255]` uint8_t.
|
||||
} qgf_palette_entry_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_palette_entry_v1_t) == 3, "Palette entry is not 3 bytes in size");
|
||||
STATIC_ASSERT(sizeof(qgf_palette_entry_v1_t) == 3, "Palette entry is not 3 bytes in size");
|
||||
|
||||
typedef struct QP_PACKED qgf_palette_v1_t {
|
||||
qgf_block_header_v1_t header; // = { .type_id = 0x03, .neg_type_id = (~0x03), .length = (N * 3 * sizeof(uint8_t)) }
|
||||
qgf_palette_entry_v1_t hsv[0]; // N * hsv, where N is the number of palette entries depending on the frame format in the descriptor
|
||||
} qgf_palette_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_palette_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_palette_v1_t must only contain qgf_block_header_v1_t in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_palette_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_palette_v1_t must only contain qgf_block_header_v1_t in v1 of QGF");
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Frame delta descriptor
|
||||
|
@ -110,7 +111,7 @@ typedef struct QP_PACKED qgf_delta_v1_t {
|
|||
uint16_t bottom; // The bottom pixel location to to draw the delta image
|
||||
} qgf_delta_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_delta_v1_t) == (sizeof(qgf_block_header_v1_t) + 8), "qgf_delta_v1_t must be 13 bytes in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_delta_v1_t) == (sizeof(qgf_block_header_v1_t) + 8), "qgf_delta_v1_t must be 13 bytes in v1 of QGF");
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Frame data descriptor
|
||||
|
@ -122,7 +123,7 @@ typedef struct QP_PACKED qgf_data_v1_t {
|
|||
uint8_t data[0]; // 0 signifies that this struct is immediately followed by the length of data specified in the header
|
||||
} qgf_data_v1_t;
|
||||
|
||||
_Static_assert(sizeof(qgf_data_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_data_v1_t must only contain qgf_block_header_v1_t in v1 of QGF");
|
||||
STATIC_ASSERT(sizeof(qgf_data_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_data_v1_t must only contain qgf_block_header_v1_t in v1 of QGF");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// QGF API
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
// Copyright 2021 Paul Cotter (@gr1mr3aver)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "qp_internal.h"
|
||||
#include "qp_comms.h"
|
||||
#include "qp_draw.h"
|
||||
#include "qgf.h"
|
||||
|
||||
_Static_assert((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE % 16) == 0, "QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE needs to be a non-zero multiple of 16");
|
||||
STATIC_ASSERT((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE % 16) == 0, "QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE needs to be a non-zero multiple of 16");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Global variables
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "qp_internal.h"
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Quantum Painter Core API: device registration
|
||||
|
||||
|
@ -67,7 +69,7 @@ static void qp_internal_display_timeout_task(void) {
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Quantum Painter Core API: qp_internal_task
|
||||
|
||||
_Static_assert((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999");
|
||||
STATIC_ASSERT((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999");
|
||||
|
||||
void qp_internal_task(void) {
|
||||
// Perform throttling of the internal processing of Quantum Painter
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "qp_internal.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -29,7 +30,7 @@ typedef union QP_PACKED qp_pixel_t {
|
|||
|
||||
uint32_t dummy;
|
||||
} qp_pixel_t;
|
||||
_Static_assert(sizeof(qp_pixel_t) == 4, "Invalid size for qp_pixel_t");
|
||||
STATIC_ASSERT(sizeof(qp_pixel_t) == 4, "Invalid size for qp_pixel_t");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Quantum Painter image format
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "color.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -84,4 +86,4 @@ typedef union rgb_config_t {
|
|||
};
|
||||
} rgb_config_t;
|
||||
|
||||
_Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec.");
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
// DEPRECATED DEFINES - DO NOT USE
|
||||
#if defined(RGBLED_NUM)
|
||||
# define RGBLIGHT_LED_COUNT RGBLED_NUM
|
||||
|
@ -260,7 +262,7 @@ typedef union rgblight_config_t {
|
|||
};
|
||||
} rgblight_config_t;
|
||||
|
||||
_Static_assert(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec.");
|
||||
|
||||
typedef struct _rgblight_status_t {
|
||||
uint8_t base_mode;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "split_util.h"
|
||||
#include "matrix.h"
|
||||
#include "keyboard.h"
|
||||
|
@ -62,7 +64,7 @@ static struct {
|
|||
} split_config;
|
||||
|
||||
#if defined(SPLIT_USB_DETECT)
|
||||
_Static_assert((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL.");
|
||||
STATIC_ASSERT((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL.");
|
||||
static bool usb_bus_detected(void) {
|
||||
for (uint16_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) {
|
||||
// This will return true if a USB connection has been established
|
||||
|
@ -88,9 +90,9 @@ static inline bool usb_bus_detected(void) {
|
|||
# endif
|
||||
# endif
|
||||
# if defined(SPLIT_USB_DETECT)
|
||||
_Static_assert(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT.");
|
||||
STATIC_ASSERT(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT.");
|
||||
# endif
|
||||
_Static_assert(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check.");
|
||||
STATIC_ASSERT(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check.");
|
||||
|
||||
static uint32_t split_watchdog_started = 0;
|
||||
static bool split_watchdog_done = false;
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "compiler_support.h"
|
||||
|
||||
enum serial_transaction_id {
|
||||
#ifdef USE_I2C
|
||||
I2C_EXECUTE_CALLBACK,
|
||||
|
@ -122,4 +124,4 @@ enum serial_transaction_id {
|
|||
};
|
||||
|
||||
// Ensure we only use 5 bits for transaction
|
||||
_Static_assert(NUM_TOTAL_TRANSACTIONS <= (1 << 5), "Max number of usable transactions exceeded");
|
||||
STATIC_ASSERT(NUM_TOTAL_TRANSACTIONS <= (1 << 5), "Max number of usable transactions exceeded");
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <string.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "transactions.h"
|
||||
#include "transport.h"
|
||||
#include "transaction_id_define.h"
|
||||
|
@ -36,7 +37,7 @@
|
|||
# include "i2c_slave.h"
|
||||
|
||||
// Ensure the I2C buffer has enough space
|
||||
_Static_assert(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shared_memory_t too large for I2C_SLAVE_REG_COUNT");
|
||||
STATIC_ASSERT(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shared_memory_t too large for I2C_SLAVE_REG_COUNT");
|
||||
|
||||
split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg;
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compiler_support.h"
|
||||
#include "unicode_keycodes.h"
|
||||
|
||||
/**
|
||||
|
@ -33,7 +35,7 @@ typedef union unicode_config_t {
|
|||
};
|
||||
} unicode_config_t;
|
||||
|
||||
_Static_assert(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec.");
|
||||
STATIC_ASSERT(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec.");
|
||||
|
||||
extern unicode_config_t unicode_config;
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define _Static_assert static_assert
|
||||
#endif
|
||||
#include "compiler_support.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
@ -62,9 +60,9 @@ typedef uint64_t backing_store_int_t;
|
|||
#endif // WEAR_LEVELING_ASSERTS
|
||||
|
||||
// Compile-time validation of configurable options
|
||||
_Static_assert(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size");
|
||||
_Static_assert(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size");
|
||||
_Static_assert(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size");
|
||||
STATIC_ASSERT(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size");
|
||||
STATIC_ASSERT(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size");
|
||||
STATIC_ASSERT(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size");
|
||||
|
||||
// Backing Store API, to be implemented elsewhere by flash driver etc.
|
||||
bool backing_store_init(void);
|
||||
|
@ -86,7 +84,7 @@ typedef union write_log_entry_t {
|
|||
uint8_t raw8[8];
|
||||
} write_log_entry_t;
|
||||
|
||||
_Static_assert(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8");
|
||||
STATIC_ASSERT(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8");
|
||||
|
||||
/**
|
||||
* Log entry type discriminator.
|
||||
|
@ -104,7 +102,7 @@ enum {
|
|||
LOG_ENTRY_TYPES
|
||||
};
|
||||
|
||||
_Static_assert(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage");
|
||||
STATIC_ASSERT(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage");
|
||||
|
||||
#define BITMASK_FOR_BITCOUNT(n) ((1 << (n)) - 1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue