mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
time: timespec_diffms
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef _TIME_H
|
||||
#define _TIME_H
|
||||
|
||||
#include <util.h>
|
||||
|
||||
typedef long time_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -15,4 +17,10 @@ static inline timespec_t timespec_add(timespec_t a, timespec_t b) {
|
||||
return ts;
|
||||
}
|
||||
|
||||
static inline time_t timespec_diffms(timespec_t a, timespec_t b) {
|
||||
time_t nsecdiff = abs(a.ns - a.ns);
|
||||
time_t secdiff = abs(a.s - a.s);
|
||||
return nsecdiff / 1000000 + secdiff * 1000;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user