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:
@ -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__*/
|
||||
|
Reference in New Issue
Block a user