diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2010-07-09 12:32:17 +0200 |
commit | 6c027b4de25a529908be895e7ff19236f4002a57 (patch) | |
tree | f70d3a400bbb9ba8a83e9d4ffcaa4b6e367fc8bb /timespec.h | |
download | crypto-6c027b4de25a529908be895e7ff19236f4002a57.zip crypto-6c027b4de25a529908be895e7ff19236f4002a57.tar.gz |
initial commit, resurrect one of my realy old projects
Diffstat (limited to 'timespec.h')
-rw-r--r-- | timespec.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/timespec.h b/timespec.h new file mode 100644 index 0000000..5c23e69 --- /dev/null +++ b/timespec.h @@ -0,0 +1,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 |