summaryrefslogtreecommitdiff
path: root/gcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c
diff options
context:
space:
mode:
authorcamthesaxman <camthesaxman@users.noreply.github.com>2020-01-29 18:17:43 -0600
committercamthesaxman <camthesaxman@users.noreply.github.com>2020-01-29 18:17:43 -0600
commitcdc6e2c50f96119bdc4c1205ff5901ca82ec8357 (patch)
tree3e9217eabcf444e166008411f445315606dded59 /gcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c
parent27176890c4a688ea7de44d3f55af32827016a9fd (diff)
add old compiler with ARM support
Diffstat (limited to 'gcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c')
-rwxr-xr-xgcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c b/gcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c
new file mode 100755
index 0000000..40d2fa8
--- /dev/null
+++ b/gcc_arm/testsuite/gcc.c-torture/unsorted/udivmod4.c
@@ -0,0 +1,56 @@
+long long
+xlrandom ()
+{
+ long long x;
+ unsigned a;
+ int bits = 64;
+ unsigned b;
+
+ do
+ {
+ a = random ();
+ b = (a & 15) + 1;
+ x <<= b; /* shift up 1-16 steps */
+ a = (a >> 18) & 1;
+ if (a)
+ x |= (unsigned) (1 << b) - 1;
+ bits -= b;
+ }
+ while (bits >= 0);
+ return x;
+}
+
+
+unsigned long long __udivmoddi4();
+
+main ()
+{
+ int i;
+ unsigned long long n, d, q, r, rr;
+
+ for (i = 0; ;i++)
+ {
+ n = xlrandom ();
+ d = xlrandom ();
+ if (d == 0)
+ continue;
+
+ q = __udivmoddi4 (n, d, &r);
+
+ if (i % 1000000 == 0)
+ printf ("Testing udivmoddi4: %d iterations made\n", i);
+
+ rr = n - q * d;
+ if (rr != r || r >= d)
+ {
+ printf ("Testing udivmoddi4: failure after %d iterations\n", i);
+ printf ("n=%lX%08lX\n", (unsigned) (n >> 32), (unsigned) n);
+ printf ("d=%lX%08lX\n", (unsigned) (d >> 32), (unsigned) d);
+ printf ("q=%lX%08lX\n", (unsigned) (q >> 32), (unsigned) q);
+ printf ("r=%lX%08lX\n", (unsigned) (r >> 32), (unsigned) r);
+ printf ("rr=%lX%08lX\n", (unsigned) (rr >> 32), (unsigned) rr);
+ abort ();
+ }
+ }
+
+}