]>
git.saurik.com Git - apple/xnu.git/blob - tests/os_unaligned.c
2 #include <darwintest.h>
3 #include <darwintest_utils.h>
5 #include "../libkern/os/ptrtools.h"
7 #define CHECK_ALIGNMENT(T) \
10 T_QUIET; T_EXPECT_EQ_ULONG(__alignof__(*__p), sizeof(*__p), #T " native alignment"); \
11 T_ASSERT_EQ_ULONG(__alignof__(os_unaligned_deref(__p)), 1UL, #T " alignment"); \
14 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
20 T_DECL(os_unaligned
, "Unaligned pointer access")
25 T_ASSERT_EQ_INT(os_unaligned_deref(p
), x
, "load");
26 os_unaligned_deref(&x
) = INT_MIN
;
27 T_ASSERT_EQ_INT(x
, INT_MIN
, "store");
29 CHECK_ALIGNMENT(unsigned);
30 CHECK_ALIGNMENT(long long);
31 CHECK_ALIGNMENT(uintptr_t);
32 CHECK_ALIGNMENT(int16_t);
33 CHECK_ALIGNMENT(uint64_t);
34 CHECK_ALIGNMENT(struct A
);
35 CHECK_ALIGNMENT(void *);