]> git.proxmox.com Git - qemu.git/blame - tests/test-mul64.c
target-openrisc: Remove executable flag for every page
[qemu.git] / tests / test-mul64.c
CommitLineData
f4c0f986
RH
1/*
2 * Test 64x64 -> 128 multiply subroutines
3 *
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.
6 *
7 */
8
9#include <glib.h>
10#include <stdint.h>
11#include "qemu/host-utils.h"
12#include "qemu/osdep.h"
13
14
15typedef struct {
16 uint64_t a, b;
17 uint64_t rh, rl;
18} Test;
19
20static const Test test_u_data[] = {
21 { 1, 1, 0, 1 },
22 { 10000, 10000, 0, 100000000 },
23 { 0xffffffffffffffffULL, 2, 1, 0xfffffffffffffffeULL },
24 { 0xffffffffffffffffULL, 0xffffffffffffffffULL,
25 0xfffffffffffffffeULL, 0x0000000000000001ULL },
26 { 0x1122334455667788ull, 0x8877665544332211ull,
27 0x092228fb777ae38full, 0x0a3e963337c60008ull },
28};
29
30static const Test test_s_data[] = {
31 { 1, 1, 0, 1 },
32 { 1, -1, -1, -1 },
33 { -10, -10, 0, 100 },
34 { 10000, 10000, 0, 100000000 },
35 { -1, 2, -1, -2 },
36 { 0x1122334455667788ULL, 0x1122334455667788ULL,
37 0x01258f60bbc2975cULL, 0x1eace4a3c82fb840ULL },
38};
39
40static void test_u(void)
41{
42 int i;
43
44 for (i = 0; i < ARRAY_SIZE(test_u_data); ++i) {
45 uint64_t rl, rh;
46 mulu64(&rl, &rh, test_u_data[i].a, test_u_data[i].b);
47 g_assert_cmpuint(rl, ==, test_u_data[i].rl);
48 g_assert_cmpuint(rh, ==, test_u_data[i].rh);
49 }
50}
51
52static void test_s(void)
53{
54 int i;
55
56 for (i = 0; i < ARRAY_SIZE(test_s_data); ++i) {
57 uint64_t rl, rh;
58 muls64(&rl, &rh, test_s_data[i].a, test_s_data[i].b);
59 g_assert_cmpuint(rl, ==, test_s_data[i].rl);
60 g_assert_cmpint(rh, ==, test_s_data[i].rh);
61 }
62}
63
64int main(int argc, char **argv)
65{
66 g_test_init(&argc, &argv, NULL);
67 g_test_add_func("/host-utils/mulu64", test_u);
68 g_test_add_func("/host-utils/muls64", test_s);
69 return g_test_run();
70}