From 3232c85269d5abc9dc58d306e5b13bb1be217801 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 6 Oct 2019 11:24:17 +0100 Subject: add timer cmp,isset and clear to fallback macros and improve file documentation --- utils/sys_time.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/utils/sys_time.h b/utils/sys_time.h index 82d88fd25..fe8e5f6f3 100644 --- a/utils/sys_time.h +++ b/utils/sys_time.h @@ -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 +#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 -- cgit v1.2.3