HW12/timerhelper.h

16 lines
373 B
C
Raw Normal View History

2020-12-07 00:26:59 +09:00
#ifndef _TIMERHELPER_H_
#define _TIMERHELPER_H_
#include <sys/time.h>
__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