]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/none/tests/ppc64/power6_bcmp.c
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / none / tests / ppc64 / power6_bcmp.c
1 /*  Copyright (C) 2007 IBM
2
3     Author: Pete Eberlein  eberlein@us.ibm.com
4
5     This program is free software; you can redistribute it and/or
6     modify it under the terms of the GNU General Public License as
7     published by the Free Software Foundation; either version 2 of the
8     License, or (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful, but
11     WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18     02111-1307, USA.
19
20     The GNU General Public License is contained in the file COPYING.
21 */
22
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <strings.h>
27
28 #define CMPB(result,a,b) \
29     asm ("cmpb %0, %1, %2\n" : "=r"(result) : "r"(a), "r"(b))
30
31
32 int main(int argc, char *argv[])
33 {
34    int i, j, k;
35    unsigned long mask;
36    for (i = 1; i < 256; i++) {
37       mask = 0;
38       if (i & 1)
39          mask += 0xff;
40       if (i & 2)
41          mask += 0xff00;
42       if (i & 4)
43          mask += 0xff0000;
44       if (i & 8)
45          mask += 0xff000000;
46       if (i & 16)
47          mask += 0xff00000000;
48       if (i & 32)
49          mask += 0xff0000000000;
50       if (i & 64)
51          mask += 0xff000000000000;
52       if (i & 128)
53          mask += 0xff00000000000000;
54
55       for (j = 0; j < 256; j++)
56          for (k = 0; k < 256; k++)
57             if (j != k) {
58
59                unsigned long a, b, result;
60                a = (mask & (j * 0x101010101010101)) +
61                    ((~mask) & (k * 0x101010101010101));
62                b = j * 0x101010101010101;
63                CMPB(result, a, b);
64                if (result != mask) {
65                   printf("%8lx %8lx %8lx %8lx\n", mask, a, b, result);
66                   exit(1);
67                }
68             }
69
70    }
71
72    return 0;
73 }