blob: 5c23e69be6c9f5fa4a6a7882d1c5447bd2d5df58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#ifndef _TIMESPEC_H
#define _TIMESPEC_H
/*
* on my OpenBSD 3.5 CLOCK_ REALTIME and MONOTONIC work but not VIRTUAL and PROF
* on my slackware 10.0 nor MONOTONIC neither PROCESS_CPU_ID or THREAD_CPUTIME_ID work, only REALTIME is ok
*/
/* BSD compare macro */
#ifndef timespeccmp
#define timespeccmp(pt_a,pt_b,sign) ( ((pt_a)->tv_sec==(pt_b)->tv_sec) ? \
((pt_a)->tv_nsec sign (pt_b)->tv_nsec) : \
((pt_a)->tv_sec sign (pt_b)->tv_sec) )
#endif
/* compute macro */
#define timespec_compute(pt_a,pt_b) ((float)((pt_b)->tv_sec - (pt_a)->tv_sec) + \
((float)((pt_b)->tv_nsec - (pt_a)->tv_nsec))/1E9)
#endif
|