mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
time: timespec_add()
This commit is contained in:
@@ -8,4 +8,11 @@ typedef struct {
|
||||
time_t ns;
|
||||
} timespec_t;
|
||||
|
||||
static inline timespec_t timespec_add(timespec_t a, timespec_t b) {
|
||||
timespec_t ts;
|
||||
ts.ns = (a.ns + b.ns) % 1000000000;
|
||||
ts.s = a.s + b.s + (a.ns + b.ns) / 1000000000;
|
||||
return ts;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user