From 213a8f6a6d50a6c3333502b3cc38f92c6f4b74ad Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Tue, 17 Dec 2024 00:19:13 +0100 Subject: [PATCH] implementing endianness check on mlx_color struct --- includes/mlx.h | 17 ++++++++++++----- includes/mlx_profile.h | 6 +++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/includes/mlx.h b/includes/mlx.h index 21fc75a..adde595 100644 --- a/includes/mlx.h +++ b/includes/mlx.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */ -/* Updated: 2024/12/16 23:11:59 by maldavid ### ########.fr */ +/* Updated: 2024/12/17 00:15:34 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -48,10 +48,17 @@ typedef union mlx_color { struct { - uint8_t a; - uint8_t b; - uint8_t g; - uint8_t r; + #if MLX_ENDIAN_ORDER == MLX_LITTLE_ENDIAN + uint8_t a; + uint8_t b; + uint8_t g; + uint8_t r; + #else + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + #endif }; uint32_t rgba; } mlx_color; diff --git a/includes/mlx_profile.h b/includes/mlx_profile.h index d525c45..8f6431a 100644 --- a/includes/mlx_profile.h +++ b/includes/mlx_profile.h @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */ -/* Updated: 2024/12/16 16:16:07 by maldavid ### ########.fr */ +/* Updated: 2024/12/17 00:14:47 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -142,6 +142,10 @@ #endif #endif +#define MLX_LITTLE_ENDIAN 0x41424344UL +#define MLX_BIG_ENDIAN 0x44434241UL +#define MLX_ENDIAN_ORDER ('ABCD') + #include #define MLX_MAKE_VERSION(major, minor, patch) ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))