OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [unsorted/] [udivmod4.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
long long
2
xlrandom ()
3
{
4
  long long x;
5
  unsigned a;
6
  int bits = 64;
7
  unsigned b;
8
 
9
  do
10
    {
11
      a = random ();
12
      b = (a & 15) + 1;
13
      x <<= b;                          /* shift up 1-16 steps */
14
      a = (a >> 18) & 1;
15
      if (a)
16
        x |= (unsigned) (1 << b) - 1;
17
      bits -= b;
18
    }
19
  while (bits >= 0);
20
  return x;
21
}
22
 
23
 
24
unsigned long long __udivmoddi4();
25
 
26
main ()
27
{
28
  int i;
29
  unsigned long long n, d, q, r, rr;
30
 
31
  for (i = 0; ;i++)
32
    {
33
      n = xlrandom ();
34
      d = xlrandom ();
35
      if (d == 0)
36
        continue;
37
 
38
      q = __udivmoddi4 (n, d, &r);
39
 
40
      if (i % 1000000 == 0)
41
        printf ("Testing udivmoddi4: %d iterations made\n", i);
42
 
43
      rr = n - q * d;
44
      if (rr != r || r >= d)
45
        {
46
          printf ("Testing udivmoddi4: failure after %d iterations\n", i);
47
          printf ("n=%lX%08lX\n", (unsigned) (n >> 32), (unsigned) n);
48
          printf ("d=%lX%08lX\n", (unsigned) (d >> 32), (unsigned) d);
49
          printf ("q=%lX%08lX\n", (unsigned) (q >> 32), (unsigned) q);
50
          printf ("r=%lX%08lX\n", (unsigned) (r >> 32), (unsigned) r);
51
          printf ("rr=%lX%08lX\n", (unsigned) (rr >> 32), (unsigned) rr);
52
          abort ();
53
        }
54
    }
55
 
56
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.