Cygwin: clock.h: add valid_timespec() to check timespec for validity

Use throughout, drop local timespec_bad() in timer.cc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2019-01-18 14:31:01 +01:00
parent 7f983079d4
commit 397526dee8
6 changed files with 19 additions and 23 deletions

View File

@ -166,4 +166,12 @@ ts_diff (const struct timespec &ts0, struct timespec &ts1)
ts1.tv_sec -= ts0.tv_sec;
}
static inline bool
valid_timespec (const timespec& ts)
{
if (ts.tv_nsec < 0 || ts.tv_nsec >= NSPERSEC || ts.tv_sec < 0)
return false;
return true;
}
#endif /*__CLOCK_H__*/