Home | History | Annotate | Download | only in s390x
      1 #include<stdio.h>
      2 #include<time.h>
      3 #include<stdlib.h>
      4 #include<unistd.h>
      5 
      6 int stck(unsigned long *addr)
      7 {
      8 	int cc;
      9 	asm volatile (	"stck	%0\n"
     10 			"ipm	%1\n"
     11 			"srl	%1,28\n"
     12 		      :"=Q" (*addr), "=d"(cc)::"memory", "cc");
     13 	return cc;
     14 }
     15 
     16 unsigned long clockticks_in_msec(unsigned long b, unsigned long a)
     17 {
     18 	return (b - a) / 4096000UL;
     19 }
     20 
     21 int main()
     22 {
     23 
     24 	int cc;
     25 	unsigned long start, end, diff;
     26 
     27 	cc = stck(&start);
     28 	if (cc)
     29 		printf("cc != 0!\n");
     30 	sleep(1);
     31 	cc = stck(&end);
     32 	if (cc)
     33 		printf("cc != 0!\n");
     34 	diff = clockticks_in_msec(end, start);
     35 	if (diff >= 1000 && diff < 1500)
     36 		printf("OK.....Testcase passed\n");
     37 	else
     38 		printf("FAILED.....Testcase failed\n");
     39 	return 0;
     40 
     41 }
     42