HW12/timerhelper.h

20 lines
429 B
C
Raw Normal View History

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