IoTivity-Lite
oc_clock.h File Reference
#include "oc_clock_util.h"
#include "oc_export.h"
#include "util/oc_compiler.h"
#include <stdbool.h>
#include <stdint.h>

Functions

void oc_clock_init (void)
 A second, measured in system clock time. More...
 
unsigned long oc_clock_seconds (void)
 Get the current value of the platform seconds. More...
 
uint64_t oc_clock_seconds_v1 (void)
 Get the current value of the platform seconds. More...
 
oc_clock_time_t oc_clock_time (void)
 Get the current clock time. More...
 
bool oc_clock_time_has_monotonic_clock (void)
 Check if the platform supports a monotonic clock. More...
 
oc_clock_time_t oc_clock_time_monotonic (void)
 Get the current monotonic clock time. More...
 
void oc_clock_wait (oc_clock_time_t t)
 Wait for a given number of ticks. More...
 

Function Documentation

◆ oc_clock_init()

void oc_clock_init ( void  )

A second, measured in system clock time.

Initialize the clock library.

This function initializes the clock library and should be called from the main() function of the system.

◆ oc_clock_seconds()

unsigned long oc_clock_seconds ( void  )

Get the current value of the platform seconds.

Deprecated:
Use oc_clock_seconds_v1 instead because it returns a 64-bit value on all platforms and thus is safe for years 2038+.

◆ oc_clock_seconds_v1()

uint64_t oc_clock_seconds_v1 ( void  )

Get the current value of the platform seconds.

This could be the number of seconds since startup, or since a standard epoch.

Returns
The value.

◆ oc_clock_time()

oc_clock_time_t oc_clock_time ( void  )

Get the current clock time.

This function returns the current system clock time.

Returns
The current clock time, measured in system ticks.

◆ oc_clock_time_has_monotonic_clock()

bool oc_clock_time_has_monotonic_clock ( void  )

Check if the platform supports a monotonic clock.

Returns
true if the platform supports a monotonic clock
false otherwise

◆ oc_clock_time_monotonic()

oc_clock_time_t oc_clock_time_monotonic ( void  )

Get the current monotonic clock time.

This could be the number of seconds since startup, or since a standard epoch. This time is guaranteed to be monotonic, and not effected by any changes in system.

Returns
The current clock monotonic time, measured in system ticks.
Note
If the platform does not support a monotonic clock, this function returns the same value as oc_clock_time().
See also
oc_clock_time_has_monotonic_clock()
oc_clock_time()

◆ oc_clock_wait()

void oc_clock_wait ( oc_clock_time_t  t)

Wait for a given number of ticks.

Parameters
tHow many ticks.