[lib] Change TIMESTAMP type
TIMESTAMP is not a simple alias for struct timespec. It is now a clone of struct timespec that uses fields of a fixed size (uint32_t).
This commit is contained in:
parent
fb8081f02e
commit
f60287bf49
|
@ -107,11 +107,15 @@ void owl_timestamp_now(TIMESTAMP *now)
|
|||
int owl_timestamp_now_ns(TIMESTAMP *now)
|
||||
{
|
||||
int ret ;
|
||||
if ((ret = clock_gettime(CLOCK_REALTIME, now)))
|
||||
struct timespec now_ts ;
|
||||
if ((ret = clock_gettime(CLOCK_REALTIME, &now_ts)))
|
||||
{
|
||||
perror("Cannot get the current time") ;
|
||||
return ret ;
|
||||
}
|
||||
|
||||
*now = owl_timespec_to_timestamp(now_ts) ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
@ -127,6 +131,19 @@ void owl_timestamp_round_to_ms(TIMESTAMP *now)
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Returns a TIMESTAMP from a struct timespec.
|
||||
*/
|
||||
TIMESTAMP owl_timespec_to_timestamp(const struct timespec d)
|
||||
{
|
||||
TIMESTAMP res ;
|
||||
res.tv_sec = d.tv_sec ;
|
||||
res.tv_nsec = d.tv_nsec ;
|
||||
return res ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Returns a TIMESTAMP from a struct timeval.
|
||||
*/
|
||||
|
|
|
@ -60,8 +60,12 @@ typedef enum {FALSE, TRUE} BOOL ;
|
|||
typedef enum {NORTH = 1, EAST, SOUTH, WEST} DIRECTION ;
|
||||
|
||||
|
||||
/* Timestamp type */
|
||||
typedef struct timespec TIMESTAMP ;
|
||||
/* Timestamp type (struct timespec clone with fix-sized fields) */
|
||||
typedef struct _TIMESTAMP
|
||||
{
|
||||
uint32_t tv_sec ;
|
||||
uint32_t tv_nsec ;
|
||||
} TIMESTAMP ;
|
||||
|
||||
|
||||
/* Message sent by the listener to the aggregator */
|
||||
|
@ -226,6 +230,7 @@ uint_fast8_t owl_frequency_to_channel(uint_fast16_t channel) ;
|
|||
void owl_timestamp_now(TIMESTAMP *now) ;
|
||||
int owl_timestamp_now_ns(TIMESTAMP *now) ;
|
||||
void owl_timestamp_round_to_ms(TIMESTAMP *now) ;
|
||||
TIMESTAMP owl_timespec_to_timestamp(const struct timespec d) ;
|
||||
TIMESTAMP owl_timeval_to_timestamp(const struct timeval d) ;
|
||||
uint64_t owl_timestamp_to_ms(TIMESTAMP date) ;
|
||||
uint_fast32_t owl_time_elapsed(TIMESTAMP sup, TIMESTAMP inf) ;
|
||||
|
|
Loading…
Reference in New Issue