* Take a snapshot of sysclock data which can be used to compare system clocks * and generate timestamps after the fact. */
| 1020 | * and generate timestamps after the fact. |
| 1021 | */ |
| 1022 | void |
| 1023 | sysclock_getsnapshot(struct sysclock_snap *clock_snap, int fast) |
| 1024 | { |
| 1025 | struct fbclock_info *fbi; |
| 1026 | struct timehands *th; |
| 1027 | struct bintime bt; |
| 1028 | unsigned int delta, gen; |
| 1029 | #ifdef FFCLOCK |
| 1030 | ffcounter ffcount; |
| 1031 | struct fftimehands *ffth; |
| 1032 | struct ffclock_info *ffi; |
| 1033 | struct ffclock_estimate cest; |
| 1034 | |
| 1035 | ffi = &clock_snap->ff_info; |
| 1036 | #endif |
| 1037 | |
| 1038 | fbi = &clock_snap->fb_info; |
| 1039 | delta = 0; |
| 1040 | |
| 1041 | do { |
| 1042 | th = timehands; |
| 1043 | gen = atomic_load_acq_int(&th->th_generation); |
| 1044 | fbi->th_scale = th->th_scale; |
| 1045 | fbi->tick_time = th->th_offset; |
| 1046 | #ifdef FFCLOCK |
| 1047 | ffth = fftimehands; |
| 1048 | ffi->tick_time = ffth->tick_time_lerp; |
| 1049 | ffi->tick_time_lerp = ffth->tick_time_lerp; |
| 1050 | ffi->period = ffth->cest.period; |
| 1051 | ffi->period_lerp = ffth->period_lerp; |
| 1052 | clock_snap->ffcount = ffth->tick_ffcount; |
| 1053 | cest = ffth->cest; |
| 1054 | #endif |
| 1055 | if (!fast) |
| 1056 | delta = tc_delta(th); |
| 1057 | atomic_thread_fence_acq(); |
| 1058 | } while (gen == 0 || gen != th->th_generation); |
| 1059 | |
| 1060 | clock_snap->delta = delta; |
| 1061 | clock_snap->sysclock_active = sysclock_active; |
| 1062 | |
| 1063 | /* Record feedback clock status and error. */ |
| 1064 | clock_snap->fb_info.status = time_status; |
| 1065 | /* XXX: Very crude estimate of feedback clock error. */ |
| 1066 | bt.sec = time_esterror / 1000000; |
| 1067 | bt.frac = ((time_esterror - bt.sec) * 1000000) * |
| 1068 | (uint64_t)18446744073709ULL; |
| 1069 | clock_snap->fb_info.error = bt; |
| 1070 | |
| 1071 | #ifdef FFCLOCK |
| 1072 | if (!fast) |
| 1073 | clock_snap->ffcount += delta; |
| 1074 | |
| 1075 | /* Record feed-forward clock leap second adjustment. */ |
| 1076 | ffi->leapsec_adjustment = cest.leapsec_total; |
| 1077 | if (clock_snap->ffcount > cest.leapsec_next) |
| 1078 | ffi->leapsec_adjustment -= cest.leapsec; |
| 1079 |
nothing calls this directly
no test coverage detected