ReadFBClockData reads Data from mmaped fbclock shared memory
(shmp unsafe.Pointer)
| 143 | |
| 144 | // ReadFBClockData reads Data from mmaped fbclock shared memory |
| 145 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…