diff options
author | Vincent Sanders <vince@kyllikki.org> | 2019-10-06 11:24:17 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2019-10-11 17:12:53 +0100 |
commit | 3232c85269d5abc9dc58d306e5b13bb1be217801 (patch) | |
tree | 1101e84526edcbbc2e3d7bf0b4c25d9aa95eecde /utils/sys_time.h | |
parent | 5c9c1a70256dbb4ab14c0b07fc664384b076f87b (diff) | |
download | netsurf-3232c85269d5abc9dc58d306e5b13bb1be217801.tar.gz netsurf-3232c85269d5abc9dc58d306e5b13bb1be217801.tar.bz2 |
add timer cmp,isset and clear to fallback macros and improve file documentation
Diffstat (limited to 'utils/sys_time.h')
-rw-r--r-- | utils/sys_time.h | 24 |
1 files 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 <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 |