Rev 3297 | Rev 5270 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3297 | Rev 4244 | ||
---|---|---|---|
Line 160... | Line 160... | ||
160 | (((u64)nsec * NSEC_CONVERSION) >> |
160 | (((u64)nsec * NSEC_CONVERSION) >> |
161 | (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; |
161 | (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; |
Line 162... | Line 162... | ||
162 | 162 | ||
Line -... | Line 163... | ||
- | 163 | } |
|
- | 164 | ||
- | 165 | s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) |
|
- | 166 | { |
|
- | 167 | u64 quotient; |
|
- | 168 | ||
- | 169 | if (dividend < 0) { |
|
- | 170 | quotient = div_u64_rem(-dividend, abs(divisor), (u32 *)remainder); |
|
- | 171 | *remainder = -*remainder; |
|
- | 172 | if (divisor > 0) |
|
- | 173 | quotient = -quotient; |
|
- | 174 | } else { |
|
- | 175 | quotient = div_u64_rem(dividend, abs(divisor), (u32 *)remainder); |
|
- | 176 | if (divisor < 0) |
|
- | 177 | quotient = -quotient; |
|
- | 178 | } |
|
- | 179 | return quotient; |
|
- | 180 | } |
|
- | 181 | ||
- | 182 | struct timespec ns_to_timespec(const s64 nsec) |
|
- | 183 | { |
|
- | 184 | struct timespec ts; |
|
- | 185 | s32 rem; |
|
- | 186 | ||
- | 187 | if (!nsec) |
|
- | 188 | return (struct timespec) {0, 0}; |
|
- | 189 | ||
- | 190 | ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); |
|
- | 191 | if (unlikely(rem < 0)) { |
|
- | 192 | ts.tv_sec--; |
|
- | 193 | rem += NSEC_PER_SEC; |
|
- | 194 | } |
|
- | 195 | ts.tv_nsec = rem; |
|
- | 196 | ||
- | 197 | return ts; |