Add missing zstd.h to coregrind Makefile.am noinst_HEADERS
[valgrind.git] / memcheck / tests / s390x / vstrs.c
blob3354c2e538d2e392073c4ecdd1fb826a714ea64f
1 #include <stdio.h>
2 #include <string.h>
4 #define VECTOR __attribute__ ((vector_size (16)))
6 typedef char VECTOR char_v;
8 volatile char tmp;
9 static const char *hex_digit = "0123456789abcdefGHIJKLMNOPQRSTUV";
11 static char_v to_char_vec(const char *str)
13 char buf[17];
14 char_v v;
16 for (int i = 0; i < sizeof(buf); i++) {
17 char ch = str[i];
18 if (ch == '\0')
19 break;
20 else if (ch == '$')
21 buf[i] = '\0';
22 else if (ch != '~')
23 buf[i] = ch;
25 v = *(char_v *) buf;
26 return v;
29 static void test_vstrs_char(const char *haystack, const char *needle,
30 int expect_res, int expect_cc)
32 int cc;
33 char_v v2val = to_char_vec(haystack);
34 char_v v3val = to_char_vec(needle);
36 register unsigned long VECTOR v4 __asm__("v4") = { strlen(needle), 0 };
37 register char_v v1 __asm__("v1");
38 register char_v v2 __asm__("v2") = v2val;
39 register char_v v3 __asm__("v3") = v3val;
41 __asm__(
42 "cr 0,0\n\t" /* Clear CC */
43 ".short 0xe712,0x3020,0x408b\n\t" /* vstrs %v1,%v2,%v3,%v4,0,2 */
44 "ipm %[cc]\n\t"
45 "srl %[cc],28"
46 : "=v" (v1), [cc] "=d" (cc)
47 : "v" (v2), "v" (v3), "v" (v4)
48 : "cc");
50 tmp = hex_digit[v1[7] & 0x1f];
51 if (expect_res >= 0 && v1[7] != expect_res)
52 printf("result %u != %d\n", v1[7], expect_res);
54 tmp = hex_digit[cc & 0xf];
55 if (expect_cc >= 0 && cc != expect_cc)
56 printf("CC %d != %d\n", cc, expect_cc);
59 int main()
61 test_vstrs_char("haystack$needle", "needle$haystack", 16, 1);
62 test_vstrs_char("haystack, needle", "needle, haystack", 10, 3);
63 test_vstrs_char("ABCDEFGH", "DEFGHI", -1, -1);
64 test_vstrs_char("match in UNDEF", "UN", 9, 2);
65 test_vstrs_char("after ~ UNDEF", "DEF", -1, -1);
66 test_vstrs_char("", "", 0, 2);
67 return 0;