FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / ex.c
bloba25087bcb3a2811add0d4e57294b62bcf600e635
1 #include <stdio.h>
3 char buffer[] ="0123456789abcdef";
4 char target[] ="XXXXXXXXXXXXXXXX";
6 int main(void)
8 unsigned long offset;
10 setbuf(stdout, NULL);
12 printf("------- Copy 10+1 bytes from buffer to target\n");
13 printf("------- EX to OR in the length\n");
14 printf("before: buffer = |%s|\n", buffer);
15 printf("before: target = |%s|\n", target);
16 asm volatile( "larl 1, 1f\n\t"
17 "lghi 2, 10\n\t"
18 "ex 2, 0(1)\n\t"
19 "j 2f\n\t"
20 "1:\n\t"
21 "mvc 0(1,%0),0(%1)\n\t"
22 "2:\n\t"
23 : : "a" (target), "a" (buffer): "1", "2", "memory");
24 printf("after: buffer = |%s|\n", buffer);
25 printf("after: target = |%s|\n", target);
26 printf("\n");
28 printf("------- EX 0,... has no effect (writes out target)\n");
29 printf(" target = |");
30 asm volatile( "lghi 0, 0xff\n\t" // fill nonsense in r0
31 "larl 1, 1f\n\t"
32 "lghi 2, 1\n\t" // stdout
33 "lgr 3, %0\n\t" // target
34 "lghi 4, %1\n\t" // len
35 "ex 0, 0(1)\n\t"
36 "j 2f\n\t"
37 "1:\n\t"
38 "svc 4\n\t"
39 "2:\n\t"
40 : : "a" (target), "i" (sizeof target - 1)
41 : "0", "1", "2", "3", "4");
42 printf("|\n");
43 printf("\n");
45 printf("------- EX to OR in the syscall number (writes out target)\n");
46 printf(" target = |");
47 asm volatile( "lghi 5, 4\n\t" // NR_write
48 "larl 1, 1f\n\t"
49 "lghi 2, 1\n\t" // stdout
50 "lgr 3, %0\n\t" // target
51 "lghi 4, %1\n\t" // len
52 "ex 5, 0(1)\n\t"
53 "j 2f\n\t"
54 "1:\n\t"
55 "svc 0\n\t" // changed to NR_write
56 "2:\n\t"
57 : : "a" (target), "i" (sizeof target - 1)
58 : "1", "2", "3", "4", "5");
59 printf("|\n");
60 printf("\n");
62 printf("------- EX targeting a PC-relative instruction\n");
63 asm volatile( "1:\n\t"
64 "larl 1,1b\n\t"
65 "lgr 2,1\n\t"
66 "ex 0, 0(2)\n\t"
67 "sgrk %0,1,2\n\t"
68 : "=d" (offset) :
69 : "1", "2");
70 printf(" offset = |%016lx|\n", offset);
71 printf("\n");
73 printf("------- EX targeting a branch-and-link instruction\n");
74 asm volatile( "larl 1,1f\n\t"
75 "ex 0, 0(1)\n\t"
76 ".insn e,0x0000\n\t"
77 "1:\n\t"
78 "brasl 2,2f\n\t"
79 "2:\n\t"
80 "sgrk %0,1,2\n\t"
81 : "=&d" (offset) :
82 : "1", "2");
83 printf(" offset = |%016lx|\n", offset);
84 printf("\n");
86 return 0;