xtos_ signal_ correct_ timestamps
Rebuilds a timestamp array from a start time and a rounded fixed nanosecond interval.
On this page
Declaration
#include <xtos/signal.h>
int xtos_signal_correct_timestamps(uint64_t start_timestamp_ns,
uint32_t sample_rate_hz,
uint64_t *timestamps_ns,
size_t count);Parameters
| Parameter | Type | Description |
|---|---|---|
| start_timestamp_ns | uint64_t | Start timestamp in nanoseconds. |
| sample_rate_hz | uint32_t | Sampling rate in Hz, greater than zero. |
| timestamps_ns | uint64_t * | Non-NULL output array with at least count entries. |
| count | size_t | Number of entries to write, greater than zero. |
Return value
Returns 0 on success and -1 on failure. Success writes start_timestamp_ns + i×rounded_interval.
Errors
| errno | Condition |
|---|---|
| EINVAL | timestamps_ns is NULL, count is zero, or sample rate is zero. |
Notes
- The function does not check uint64 multiply/add overflow; rounding error for fractional-nanosecond periods accumulates by index.
- Overwrites the caller array without allocation; retain original timestamps if comparison is needed.
Example
Source
This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.