FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / spechelper-algr.c
blob441b6ef63f2d36509968d7d7ae472b22d0cc7522
1 #include <stdio.h>
3 #define branch(mask,_v1,_v2) \
4 ({ \
5 unsigned char taken; \
6 unsigned long b1 = _v1; \
7 unsigned long b2 = _v2; \
8 asm volatile( " algr %[b1],%[b2]\n\t" \
9 " brc " #mask " ,1f\n\t" \
10 " mvi %[taken],0\n\t" \
11 " j 0f\n\t" \
12 "1: mvi %[taken],1\n\t" \
13 "0: bcr 0,0 /* nop */\n\t" \
14 : [taken] "=Q" (taken), [b1] "+d"(b1) \
15 : [b2] "d"(b2) \
16 : "cc"); \
17 taken; \
21 void
22 algr_cc_0(void)
24 unsigned long v1, v2;
25 int wrong, ok;
27 printf("Test #1 cc == 0\n");
29 v1 = v2 = 0;
30 wrong = ok = 0;
31 if (branch(0, v1, v2)) ++wrong; else ++ok;
32 if (branch(1, v1, v2)) ++wrong; else ++ok;
33 if (branch(2, v1, v2)) ++wrong; else ++ok;
34 if (branch(3, v1, v2)) ++wrong; else ++ok;
35 if (branch(4, v1, v2)) ++wrong; else ++ok;
36 if (branch(5, v1, v2)) ++wrong; else ++ok;
37 if (branch(6, v1, v2)) ++wrong; else ++ok;
38 if (branch(7, v1, v2)) ++wrong; else ++ok;
39 if (branch(8, v1, v2)) ++ok; else ++wrong;
40 if (branch(9, v1, v2)) ++ok; else ++wrong;
41 if (branch(10, v1, v2)) ++ok; else ++wrong;
42 if (branch(11, v1, v2)) ++ok; else ++wrong;
43 if (branch(12, v1, v2)) ++ok; else ++wrong;
44 if (branch(13, v1, v2)) ++ok; else ++wrong;
45 if (branch(14, v1, v2)) ++ok; else ++wrong;
46 if (branch(15, v1, v2)) ++ok; else ++wrong;
48 if (wrong != 0 || ok != 16)
49 printf("FAILED\n");
50 else
51 printf("OK\n");
54 void
55 algr_cc_1(void)
57 unsigned long v1, v2;
58 int wrong, ok;
60 printf("Test #2 cc == 1\n");
62 v1 = v2 = 42;
63 wrong = ok = 0;
65 if (branch(0, v1, v2)) ++wrong; else ++ok;
66 if (branch(1, v1, v2)) ++wrong; else ++ok;
67 if (branch(2, v1, v2)) ++wrong; else ++ok;
68 if (branch(3, v1, v2)) ++wrong; else ++ok;
69 if (branch(4, v1, v2)) ++ok; else ++wrong;
70 if (branch(5, v1, v2)) ++ok; else ++wrong;
71 if (branch(6, v1, v2)) ++ok; else ++wrong;
72 if (branch(7, v1, v2)) ++ok; else ++wrong;
73 if (branch(8, v1, v2)) ++wrong; else ++ok;
74 if (branch(9, v1, v2)) ++wrong; else ++ok;
75 if (branch(10, v1, v2)) ++wrong; else ++ok;
76 if (branch(11, v1, v2)) ++wrong; else ++ok;
77 if (branch(12, v1, v2)) ++ok; else ++wrong;
78 if (branch(13, v1, v2)) ++ok; else ++wrong;
79 if (branch(14, v1, v2)) ++ok; else ++wrong;
80 if (branch(15, v1, v2)) ++ok; else ++wrong;
82 if (wrong != 0 || ok != 16)
83 printf("FAILED\n");
84 else
85 printf("OK\n");
88 void
89 algr_cc_2(void)
91 unsigned long v1, v2;
92 int wrong, ok;
94 printf("Test #3 cc == 2\n");
96 v1 = ~0ULL;
97 v2 = 1;
99 wrong = ok = 0;
101 if (branch(0, v1, v2)) ++wrong; else ++ok;
102 if (branch(1, v1, v2)) ++wrong; else ++ok;
103 if (branch(2, v1, v2)) ++ok; else ++wrong;
104 if (branch(3, v1, v2)) ++ok; else ++wrong;
105 if (branch(4, v1, v2)) ++wrong; else ++ok;
106 if (branch(5, v1, v2)) ++wrong; else ++ok;
107 if (branch(6, v1, v2)) ++ok; else ++wrong;
108 if (branch(7, v1, v2)) ++ok; else ++wrong;
109 if (branch(8, v1, v2)) ++wrong; else ++ok;
110 if (branch(9, v1, v2)) ++wrong; else ++ok;
111 if (branch(10, v1, v2)) ++ok; else ++wrong;
112 if (branch(11, v1, v2)) ++ok; else ++wrong;
113 if (branch(12, v1, v2)) ++wrong; else ++ok;
114 if (branch(13, v1, v2)) ++wrong; else ++ok;
115 if (branch(14, v1, v2)) ++ok; else ++wrong;
116 if (branch(15, v1, v2)) ++ok; else ++wrong;
118 if (wrong != 0 /* || ok != 16 */)
119 printf("FAILED\n");
120 else
121 printf("OK\n");
124 void
125 algr_cc_3(void)
127 unsigned long v1, v2;
128 int wrong, ok;
130 printf("Test #4 cc == 3\n");
132 v1 = ~0ULL;
133 v2 = 100;
135 wrong = ok = 0;
137 if (branch(0, v1, v2)) ++wrong; else ++ok;
138 if (branch(1, v1, v2)) ++ok; else ++wrong;
139 if (branch(2, v1, v2)) ++wrong; else ++ok;
140 if (branch(3, v1, v2)) ++ok; else ++wrong;
141 if (branch(4, v1, v2)) ++wrong; else ++ok;
142 if (branch(5, v1, v2)) ++ok; else ++wrong;
143 if (branch(6, v1, v2)) ++wrong; else ++ok;
144 if (branch(7, v1, v2)) ++ok; else ++wrong;
145 if (branch(8, v1, v2)) ++wrong; else ++ok;
146 if (branch(9, v1, v2)) ++ok; else ++wrong;
147 if (branch(10, v1, v2)) ++wrong; else ++ok;
148 if (branch(11, v1, v2)) ++ok; else ++wrong;
149 if (branch(12, v1, v2)) ++wrong; else ++ok;
150 if (branch(13, v1, v2)) ++ok; else ++wrong;
151 if (branch(14, v1, v2)) ++wrong; else ++ok;
152 if (branch(15, v1, v2)) ++ok; else ++wrong;
154 if (wrong != 0 || ok != 16)
155 printf("FAILED\n");
156 else
157 printf("OK\n");
160 int main()
162 algr_cc_0();
163 algr_cc_1();
164 algr_cc_2();
165 algr_cc_3();
167 return 0;