From 91f4860ae4ece05ec4d8e198d62d9486efa761db Mon Sep 17 00:00:00 2001 From: Ben van Werkhoven Date: Fri, 26 Apr 2024 09:33:26 +0200 Subject: [PATCH 1/2] __has_builtin to its own if, see issue #2 --- include/kernel_float/macros.h | 8 +++++--- single_include/kernel_float.h | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/kernel_float/macros.h b/include/kernel_float/macros.h index 689b6b2..d1eba68 100644 --- a/include/kernel_float/macros.h +++ b/include/kernel_float/macros.h @@ -50,9 +50,11 @@ #define KERNEL_FLOAT_CALL(F, ...) F(__VA_ARGS__) // TOOD: check if this way is support across all compilers -#if defined(__has_builtin) && __has_builtin(__builtin_assume_aligned) && 0 -#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ - static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) +#if defined(__has_builtin) + #if __has_builtin(__builtin_assume_aligned) && 0 + #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ + static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) + #endif #else #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR) #endif diff --git a/single_include/kernel_float.h b/single_include/kernel_float.h index b5f3c8a..b1d9c30 100644 --- a/single_include/kernel_float.h +++ b/single_include/kernel_float.h @@ -72,9 +72,11 @@ #define KERNEL_FLOAT_CALL(F, ...) F(__VA_ARGS__) // TOOD: check if this way is support across all compilers -#if defined(__has_builtin) && __has_builtin(__builtin_assume_aligned) && 0 -#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ - static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) +#if defined(__has_builtin) + #if __has_builtin(__builtin_assume_aligned) && 0 + #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ + static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) + #endif #else #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR) #endif From 522b6b4452f09678d124e477421a44fcc2037357 Mon Sep 17 00:00:00 2001 From: stijn Date: Fri, 26 Apr 2024 09:46:36 +0200 Subject: [PATCH 2/2] Fix missing `else` case for `if __has_builtin(__builtin_assume_aligned)` --- include/kernel_float/macros.h | 10 ++++++---- single_include/kernel_float.h | 14 ++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/kernel_float/macros.h b/include/kernel_float/macros.h index d1eba68..9c105bf 100644 --- a/include/kernel_float/macros.h +++ b/include/kernel_float/macros.h @@ -51,10 +51,12 @@ // TOOD: check if this way is support across all compilers #if defined(__has_builtin) - #if __has_builtin(__builtin_assume_aligned) && 0 - #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ - static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) - #endif +#if __has_builtin(__builtin_assume_aligned) +#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ + static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) +#else +#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR) +#endif #else #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR) #endif diff --git a/single_include/kernel_float.h b/single_include/kernel_float.h index b1d9c30..988e9e3 100644 --- a/single_include/kernel_float.h +++ b/single_include/kernel_float.h @@ -16,8 +16,8 @@ //================================================================================ // this file has been auto-generated, do not modify its contents! -// date: 2023-10-24 14:14:37.228322 -// git hash: 28f811af866d73bef37acd541bac6a95df9a94c3 +// date: 2024-04-26 09:45:38.335903 +// git hash: 91f4860ae4ece05ec4d8e198d62d9486efa761db //================================================================================ #ifndef KERNEL_FLOAT_MACROS_H @@ -73,10 +73,12 @@ // TOOD: check if this way is support across all compilers #if defined(__has_builtin) - #if __has_builtin(__builtin_assume_aligned) && 0 - #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ - static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) - #endif +#if __has_builtin(__builtin_assume_aligned) +#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \ + static_cast(__builtin_assume_aligned(static_cast(PTR), (ALIGNMENT))) +#else +#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR) +#endif #else #define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR) #endif