• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Test for gethrtime which either issues a classic syscall
2    or leverages fasttrap available on Solaris with tscp hwcap. */
3 
4 #include "config.h"
5 #include <stdio.h>
6 #include <sys/time.h>
7 #include <sys/trap.h>
8 
main(void)9 int main(void)
10 {
11    hrtime_t hrt = gethrtime();
12    if (hrt > 0)
13       printf("PASS\n");
14 
15 /* Exercise the fasttrap directly if available. When tscp hwcap
16    is not supported, it simply returns NULL. */
17 #if defined(SOLARIS_GETHRT_FASTTRAP)
18 #if defined(VGP_x86_solaris)
19    __asm__ ( \
20       "movl %[FASTTRAP],%%eax\n"
21       "int $0xd2\n"
22       :
23       : [FASTTRAP] "i" (T_GETHRT)
24       : "eax", "edx", "cc");
25 #elif defined(VGP_amd64_solaris)
26    __asm__ ( \
27       "movq %[FASTTRAP],%%rax\n"
28       "int $0xd2\n"
29       :
30       : [FASTTRAP] "i" (T_GETHRT)
31       : "rax", "rdx", "cc");
32 #else
33 #  error "Unknown platform"
34 #endif
35 #endif /* SOLARIS_GETHRT_FASTTRAP */
36 
37    return 0;
38 }
39 
40