6 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
7 #define cpu_to_be32(x) bswap_32(x)
8 #define be32_to_cpu(x) bswap_32(x)
9 #define be16_to_cpup(x) bswap_16(*x)
10 #define cpu_to_be64(x) bswap_64(x)
12 #define cpu_to_be32(x) (x)
13 #define be32_to_cpu(x) (x)
14 #define be16_to_cpup(x) (*x)
15 #define cpu_to_be64(x) (x)
22 long input[VPHN_REGISTER_COUNT];
23 u32 expected[VPHN_ASSOC_BUFSIZE];
40 "vphn: 1 x 16-bit value",
55 "vphn: 2 x 16-bit values",
71 "vphn: 3 x 16-bit values",
88 "vphn: 4 x 16-bit values",
106 /* Parsing the next 16-bit value out of the next 64-bit input
109 "vphn: 5 x 16-bit values",
128 /* Parse at most 6 x 64-bit input values */
129 "vphn: 24 x 16-bit values",
167 "vphn: 1 x 32-bit value",
182 "vphn: 2 x 32-bit values",
198 /* Parsing the next 32-bit value out of the next 64-bit input
201 "vphn: 3 x 32-bit values",
218 /* Parse at most 6 x 64-bit input values */
219 "vphn: 12 x 32-bit values",
245 "vphn: 16-bit value followed by 32-bit value",
261 "vphn: 32-bit value followed by 16-bit value",
277 /* Parse a 32-bit value split accross two consecutives 64-bit
280 "vphn: 16-bit value followed by 2 x 32-bit values",
299 /* The lower bits in 0x0001ffff don't get mixed up with the
302 "vphn: 32-bit value has all ones in 16 lower bits",
319 /* The following input doesn't follow the specification.
321 "vphn: last 32-bit value is truncated",
347 "vphn: garbage after terminator",
365 static int test_one(struct test *test)
367 __be32 output[VPHN_ASSOC_BUFSIZE] = { 0 };
370 vphn_unpack_associativity(test->input, output);
372 len = be32_to_cpu(output[0]);
373 if (len != test->expected[0]) {
374 printf("expected %d elements, got %d\n", test->expected[0],
379 for (i = 1; i < len; i++) {
380 u32 val = be32_to_cpu(output[i]);
381 if (val != test->expected[i]) {
382 printf("element #%d is 0x%x, should be 0x%x\n", i, val,
391 static int test_vphn(void)
393 static struct test *test;
395 for (test = all_tests; test->descr; test++) {
398 ret = test_one(test);
399 test_finish(test->descr, ret);
407 int main(int argc, char **argv)
409 return test_harness(test_vphn, "test-vphn");