Change BIO_number_read and BIO_number_written() to be 64 bit
[openssl.git] / bugs / sgiccbug.c
1 /* NOCW */
2 /* sgibug.c */
3 /* bug found by Eric Young (eay@mincom.oz.au) May 95 */
4
5 #include <stdio.h>
6
7 /*
8  * This compiler bug it present on IRIX 5.3, 5.1 and 4.0.5 (these are the
9  * only versions of IRIX I have access to. defining FIXBUG removes the bug.
10  * (bug is still present in IRIX 6.3 according to Gage
11  * <agage@forgetmenot.Mines.EDU>
12  */
13
14 /*-
15  * Compare the output from
16  * cc sgiccbug.c; ./a.out
17  * and
18  * cc -O sgiccbug.c; ./a.out
19  */
20
21 static unsigned long a[4] =
22     { 0x01234567, 0x89ABCDEF, 0xFEDCBA98, 0x76543210 };
23 static unsigned long b[4] =
24     { 0x89ABCDEF, 0xFEDCBA98, 0x76543210, 0x01234567 };
25 static unsigned long c[4] =
26     { 0x77777778, 0x8ACF1357, 0x88888888, 0x7530ECA9 };
27
28 main()
29 {
30     unsigned long r[4];
31     sub(r, a, b);
32     fprintf(stderr, "input a= %08X %08X %08X %08X\n", a[3], a[2], a[1], a[0]);
33     fprintf(stderr, "input b= %08X %08X %08X %08X\n", b[3], b[2], b[1], b[0]);
34     fprintf(stderr, "output = %08X %08X %08X %08X\n", r[3], r[2], r[1], r[0]);
35     fprintf(stderr, "correct= %08X %08X %08X %08X\n", c[3], c[2], c[1], c[0]);
36 }
37
38 int sub(r, a, b)
39 unsigned long *r, *a, *b;
40 {
41     register unsigned long t1, t2, *ap, *bp, *rp;
42     int i, carry;
43 #ifdef FIXBUG
44     unsigned long dummy;
45 #endif
46
47     ap = a;
48     bp = b;
49     rp = r;
50     carry = 0;
51     for (i = 0; i < 4; i++) {
52         t1 = *(ap++);
53         t2 = *(bp++);
54         t1 = (t1 - t2);
55 #ifdef FIXBUG
56         dummy = t1;
57 #endif
58         *(rp++) = t1 & 0xffffffff;
59     }
60 }