diff options
| -rw-r--r-- | sys/sys/time.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/sys/time.h b/sys/sys/time.h index d3a19ebfc811..707565b6a6f1 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -352,6 +352,16 @@ tstosbt(struct timespec _ts) return (((sbintime_t)_ts.tv_sec << 32) + nstosbt(_ts.tv_nsec)); } +static __inline sbintime_t +tstosbt_sat(struct timespec _ts) +{ + if (_ts.tv_sec > SBT_MAX >> 32) + return (SBT_MAX); + if (_ts.tv_sec < -(SBT_MAX >> 32) - 1) + return (-SBT_MAX - 1); + return (tstosbt(_ts)); +} + static __inline struct timeval sbttotv(sbintime_t _sbt) { @@ -368,6 +378,17 @@ tvtosbt(struct timeval _tv) return (((sbintime_t)_tv.tv_sec << 32) + ustosbt(_tv.tv_usec)); } + +static __inline sbintime_t +tvtosbt_sat(struct timeval _tv) +{ + if (_tv.tv_sec > SBT_MAX >> 32) + return (SBT_MAX); + if (_tv.tv_sec < -(SBT_MAX >> 32) - 1) + return (-SBT_MAX - 1); + return (tvtosbt(_tv)); +} + #endif /* __BSD_VISIBLE */ #ifdef _KERNEL |
