8 static struct TestS test_s
[] = {
9 { 4, 2, 2, 0 }, /* normal cases */
11 { 0, 0, -1, 0 }, /* div by zero cases */
13 { LONG_MIN
, -1, LONG_MIN
, 0 }, /* overflow case */
17 unsigned long x
, y
, q
, r
;
20 static struct TestU test_u
[] = {
21 { 4, 2, 2, 0 }, /* normal cases */
23 { 0, 0, ULONG_MAX
, 0 }, /* div by zero cases */
24 { 9, 0, ULONG_MAX
, 9 },
27 #define ARRAY_SIZE(X) (sizeof(X) / sizeof(*(X)))
33 for (i
= 0; i
< ARRAY_SIZE(test_s
); i
++) {
36 asm("div %0, %2, %3\n\t"
39 : "r" (test_s
[i
].x
), "r" (test_s
[i
].y
));
41 assert(q
== test_s
[i
].q
);
42 assert(r
== test_s
[i
].r
);
45 for (i
= 0; i
< ARRAY_SIZE(test_u
); i
++) {
48 asm("divu %0, %2, %3\n\t"
51 : "r" (test_u
[i
].x
), "r" (test_u
[i
].y
));
53 assert(q
== test_u
[i
].q
);
54 assert(r
== test_u
[i
].r
);