HW12/timerhelper.h
ubuntu201711081 f2e8bf2376 add comment
2020-12-14 10:19:49 +00:00

20 lines
429 B
C

#ifndef _TIMERHELPER_H_
#define _TIMERHELPER_H_
#include <sys/time.h>
#ifndef __always_inline
#define __always_inline
#endif
__always_inline struct timespec timespec_sub(struct timespec a,struct timespec b){
struct timespec ret;
ret.tv_sec = a.tv_sec - b.tv_sec;
ret.tv_nsec = a.tv_nsec - b.tv_nsec;
if (ret.tv_nsec < 0){
ret.tv_sec--;
ret.tv_nsec += 1000000000L;
}
return ret;
}
#endif