Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / none / tests / ppc64 / power6_bcmp.c
blob6c16ec3b11ab681cb4fbd84f27bf5f18d2aa4eb0
1 /* Copyright (C) 2007 IBM
3 Author: Pete Eberlein eberlein@us.ibm.com
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>.
18 The GNU General Public License is contained in the file COPYING.
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <strings.h>
26 #define CMPB(result,a,b) \
27 asm ("cmpb %0, %1, %2\n" : "=r"(result) : "r"(a), "r"(b))
30 int main(int argc, char *argv[])
32 int i, j, k;
33 unsigned long mask;
34 for (i = 1; i < 256; i++) {
35 mask = 0;
36 if (i & 1)
37 mask += 0xff;
38 if (i & 2)
39 mask += 0xff00;
40 if (i & 4)
41 mask += 0xff0000;
42 if (i & 8)
43 mask += 0xff000000;
44 if (i & 16)
45 mask += 0xff00000000;
46 if (i & 32)
47 mask += 0xff0000000000;
48 if (i & 64)
49 mask += 0xff000000000000;
50 if (i & 128)
51 mask += 0xff00000000000000;
53 for (j = 0; j < 256; j++)
54 for (k = 0; k < 256; k++)
55 if (j != k) {
57 unsigned long a, b, result;
58 a = (mask & (j * 0x101010101010101)) +
59 ((~mask) & (k * 0x101010101010101));
60 b = j * 0x101010101010101;
61 CMPB(result, a, b);
62 if (result != mask) {
63 printf("%8lx %8lx %8lx %8lx\n", mask, a, b, result);
64 exit(1);
70 return 0;