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

Function ReadFBClockData

fbclock/shmem_notlinux.go:145–160  ·  view source on GitHub ↗

ReadFBClockData reads Data from mmaped fbclock shared memory

(shmp unsafe.Pointer)

Source from the content-addressed store, hash-verified

143
144// ReadFBClockData reads Data from mmaped fbclock shared memory
145func ReadFBClockData(shmp unsafe.Pointer) (*Data, error) {
146 for range maxReadTries {
147 base := (*[shmDataSize]byte)(shmp)
148 var buf [40]byte
149 copy(buf[:], base[8:48])
150 crc := atomic.LoadUint64((*uint64)(unsafe.Pointer(&base[0])))
151 if clockDataCRC(&buf) == crc {
152 return &Data{
153 IngressTimeNS: int64(binary.LittleEndian.Uint64(buf[0:8])),
154 ErrorBoundNS: uint64(binary.LittleEndian.Uint32(buf[8:12])),
155 HoldoverMultiplierNS: Uint32AsFloat(binary.LittleEndian.Uint32(buf[12:16])),
156 }, nil
157 }
158 }
159 return nil, fmt.Errorf("CRC check failed after %d tries", maxReadTries)
160}
161
162// storeSeqlockSection writes a data section guarded by the seqlock at seqOff:
163// bump the counter odd, run write (which gets the section's data slice starting

Callers

nothing calls this directly

Calls 2

clockDataCRCFunction · 0.85
Uint32AsFloatFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…