arm: Support pac_key_* register operand for MRS/MSR in Armv8.1-M Mainline
[binutils-gdb.git] / gprofng / testsuite / lib / smalltest.c
blobfe6531e165108703dd1009ab48b89bb99c91eae4
1 #include <stdio.h>
2 #include <time.h>
4 typedef long long hrtime_t;
6 hrtime_t
7 gethrtime (void)
9 struct timespec tp;
10 hrtime_t rc = 0;
11 #ifdef CLOCK_MONOTONIC_RAW
12 int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
13 #else
14 int r = clock_gettime (CLOCK_MONOTONIC, &tp);
15 #endif
17 if (r == 0)
18 rc = ((hrtime_t) tp.tv_sec) * 1e9 + (hrtime_t) tp.tv_nsec;
19 return rc;
22 volatile long x; /* temp variable for long calculation */
24 int
25 main (int argc, char **argv)
27 long long count = 0;
28 hrtime_t start = gethrtime ();
32 x = 0;
33 for (int j = 0; j < 1000000; j++)
34 x = x + 1;
35 count++;
37 while (start + 2e9 > gethrtime ());
38 printf("count=%lld x=%lld\n", count, x);
39 return 0;