- struct timespec tp1, tp2, tpsleep;
- clock_gettime (CLOCK_REALTIME, &tp1);
- clock_gettime (CLOCK_REALTIME, &tp2);
- if ((tp1.tv_sec != tp2.tv_sec) || (tp1.tv_nsec != tp2.tv_nsec))
- printf("Error, two consecutive calls to gettimeofday did not return same time (with running power to 0)\n");
-
- //nanosleep for 100ns
- clock_gettime (CLOCK_REALTIME, &tp1);
- tpsleep.tv_sec=0;
- tpsleep.tv_nsec=100;
- nanosleep(&tpsleep, NULL);
- clock_gettime (CLOCK_REALTIME, &tp2);
- res = ((tp2.tv_sec * 1000000000 + tp2.tv_nsec)) - ((tp1.tv_sec * 1000000000 + tp1.tv_nsec));
- if (res <98 || res > 102)
- printf("Error, nanosleep did not really sleep 100ns, but %ld\n", res);
+ struct timespec tp1;
+ struct timespec tp2;
+ struct timespec tpsleep;
+ clock_gettime(CLOCK_REALTIME, &tp1);
+ clock_gettime(CLOCK_REALTIME, &tp2);
+ if ((tp1.tv_sec != tp2.tv_sec) || (tp1.tv_nsec != tp2.tv_nsec))
+ printf("Error, two consecutive calls to gettimeofday did not return same time (with running power to 0)\n");