summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2017-04-21 12:03:45 -0700
committerEric Anholt <eric@anholt.net>2017-04-25 15:01:23 -0700
commitfec9607c8e0a84dc86466c638d00b502f21ec622 (patch)
tree7cb4044697097d60eccb4f3ca2eedfb51815076d /test
parent4552238960fc05ff885bcabbc24d1489370fbd89 (diff)
Remove support for unaligned swaps.
The previous misc.h code went out of its way to allow swapping of unaligned pointers to values. However, the members of an X request/response are always naturally aligned within the struct, and the buffers containing a request/response will also be aligned to at least 8 bytes, so we can just drop it. text data bss dec hex filename before: 2215167 51552 132016 2398735 249a0f hw/xfree86/Xorg after: 2214919 51552 132016 2398487 249917 hw/xfree86/Xorg Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'test')
-rw-r--r--test/misc.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/test/misc.c b/test/misc.c
index c10a2b935..3c669b677 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -204,34 +204,21 @@ bswap_test(void)
uint16_t result_16;
uint32_t result_32;
uint64_t result_64;
- unsigned buffer[sizeof(test_64) + 4];
- void *unaligned = &buffer[1];
assert(bswap_16(test_16) == expect_16);
assert(bswap_32(test_32) == expect_32);
assert(bswap_64(test_64) == expect_64);
- /* Test the swapping-in-a-pointer functions, with unaligned
- * addresses (the functions shouldn't cause traps in that case).
- */
- for (int i = 0; i < 2; i++) {
- unaligned = buffer + i;
- if (((uintptr_t)unaligned & 1) == 1)
- break;
- }
- memcpy(unaligned, &test_16, sizeof(test_16));
- swaps((uint16_t *)unaligned);
- memcpy(&result_16, unaligned, sizeof(result_16));
+ result_16 = test_16;
+ swaps(&result_16);
assert(result_16 == expect_16);
- memcpy(unaligned, &test_32, sizeof(test_32));
- swapl((uint32_t *)unaligned);
- memcpy(&result_32, unaligned, sizeof(result_32));
+ result_32 = test_32;
+ swapl(&result_32);
assert(result_32 == expect_32);
- memcpy(unaligned, &test_64, sizeof(test_64));
- swapll((uint64_t *)unaligned);
- memcpy(&result_64, unaligned, sizeof(result_64));
+ result_64 = test_64;
+ swapll(&result_64);
assert(result_64 == expect_64);
}