diff options
author | Damien Miller <djm@mindrot.org> | 2021-11-17 23:26:20 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2021-11-17 23:26:20 +0100 |
commit | 76292787a1e93e668f10e36b4bf59ce0ae28e156 (patch) | |
tree | f68ea40770fda24b3fbcce38de549bef1cb73632 | |
parent | upstream: set num_listen_socks to 0 on close-all instead of -1, (diff) | |
download | openssh-76292787a1e93e668f10e36b4bf59ce0ae28e156.tar.xz openssh-76292787a1e93e668f10e36b4bf59ce0ae28e156.zip |
compat for timespecsub() and friends
-rw-r--r-- | defines.h | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -532,6 +532,39 @@ struct winsize { ((tsp)->tv_sec cmp (usp)->tv_sec)) #endif +/* Operations on timespecs. */ +#ifndef timespecclear +#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0 +#endif +#ifndef timespeccmp +#define timespeccmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? \ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ + ((tsp)->tv_sec cmp (usp)->tv_sec)) +#endif +#ifndef timespecadd +#define timespecadd(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \ + if ((vsp)->tv_nsec >= 1000000000L) { \ + (vsp)->tv_sec++; \ + (vsp)->tv_nsec -= 1000000000L; \ + } \ + } while (0) +#endif +#ifndef timespecsub +#define timespecsub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000L; \ + } \ + } while (0) +#endif + #ifndef __P # define __P(x) x #endif |