FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / tr.c
bloba99b73684c545d10291a7fba58780242b5df092d
1 #include<stdio.h>
2 #include<stdlib.h>
3 #include<asm/types.h>
4 #include<stdint.h>
5 #include<string.h>
6 #include "table.h"
8 uint8_t buff[40];
10 void tr(uint8_t *codepage, uint8_t *addr, uint64_t len)
12 asm volatile(
13 " larl 1,1f\n"
14 "1: tr 0(1,%0),0(%2)\n"
15 " ex %1,0(1)"
16 : "+&a" (addr), "+a" (len)
17 : "a" (codepage) : "cc", "memory", "1");
20 void run_test(void *tran_table, void *srcaddr, uint64_t len)
22 int i;
24 tr(tran_table, buff, len);
25 printf("the translated string is ");
26 for (i = 0; i < len; i++) {
27 printf("%c", buff[i]);
29 printf("\n");
32 int main()
34 /* Test 1: length = 0 */
35 run_test((char *)&touppercase, &buff, 0);
36 run_test((char *)&touppercase, &buff, 0);
38 /* Test 2 : length > 0 */
39 memset(buff, 'a', 1);
40 run_test((char *)&touppercase, &buff, 1);
42 memcpy(buff, "abcdefgh", 8);
43 run_test((char *)&touppercase, &buff, 3);
44 run_test((char *)&touppercase, &buff, 3);
45 run_test((char *)&touppercase, &buff, 8);
47 memcpy(buff, "ABCDEFGH", 8);
48 run_test((char *)&tolowercase, &buff, 3);
49 run_test((char *)&tolowercase, &buff, 3);
50 run_test((char *)&tolowercase, &buff, 8);
52 memcpy(buff, "0123456789", 9);
53 run_test((char *)&touppercase, &buff, 9);
54 run_test((char *)&tolowercase, &buff, 9);
55 return 0;