mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-03 08:25:47 +03:00
i/c/coap_time.h: whitespace cleanup, reformatting, no changes
Just some cleanup like whitespace, punctiation marking and indentation issues.
This commit is contained in:
1 parent
54abde5943
commit
7af8edf8a9
1 file changed
+40
-41
+40
-41
@@ -3,10 +3,10 @@
|
||||
* Copyright (C) 2010--2013 Olaf Bergmann <bergmann@tzi.org>
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see
|
||||
* README for terms of use.
|
||||
* README for terms of use.
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* @file coap_time.h
|
||||
* @brief Clock Handling
|
||||
*/
|
||||
@@ -21,7 +21,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "coap_config.h"
|
||||
|
||||
/**
|
||||
@@ -42,23 +41,21 @@ typedef uint32_t coap_tick_t;
|
||||
typedef uint32_t coap_time_t;
|
||||
typedef int32_t coap_tick_diff_t;
|
||||
|
||||
static inline void coap_ticks_impl(coap_tick_t *t)
|
||||
{
|
||||
*t = sys_now();
|
||||
static inline void coap_ticks_impl(coap_tick_t *t) {
|
||||
*t = sys_now();
|
||||
}
|
||||
|
||||
static inline void coap_clock_init_impl(void)
|
||||
{
|
||||
static inline void coap_clock_init_impl(void) {
|
||||
}
|
||||
|
||||
#define coap_clock_init coap_clock_init_impl
|
||||
|
||||
#define coap_ticks coap_ticks_impl
|
||||
|
||||
static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) {
|
||||
return t / COAP_TICKS_PER_SECOND;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_CONTIKI
|
||||
#include "clock.h"
|
||||
|
||||
@@ -66,21 +63,19 @@ typedef clock_time_t coap_tick_t;
|
||||
typedef clock_time_t coap_time_t;
|
||||
|
||||
/**
|
||||
* This data type is used to represent the difference between two
|
||||
* clock_tick_t values. This data type must have the same size in
|
||||
* memory as coap_tick_t to allow wrapping.
|
||||
* This data type is used to represent the difference between two clock_tick_t
|
||||
* values. This data type must have the same size in memory as coap_tick_t to
|
||||
* allow wrapping.
|
||||
*/
|
||||
typedef int coap_tick_diff_t;
|
||||
|
||||
#define COAP_TICKS_PER_SECOND CLOCK_SECOND
|
||||
|
||||
static inline void
|
||||
coap_clock_init(void) {
|
||||
static inline void coap_clock_init(void) {
|
||||
clock_init();
|
||||
}
|
||||
|
||||
static inline void
|
||||
coap_ticks(coap_tick_t *t) {
|
||||
static inline void coap_ticks(coap_tick_t *t) {
|
||||
*t = clock_time();
|
||||
}
|
||||
|
||||
@@ -88,43 +83,49 @@ static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) {
|
||||
return t / COAP_TICKS_PER_SECOND;
|
||||
}
|
||||
#endif /* WITH_CONTIKI */
|
||||
|
||||
#ifdef WITH_POSIX
|
||||
/**
|
||||
* This data type represents internal timer ticks with
|
||||
* COAP_TICKS_PER_SECOND resolution.
|
||||
* This data type represents internal timer ticks with COAP_TICKS_PER_SECOND
|
||||
* resolution.
|
||||
*/
|
||||
typedef unsigned long coap_tick_t;
|
||||
|
||||
/** CoAP time in seconds since epoch. */
|
||||
/**
|
||||
* CoAP time in seconds since epoch.
|
||||
*/
|
||||
typedef time_t coap_time_t;
|
||||
|
||||
/**
|
||||
* This data type is used to represent the difference between two
|
||||
* clock_tick_t values. This data type must have the same size in
|
||||
* memory as coap_tick_t to allow wrapping.
|
||||
* This data type is used to represent the difference between two clock_tick_t
|
||||
* values. This data type must have the same size in memory as coap_tick_t to
|
||||
* allow wrapping.
|
||||
*/
|
||||
typedef long coap_tick_diff_t;
|
||||
|
||||
/** Use ms resolution on POSIX systems */
|
||||
#define COAP_TICKS_PER_SECOND 1000
|
||||
|
||||
/** Initializes the internal clock. */
|
||||
static inline void coap_clock_init(void)
|
||||
{
|
||||
/**
|
||||
* Initializes the internal clock.
|
||||
*/
|
||||
static inline void coap_clock_init(void) {
|
||||
}
|
||||
|
||||
/** Sets @p t to the internal time with COAP_TICKS_PER_SECOND resolution. */
|
||||
/**
|
||||
* Sets @p t to the internal time with COAP_TICKS_PER_SECOND resolution.
|
||||
*/
|
||||
void coap_ticks(coap_tick_t *t);
|
||||
|
||||
/**
|
||||
* Helper function that converts coap ticks to wallclock time. On POSIX,
|
||||
* this function returns the number of seconds since the epoch. On other
|
||||
* systems, it may be the calculated number of seconds since last reboot
|
||||
* or so.
|
||||
* Helper function that converts coap ticks to wallclock time. On POSIX, this
|
||||
* function returns the number of seconds since the epoch. On other systems, it
|
||||
* may be the calculated number of seconds since last reboot or so.
|
||||
*
|
||||
* @param t Internal system ticks
|
||||
* @return The number of seconds that has passed since a specific reference
|
||||
* point (seconds since epoch on POSIX).
|
||||
* @param t Internal system ticks.
|
||||
*
|
||||
* @return The number of seconds that has passed since a specific reference
|
||||
* point (seconds since epoch on POSIX).
|
||||
*/
|
||||
static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) {
|
||||
return t / COAP_TICKS_PER_SECOND;
|
||||
@@ -132,20 +133,18 @@ static inline coap_time_t coap_ticks_to_rt(coap_tick_t t) {
|
||||
#endif /* WITH_POSIX */
|
||||
|
||||
/**
|
||||
* Returns @c 1 if and only if @p a is less than @p b where less is
|
||||
* defined on a signed data type.
|
||||
* Returns @c 1 if and only if @p a is less than @p b where less is defined on a
|
||||
* signed data type.
|
||||
*/
|
||||
static inline
|
||||
int coap_time_lt(coap_tick_t a, coap_tick_t b) {
|
||||
static inline int coap_time_lt(coap_tick_t a, coap_tick_t b) {
|
||||
return ((coap_tick_diff_t)(a - b)) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns @c 1 if and only if @p a is less than or equal @p b where
|
||||
* less is defined on a signed data type.
|
||||
* Returns @c 1 if and only if @p a is less than or equal @p b where less is
|
||||
* defined on a signed data type.
|
||||
*/
|
||||
static inline
|
||||
int coap_time_le(coap_tick_t a, coap_tick_t b) {
|
||||
static inline int coap_time_le(coap_tick_t a, coap_tick_t b) {
|
||||
return a == b || coap_time_lt(a,b);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user