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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [armnommu/] [lib/] [testm.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
char buffer[1036];
2
char buffer2[1036];
3
 
4
int main ()
5
{
6
        char *p;
7
        int i, o, o2, l;
8
 
9
        printf ("Testing memset\n");
10
        for (l = 1; l < 1020; l ++) {
11
                for (o = 0; o < 4; o++) {
12
                        p = buffer + o + 4;
13
                        for (i = 0; i < l + 12; i++)
14
                                buffer[i] = 0x55;
15
 
16
                        memset (p, 0xaa, l);
17
 
18
                        for (i = 0; i < l; i++)
19
                                if (p[i] != 0xaa)
20
                                        printf ("Error: %X+%d\n", p, i);
21
                        if (p[-1] != 0x55 || p[-2] != 0x55 || p[-3] != 0x55 || p[-4] != 0x55)
22
                                printf ("Error before %X\n", p);
23
                        if (p[l] != 0x55 || p[l+1] != 0x55 || p[l+2] != 0x55 || p[l+3] != 0x55)
24
                                printf ("Error at end: %p: %02X %02X %02X %02X\n", p+l, p[l], p[l+1], p[l+2], p[l+3]);
25
                }
26
        }
27
 
28
        printf ("Testing memcpy s > d\n");
29
        for (l = 1; l < 1020; l++) {
30
                for (o = 0; o < 4; o++) {
31
                        for (o2 = 0; o2 < 4; o2++) {
32
                                char *d, *s;
33
 
34
                                for (i = 0; i < l + 12; i++)
35
                                        buffer[i] = (i & 0x3f) + 0x40;
36
                                for (i = 0; i < 1036; i++)
37
                                        buffer2[i] = 0;
38
 
39
                                s = buffer + o;
40
                                d = buffer2 + o2 + 4;
41
 
42
                                memcpy (d, s, l);
43
 
44
                                for (i = 0; i < l; i++)
45
                                        if (s[i] != d[i])
46
                                                printf ("Error at %X+%d -> %X+%d (%02X != %02X)\n", s, i, d, i, s[i], d[i]);
47
                                if (d[-1] || d[-2] || d[-3] || d[-4])
48
                                        printf ("Error before %X\n", d);
49
                                if (d[l] || d[l+1] || d[l+2] || d[l+3])
50
                                        printf ("Error after %X\n", d+l);
51
                        }
52
                }
53
        }
54
 
55
        printf ("Testing memcpy s < d\n");
56
        for (l = 1; l < 1020; l++) {
57
                for (o = 0; o < 4; o++) {
58
                        for (o2 = 0; o2 < 4; o2++) {
59
                                char *d, *s;
60
 
61
                                for (i = 0; i < l + 12; i++)
62
                                        buffer2[i] = (i & 0x3f) + 0x40;
63
                                for (i = 0; i < 1036; i++)
64
                                        buffer[i] = 0;
65
 
66
                                s = buffer2 + o;
67
                                d = buffer + o2 + 4;
68
 
69
                                memcpy (d, s, l);
70
 
71
                                for (i = 0; i < l; i++)
72
                                        if (s[i] != d[i])
73
                                                printf ("Error at %X+%d -> %X+%d (%02X != %02X)\n", s, i, d, i, s[i], d[i]);
74
                                if (d[-1] || d[-2] || d[-3] || d[-4])
75
                                        printf ("Error before %X\n", d);
76
                                if (d[l] || d[l+1] || d[l+2] || d[l+3])
77
                                        printf ("Error after %X\n", d+l);
78
                        }
79
                }
80
        }
81
}

powered by: WebSVN 2.1.0

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