rcutils
master
C API providing common utilities and data structures.
|
#include <stdint.h>
#include "rcutils/macros.h"
#include "rcutils/types.h"
#include "rcutils/visibility_control.h"
Go to the source code of this file.
Macros | |
#define | RCUTILS_S_TO_NS(seconds) (seconds * (1000 * 1000 * 1000)) |
Convenience macro to convert seconds to nanoseconds. More... | |
#define | RCUTILS_MS_TO_NS(milliseconds) (milliseconds * (1000 * 1000)) |
Convenience macro to convert milliseconds to nanoseconds. More... | |
#define | RCUTILS_US_TO_NS(microseconds) (microseconds * 1000) |
Convenience macro to convert microseconds to nanoseconds. More... | |
#define | RCUTILS_NS_TO_S(nanoseconds) (nanoseconds / (1000 * 1000 * 1000)) |
Convenience macro to convert nanoseconds to seconds. More... | |
#define | RCUTILS_NS_TO_MS(nanoseconds) (nanoseconds / (1000 * 1000)) |
Convenience macro to convert nanoseconds to milliseconds. More... | |
#define | RCUTILS_NS_TO_US(nanoseconds) (nanoseconds / 1000) |
Convenience macro to convert nanoseconds to microseconds. More... | |
Typedefs | |
typedef uint64_t | rcutils_time_point_value_t |
A single point in time, measured in nanoseconds since the Unix epoch. More... | |
typedef int64_t | rcutils_duration_value_t |
A duration of time, measured in nanoseconds. More... | |
Functions | |
rcutils_ret_t | rcutils_system_time_now (rcutils_time_point_value_t *now) |
rcutils_ret_t | rcutils_steady_time_now (rcutils_time_point_value_t *now) |
Retrieve the current time as a rcutils_time_point_value_t object. More... | |
#define RCUTILS_S_TO_NS | ( | seconds | ) | (seconds * (1000 * 1000 * 1000)) |
Convenience macro to convert seconds to nanoseconds.
#define RCUTILS_MS_TO_NS | ( | milliseconds | ) | (milliseconds * (1000 * 1000)) |
Convenience macro to convert milliseconds to nanoseconds.
#define RCUTILS_US_TO_NS | ( | microseconds | ) | (microseconds * 1000) |
Convenience macro to convert microseconds to nanoseconds.
#define RCUTILS_NS_TO_S | ( | nanoseconds | ) | (nanoseconds / (1000 * 1000 * 1000)) |
Convenience macro to convert nanoseconds to seconds.
#define RCUTILS_NS_TO_MS | ( | nanoseconds | ) | (nanoseconds / (1000 * 1000)) |
Convenience macro to convert nanoseconds to milliseconds.
#define RCUTILS_NS_TO_US | ( | nanoseconds | ) | (nanoseconds / 1000) |
Convenience macro to convert nanoseconds to microseconds.
typedef uint64_t rcutils_time_point_value_t |
A single point in time, measured in nanoseconds since the Unix epoch.
typedef int64_t rcutils_duration_value_t |
A duration of time, measured in nanoseconds.
rcutils_ret_t rcutils_system_time_now | ( | rcutils_time_point_value_t * | now | ) |
This function returns the time from a system clock. The closest equivalent would be to std::chrono::system_clock::now();
The resolution (e.g. nanoseconds vs microseconds) is not guaranteed.
The now argument must point to an allocated rcutils_time_point_value_t object, as the result is copied into this variable.
Attribute | Adherence — |
---|---|
Allocates Memory | No |
Thread-Safe | Yes |
Uses Atomics | No |
Lock-Free | Yes |
[out] | now | a datafield in which the current time is stored |
RCUTILS_RET_OK
if the current time was successfully obtained, or RCUTILS_RET_INVALID_ARGUMENT
if any arguments are invalid, or RCUTILS_RET_ERROR
an unspecified error occur. rcutils_ret_t rcutils_steady_time_now | ( | rcutils_time_point_value_t * | now | ) |
Retrieve the current time as a rcutils_time_point_value_t object.
This function returns the time from a monotonically increasing clock. The closest equivalent would be to std::chrono::steady_clock::now();
The resolution (e.g. nanoseconds vs microseconds) is not guaranteed.
The now argument must point to an allocated rcutils_time_point_value_t object, as the result is copied into this variable.
Attribute | Adherence — |
---|---|
Allocates Memory | No |
Thread-Safe | Yes |
Uses Atomics | No |
Lock-Free | Yes |
[out] | now | a struct in which the current time is stored |
RCUTILS_RET_OK
if the current time was successfully obtained, or RCUTILS_RET_INVALID_ARGUMENT
if any arguments are invalid, or RCUTILS_RET_ERROR
an unspecified error occur.