XTOS / OPEN SOURCE REAL-TIME SYSTEMOPEN SOURCE · VERSION 0.9.0 · BUILD FROM SOURCE
libxtos-signalxtos_signal_correct_timestamps

xtos_signal_correct_timestamps

Rebuilds a timestamp array from a start time and a rounded fixed nanosecond interval.

On this page

Declaration

c
#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

ParameterTypeDescription
start_timestamp_nsuint64_tStart timestamp in nanoseconds.
sample_rate_hzuint32_tSampling rate in Hz, greater than zero.
timestamps_nsuint64_t *Non-NULL output array with at least count entries.
countsize_tNumber 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

errnoCondition
EINVALtimestamps_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.