1 // RUN: %clang %s -Wl,-as-needed -o %t && %run %t 2 #include <time.h> 3 #include <unistd.h> 4 #include <assert.h> 5 cpu_ns()6long cpu_ns() { 7 clockid_t clk; 8 struct timespec ts; 9 int res = clock_getcpuclockid(getpid(), &clk); 10 assert(!res); 11 res = clock_gettime(clk, &ts); 12 assert(!res); 13 return ts.tv_nsec; 14 } 15 main()16int main() { 17 long cpuns = cpu_ns(); 18 asm volatile ("" :: "r"(cpuns)); 19 return 0; 20 } 21