diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2025-01-02 08:53:44 +0000 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2025-01-02 08:53:44 +0000 |
commit | ae7f9696aefd6ce7b024af37c4d2c32f6783d106 (patch) | |
tree | d751c3402f9874663e30674ab59efb80be23bc28 /common/mem.h | |
parent | 16c0a3151e5fa4958711f64bbc2f172cfe781743 (diff) |
nvi: import version 2.2.1-52c07e8vendor/nvi/2.2.1-52c07e8vendor/nvi
Diffstat (limited to 'common/mem.h')
-rw-r--r-- | common/mem.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/mem.h b/common/mem.h index d24ec0b50b09..0c83b70dec2f 100644 --- a/common/mem.h +++ b/common/mem.h @@ -212,6 +212,18 @@ p2roundup(size_t n) return (n); } +/* + * is_aligned -- + * Determine whether the program can safely read an object with an + * alignment requirement from ptr. + * + * See also: https://clang.llvm.org/docs/LanguageExtensions.html#alignment-builtins + */ +static __inline int +is_aligned(void *ptr, size_t alignment) { + return ((uintptr_t)ptr % alignment) == 0; +} + /* Additional TAILQ helper. */ #define TAILQ_ENTRY_ISVALID(elm, field) \ ((elm)->field.tqe_prev != NULL) |