1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
10 #include <rte_byteorder.h>
14 static volatile uint16_t u16 = 0x1337;
15 static volatile uint32_t u32 = 0xdeadbeefUL;
16 static volatile uint64_t u64 = 0xdeadcafebabefaceULL;
22 * - check that optimized byte swap functions are working for each
23 * size (16, 32, 64 bits)
33 res_u16 = rte_bswap16(u16);
34 printf("%"PRIx16" -> %"PRIx16"\n", u16, res_u16);
35 if (res_u16 != 0x3713)
38 res_u32 = rte_bswap32(u32);
39 printf("%"PRIx32" -> %"PRIx32"\n", u32, res_u32);
40 if (res_u32 != 0xefbeaddeUL)
43 res_u64 = rte_bswap64(u64);
44 printf("%"PRIx64" -> %"PRIx64"\n", u64, res_u64);
45 if (res_u64 != 0xcefabebafecaaddeULL)
48 res_u16 = rte_bswap16(0x1337);
49 printf("const %"PRIx16" -> %"PRIx16"\n", 0x1337, res_u16);
50 if (res_u16 != 0x3713)
53 res_u32 = rte_bswap32(0xdeadbeefUL);
54 printf("const %"PRIx32" -> %"PRIx32"\n", (uint32_t) 0xdeadbeef, res_u32);
55 if (res_u32 != 0xefbeaddeUL)
58 res_u64 = rte_bswap64(0xdeadcafebabefaceULL);
59 printf("const %"PRIx64" -> %"PRIx64"\n", (uint64_t) 0xdeadcafebabefaceULL, res_u64);
60 if (res_u64 != 0xcefabebafecaaddeULL)
66 REGISTER_TEST_COMMAND(byteorder_autotest, test_byteorder);