Babeltrace 2 C API
2.0.0
Open-source trace manipulation framework
|
General purpose utilities.
This module contains general purpose utilities.
Typedefs | |
typedef enum bt_util_clock_cycles_to_ns_from_origin_status | bt_util_clock_cycles_to_ns_from_origin_status |
Status codes for bt_util_clock_cycles_to_ns_from_origin(). | |
Functions | |
bt_util_clock_cycles_to_ns_from_origin_status | bt_util_clock_cycles_to_ns_from_origin (uint64_t cycles, uint64_t frequency, int64_t offset_seconds, uint64_t offset_cycles, int64_t *ns_from_origin) |
Converts the clock value cycles from cycles to nanoseconds from the clock's origin and sets *ns_from_origin to the result. More... | |
Status codes for bt_util_clock_cycles_to_ns_from_origin().
Enumerator | |
---|---|
BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK | Success. |
BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR | Integer overflow while computing the result. |
bt_util_clock_cycles_to_ns_from_origin_status bt_util_clock_cycles_to_ns_from_origin | ( | uint64_t | cycles, |
uint64_t | frequency, | ||
int64_t | offset_seconds, | ||
uint64_t | offset_cycles, | ||
int64_t * | ns_from_origin | ||
) |
Converts the clock value cycles from cycles to nanoseconds from the clock's origin and sets *ns_from_origin to the result.
This function considers the clock's frequency in Hz (frequency), an offset from its origin in seconds (offset_seconds) which can be negative, and an additional offset in cycles (offset_cycles).
This function:
The following illustration shows the possible scenarios:
offset_seconds can be negative. For example, considering:
The computed value is -7.5 seconds, so this function sets *ns_from_origin to -7,500,000,000.
This function can fail and return the BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR status code if any step of the computation process causes an integer overflow.
[in] | cycles | Clock's value (cycles). |
[in] | frequency | Clock's frequency (Hz, or cycles/second). |
[in] | offset_seconds | Offset, in seconds, from the clock's origin to add to cycles (once converted to seconds). |
[in] | offset_cycles | Offset, in cycles, to add to cycles. |
[out] | ns_from_origin | On success, *ns_from_origin is cycles converted to nanoseconds from origin considering the clock's properties. |
BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OK | Success. |
BT_UTIL_CLOCK_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR | Integer overflow while computing the result. |
UINT64_C(-1)
. NULL
.