FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / stcke.c
blob8cd8e0d0b96c5dbfca70c5ba9688530553740c6a
1 #include <stdio.h>
2 #include<stdlib.h>
3 #include<unistd.h>
5 union stcke {
6 unsigned long buffer[2];
7 struct reader {
8 char pad;
9 unsigned long long time;
10 int time2;
11 short program;
12 } __attribute__ ((packed)) reader;
15 int stcke(unsigned long *addr)
18 int cc;
19 asm volatile ( "stcke %0\n"
20 "ipm %1\n"
21 "srl %1, 28\n"
22 :"+Q" (*addr), "=d"(cc)::"cc");
24 return cc;
27 unsigned long clockticks_in_msec(unsigned long b, unsigned long a)
29 return (b -a ) / 4096000UL;
32 int main()
34 union stcke start, end;
35 int cc;
37 cc = stcke(start.buffer);
38 if (cc)
39 printf("cc != 0!\n");
41 sleep(1);
42 cc = stcke(end.buffer);
43 if (cc)
44 printf("cc != 0!\n");
46 unsigned long c = clockticks_in_msec(end.reader.time,
47 start.reader.time);
49 if (c >= 1000 && c < 1500)
50 printf("OK.....Testcase passed\n");
51 else
52 printf("FAILED.....Testcase failed\n");
54 return 0;