clock

package
v0.0.0-...-b56da86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package clock contains a wrapper around CLOCK_ADJTIME syscall.

It allows interactions with supported clocks, such as system realtime clock or PHC.

Supported methods include getting the frequency, adjusting the frequency, stepping the clock, etc.

Index

Constants

View Source
const (
	// time offset
	AdjOffset uint32 = 0x0001
	// frequency offset
	AdjFrequency uint32 = 0x0002
	// maximum time error
	AdjMaxError uint32 = 0x0004
	// estimated time error
	AdjEstError uint32 = 0x0008
	// clock status
	AdjStatus uint32 = 0x0010
	// pll time constant
	AdjTimeConst uint32 = 0x0020
	// set TAI offset
	AdjTAI uint32 = 0x0080
	// add 'time' to current time
	AdjSetOffset uint32 = 0x0100
	// select microsecond resolution
	AdjMicro uint32 = 0x1000
	// select nanosecond resolution
	AdjNano uint32 = 0x2000
	// tick value
	AdjTick uint32 = 0x4000
)

clock_adjtime modes from usr/include/linux/timex.h

View Source
const PPBToTimexPPM = 65.536

PPBToTimexPPM is what we use to conver PPB to PPM. man clock_adjtime(2): In struct timex, freq, ppsfreq, and stabil are ppm (parts per million) with a 16-bit fractional part. To covert value where 2^16=65536 is 1 ppm to ppb or back, we need this multiplier

Variables

This section is empty.

Functions

func AdjFreqPPB

func AdjFreqPPB(clockid int32, freqPPB float64) (state int, err error)

AdjFreqPPB adjusts clock frequency in PPB

func Adjtime

func Adjtime(clockid int32, buf *unix.Timex) (state int, err error)

Adjtime issues CLOCK_ADJTIME syscall to either adjust the parameters of given clock, or read them if buf is empty. man(2) clock_adjtime

func FrequencyPPB

func FrequencyPPB(clockid int32) (freqPPB float64, state int, err error)

FrequencyPPB reads device frequency in PPB

func MaxFreqPPB

func MaxFreqPPB(clockid int32) (freqPPB float64, state int, err error)

MaxFreqPPB returns maximum frequency adjustment supported by the clock

func SetSync

func SetSync(clockid int32) error

SetSync sets clock status to TIME_OK

func Step

func Step(clockid int32, step time.Duration) (state int, err error)

Step steps clock by given step

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL