* Decimal<->sbt conversions. Multiplying or dividing by SBT_1NS results in * large roundoff errors which sbttons() and nstosbt() avoid. Millisecond and * microsecond functions are also provided for completeness. * * These functions return the smallest sbt larger or equal to the * number of seconds requested so that sbttoX(Xtosbt(y)) == y. Unlike * top of second computations below, which r
| 182 | * assert.h. |
| 183 | */ |
| 184 | static __inline int64_t |
| 185 | sbttons(sbintime_t _sbt) |
| 186 | { |
| 187 | uint64_t ns; |
| 188 | |
| 189 | #ifdef KASSERT |
| 190 | KASSERT(_sbt >= 0, ("Negative values illegal for sbttons: %jx", _sbt)); |
| 191 | #endif |
| 192 | ns = _sbt; |
| 193 | if (ns >= SBT_1S) |
| 194 | ns = (ns >> 32) * 1000000000; |
| 195 | else |
| 196 | ns = 0; |
| 197 | |
| 198 | return (ns + (1000000000 * (_sbt & 0xffffffffu) >> 32)); |
| 199 | } |
| 200 | |
| 201 | static __inline sbintime_t |
| 202 | nstosbt(int64_t _ns) |