16 lines
373 B
C
16 lines
373 B
C
#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 |