Convert from TSC (CPU cycles) to nanoseconds */
| 99 | |
| 100 | /* Convert from TSC (CPU cycles) to nanoseconds */ |
| 101 | static uint64_t |
| 102 | pcapng_timestamp(const rte_pcapng_t *self, uint64_t cycles) |
| 103 | { |
| 104 | uint64_t delta, rem, secs, ns; |
| 105 | const uint64_t hz = rte_get_tsc_hz(); |
| 106 | |
| 107 | delta = cycles - self->tsc_base; |
| 108 | |
| 109 | /* Avoid numeric wraparound by computing seconds first */ |
| 110 | secs = delta / hz; |
| 111 | rem = delta % hz; |
| 112 | ns = (rem * NS_PER_S) / hz; |
| 113 | |
| 114 | return secs * NS_PER_S + ns + self->offset_ns; |
| 115 | } |
| 116 | |
| 117 | /* length of option including padding */ |
| 118 | static uint16_t pcapng_optlen(uint16_t len) |
no test coverage detected