Skip to content

Commit

Permalink
__has_builtin to its own if, see issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
benvanwerkhoven committed Apr 26, 2024
1 parent 3f622bc commit 91f4860
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions include/kernel_float/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TYPE*>(__builtin_assume_aligned(static_cast<TYPE*>(PTR), (ALIGNMENT)))
#if defined(__has_builtin)
#if __has_builtin(__builtin_assume_aligned) && 0
#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \
static_cast<TYPE*>(__builtin_assume_aligned(static_cast<TYPE*>(PTR), (ALIGNMENT)))
#endif
#else
#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR)
#endif
Expand Down
8 changes: 5 additions & 3 deletions single_include/kernel_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TYPE*>(__builtin_assume_aligned(static_cast<TYPE*>(PTR), (ALIGNMENT)))
#if defined(__has_builtin)
#if __has_builtin(__builtin_assume_aligned) && 0
#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) \
static_cast<TYPE*>(__builtin_assume_aligned(static_cast<TYPE*>(PTR), (ALIGNMENT)))
#endif
#else
#define KERNEL_FLOAT_ASSUME_ALIGNED(TYPE, PTR, ALIGNMENT) (PTR)
#endif
Expand Down

0 comments on commit 91f4860

Please sign in to comment.