Step steps clock by given step
(clockid int32, step time.Duration)
| 75 | |
| 76 | // Step steps clock by given step |
| 77 | func Step(clockid int32, step time.Duration) (state int, err error) { |
| 78 | sign := 1 |
| 79 | if step < 0 { |
| 80 | sign = -1 |
| 81 | step = step * -1 |
| 82 | } |
| 83 | tx := &unix.Timex{} |
| 84 | tx.Modes = AdjSetOffset | AdjNano |
| 85 | sec := time.Duration(float64(sign) * (float64(step) / float64(time.Second))) |
| 86 | usec := time.Duration(sign) * (step % time.Second) |
| 87 | // this way we can have platform-dependent code isolated |
| 88 | setTime(tx, sec, usec) |
| 89 | /* |
| 90 | * The value of a timeval is the sum of its fields, but the |
| 91 | * field tv_usec must always be non-negative. |
| 92 | */ |
| 93 | if tx.Time.Usec < 0 { |
| 94 | tx.Time.Sec-- |
| 95 | tx.Time.Usec += 1000000000 |
| 96 | } |
| 97 | return unix.ClockAdjtime(clockid, tx) |
| 98 | } |
| 99 | |
| 100 | // MaxFreqPPB returns maximum frequency adjustment supported by the clock |
| 101 | func MaxFreqPPB(clockid int32) (freqPPB float64, state int, err error) { |
no test coverage detected
searching dependent graphs…