MCPcopy Create free account
hub / github.com/facebook/time / Step

Function Step

clock/clock.go:77–98  ·  view source on GitHub ↗

Step steps clock by given step

(clockid int32, step time.Duration)

Source from the content-addressed store, hash-verified

75
76// Step steps clock by given step
77func 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
101func MaxFreqPPB(clockid int32) (freqPPB float64, state int, err error) {

Callers 2

clockStepFunction · 0.92
StepMethod · 0.92

Calls 3

ClockAdjtimeFunction · 0.92
setTimeFunction · 0.85
DurationMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…