2 * Test 64x64 -> 128 multiply subroutines
4 * This work is licensed under the terms of the GNU LGPL, version 2 or later.
5 * See the COPYING.LIB file in the top-level directory.
9 #include "qemu/osdep.h"
11 #include "qemu/host-utils.h"
19 static const Test test_u_data[] = {
21 { 10000, 10000, 0, 100000000 },
22 { 0xffffffffffffffffULL, 2, 1, 0xfffffffffffffffeULL },
23 { 0xffffffffffffffffULL, 0xffffffffffffffffULL,
24 0xfffffffffffffffeULL, 0x0000000000000001ULL },
25 { 0x1122334455667788ull, 0x8877665544332211ull,
26 0x092228fb777ae38full, 0x0a3e963337c60008ull },
29 static const Test test_s_data[] = {
33 { 10000, 10000, 0, 100000000 },
35 { 0x1122334455667788ULL, 0x1122334455667788ULL,
36 0x01258f60bbc2975cULL, 0x1eace4a3c82fb840ULL },
39 static void test_u(void)
43 for (i = 0; i < ARRAY_SIZE(test_u_data); ++i) {
45 mulu64(&rl, &rh, test_u_data[i].a, test_u_data[i].b);
46 g_assert_cmpuint(rl, ==, test_u_data[i].rl);
47 g_assert_cmpuint(rh, ==, test_u_data[i].rh);
51 static void test_s(void)
55 for (i = 0; i < ARRAY_SIZE(test_s_data); ++i) {
57 muls64(&rl, &rh, test_s_data[i].a, test_s_data[i].b);
58 g_assert_cmpuint(rl, ==, test_s_data[i].rl);
59 g_assert_cmpint(rh, ==, test_s_data[i].rh);
63 int main(int argc, char **argv)
65 g_test_init(&argc, &argv, NULL);
66 g_test_add_func("/host-utils/mulu64", test_u);
67 g_test_add_func("/host-utils/muls64", test_s);