From 58a8318b8c150938b18edc8dbff1881c1abb4ec6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 20 Sep 2023 16:33:54 +1000 Subject: [PATCH] Move `PACKED` define to util.h (#22074) --- quantum/color.h | 15 +-------------- quantum/led_matrix/led_matrix_types.h | 15 +-------------- quantum/rgb_matrix/rgb_matrix_types.h | 15 +-------------- quantum/util.h | 4 ++++ 4 files changed, 7 insertions(+), 42 deletions(-) diff --git a/quantum/color.h b/quantum/color.h index a0414a291feb..00a3bfb3f849 100644 --- a/quantum/color.h +++ b/quantum/color.h @@ -18,6 +18,7 @@ #include #include +#include "util.h" // clang-format off @@ -73,16 +74,6 @@ // clang-format on -#if defined(__GNUC__) -# define PACKED __attribute__((__packed__)) -#else -# define PACKED -#endif - -#if defined(_MSC_VER) -# pragma pack(push, 1) -#endif - #define WS2812_BYTE_ORDER_RGB 0 #define WS2812_BYTE_ORDER_GRB 1 #define WS2812_BYTE_ORDER_BGR 2 @@ -118,10 +109,6 @@ typedef struct PACKED HSV { uint8_t v; } HSV; -#if defined(_MSC_VER) -# pragma pack(pop) -#endif - RGB hsv_to_rgb(HSV hsv); RGB hsv_to_rgb_nocie(HSV hsv); #ifdef RGBW diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 6709a558bb94..5a516ceb1028 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h @@ -18,16 +18,7 @@ #include #include - -#if defined(__GNUC__) -# define PACKED __attribute__((__packed__)) -#else -# define PACKED -#endif - -#if defined(_MSC_VER) -# pragma pack(push, 1) -#endif +#include "util.h" #if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES) # define LED_MATRIX_KEYREACTIVE_ENABLED @@ -92,7 +83,3 @@ typedef union { } led_eeconfig_t; _Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec."); - -#if defined(_MSC_VER) -# pragma pack(pop) -#endif diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h index 53ff7321b8df..0a3fd7cc0d11 100644 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ b/quantum/rgb_matrix/rgb_matrix_types.h @@ -19,16 +19,7 @@ #include #include #include "color.h" - -#if defined(__GNUC__) -# define PACKED __attribute__((__packed__)) -#else -# define PACKED -#endif - -#if defined(_MSC_VER) -# pragma pack(push, 1) -#endif +#include "util.h" #if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) # define RGB_MATRIX_KEYREACTIVE_ENABLED @@ -94,7 +85,3 @@ typedef union { } rgb_config_t; _Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec."); - -#if defined(_MSC_VER) -# pragma pack(pop) -#endif diff --git a/quantum/util.h b/quantum/util.h index 9c034cc404f7..21e3487b2828 100644 --- a/quantum/util.h +++ b/quantum/util.h @@ -46,3 +46,7 @@ */ # define ARRAY_SIZE(array) (__builtin_choose_expr(IS_ARRAY((array)), sizeof((array)) / sizeof((array)[0]), (void)0)) #endif + +#if !defined(PACKED) +# define PACKED __attribute__((__packed__)) +#endif