add timer cmp,isset and clear to fallback macros and improve file documentation

This commit is contained in:
Vincent Sanders 2019-10-06 11:24:17 +01:00
parent 5c9c1a7025
commit 3232c85269

View File

@ -18,14 +18,26 @@
/**
* \file
* \brief BSD style time functions
* BSD style timeval macros
*
* BSD added macros for manipulating timeval which have become standard on
* modern c libraries but for compatability where they are missing it is
* necessary to provide fallbacks.
*/
#ifndef _NETSURF_UTILS_SYS_TIME_H_
#define _NETSURF_UTILS_SYS_TIME_H_
#ifndef NETSURF_UTILS_SYS_TIME_H_
#define NETSURF_UTILS_SYS_TIME_H_
#include <sys/time.h>
#ifndef timerclear
#define timerclear(a) (a)->tv_sec = (a)->tv_usec = 0
#endif
#ifndef timerisset
#define timerisset(a) ((a)->tv_sec || (a)->tv_usec)
#endif
#ifndef timeradd
#define timeradd(a, aa, result) \
do { \
@ -50,4 +62,10 @@
} while (0)
#endif
#ifndef timercmp
#define timercmp(a, aa, cmp) \
((a)->tv_sec cmp (aa)->tv_sec || \
(a)->tv_sec == (aa)->tv_sec && (a)->tv_usec cmp (aa)->tv_usec)
#endif
#endif