Alignment instruction ZSTD_ALIGNED() in common/compiler.h

This commit is contained in:
Yann Collet
2025-01-15 17:11:27 -08:00
committed by Yann Collet
parent 2f3ee8b530
commit 8bff69af86
2 changed files with 15 additions and 12 deletions
+14 -1
View File
@@ -281,7 +281,7 @@
#endif
/*-**************************************************************
* Alignment check
* Alignment
*****************************************************************/
/* @return 1 if @u is a 2^n value, 0 otherwise
@@ -315,6 +315,19 @@ MEM_STATIC int ZSTD_isPower2(size_t u) {
# endif
#endif /* ZSTD_ALIGNOF */
#ifndef ZSTD_ALIGNED
/* C90-compatible alignment macro (GCC/Clang). Adjust for other compilers if needed. */
# if defined(__GNUC__)
# define ZSTD_ALIGNED(a) __attribute__((aligned(a)))
# elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
# define ZSTD_ALIGNED(a) alignas(a)
# else
/* this compiler will require its own alignment instruction */
# define ZSTD_ALIGNED(...)
# endif
#endif /* ZSTD_ALIGNED */
/*-**************************************************************
* Sanitizer
*****************************************************************/