nano-client API Reference
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

Data Structures

struct  NANO_Time
 A type to represent time-stamps and time durations. More...
 

Macros

#define NANO_TIME_INITIALIZER   { 0, 0 }
 A macro that can be used to initialize static values of NANO_Time.
 
#define NANO_TIME_INITIALIZER_INFINITE   { -1, 0 }
 TODO.
 
#define NANO_TIMEOUT_INFINITE   (-1)
 TODO.
 

Typedefs

typedef NANO_i32 NANO_Timeout
 TODO.
 

Functions

NANO_RetCode NANO_Time_initialize (NANO_Time *const self, const NANO_i32 sec, const NANO_u32 nanosec)
 Initialize a NANO_Time and make sure it is normalized. More...
 
NANO_bool NANO_Time_is_infinite (const NANO_Time *const self)
 Check if a NANO_Time instance is infinite. More...
 
NANO_bool NANO_Time_is_zero (const NANO_Time *const self)
 Check if a NANO_Time instance is zero. More...
 
NANO_RetCode NANO_Time_normalize (const NANO_Time *const self, NANO_Time *const norm_t_out)
 Generate a normalized version of a NANO_Time instance. More...
 
void NANO_Time_to_millis (const NANO_Time *const self, NANO_u64 *const millis_out)
 Convert a NANO_Time instance to a milliseconds representation. More...
 
NANO_RetCode NANO_Time_to_sec (const NANO_Time *const self, NANO_u32 *const sec_out)
 Convert a NANO_Time instance to a seconds representation. More...
 

Detailed Description

Function Documentation

◆ NANO_Time_initialize()

NANO_RetCode NANO_Time_initialize ( NANO_Time *const  self,
const NANO_i32  sec,
const NANO_u32  nanosec 
)

Initialize a NANO_Time and make sure it is normalized.

Parameters
selfthe instance to initialize.
secthe "seconds" component of the new instance.
nanosecthe "nanoseconds" component of the new instance.
Returns
NANO_RETCODE_OK if the instance was initialized successfully, an error code from NANO_Time_normalize otherwise.

◆ NANO_Time_is_infinite()

NANO_bool NANO_Time_is_infinite ( const NANO_Time *const  self)

Check if a NANO_Time instance is infinite.

Parameters
selfthe instance to check.
Returns
NANO_TRUE is the instance is infinite, NANO_FALSE otherwise.

◆ NANO_Time_is_zero()

NANO_bool NANO_Time_is_zero ( const NANO_Time *const  self)

Check if a NANO_Time instance is zero.

Parameters
selfthe instance to check.
Returns
NANO_TRUE is the instance is zero, NANO_FALSE otherwise.

◆ NANO_Time_normalize()

NANO_RetCode NANO_Time_normalize ( const NANO_Time *const  self,
NANO_Time *const  norm_t_out 
)

Generate a normalized version of a NANO_Time instance.

The source and destination instances must not be the same.

Parameters
selfThe instance to normalize.
norm_t_outA normalized representation of the input instance.
Returns
NANO_RETCODE_OK if the instance was successfully normalized, NANO_RETCODE_OVERFLOW_DETECTED if an overflow occurred.

◆ NANO_Time_to_millis()

void NANO_Time_to_millis ( const NANO_Time *const  self,
NANO_u64 *const  millis_out 
)

Convert a NANO_Time instance to a milliseconds representation.

The returned value will be rounded up if the instance has a "nanoseconds" component.

The instance must contain a "finite" time.

Parameters
selfThe instance to convert.
millis_outThe instance's time in seconds (rounded up)

◆ NANO_Time_to_sec()

NANO_RetCode NANO_Time_to_sec ( const NANO_Time *const  self,
NANO_u32 *const  sec_out 
)

Convert a NANO_Time instance to a seconds representation.

The returned value will be rounded up if the instance has a "nanoseconds" component.

The instance must contain a "finite" time.

Parameters
selfThe instance to convert.
sec_outThe instance's time in seconds (rounded up)
Returns
NANO_RETCODE_OK if the instance was successfully converted, NANO_PRECONDITION_NOT_MET if the instance does not contain a finite time.