Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 1996 21:47:55 -0500
From:      "Chris Csanady" <ccsanady@friley216.res.iastate.edu>
To:        hackers@FreeBSD.org
Subject:   Proposed addition to sys/time.h..
Message-ID:  <199610160247.VAA00535@friley216.res.iastate.edu>

next in thread | raw e-mail | index | archive | help

I was wondering if someone would like to add in the following macros from
NetBSD's sys/time.h.  They are really quite handy.

Anyway, I really hate sending this here, but what should I do with small
code change requests/etc?

Laters,
Chris Csanady

#define timeradd(tvp, uvp, vvp)                                         \
        do {                                                            \
                (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;          \
                (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;       \
                if ((vvp)->tv_usec >= 1000000) {                        \
                        (vvp)->tv_sec++;                                \
                        (vvp)->tv_usec -= 1000000;                      \
                }                                                       \
        } while (0)
#define timersub(tvp, uvp, vvp)                                         \
        do {                                                            \
                (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
                (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
                if ((vvp)->tv_usec < 0) {                               \
                        (vvp)->tv_sec--;                                \
                        (vvp)->tv_usec += 1000000;                      \
                }                                                       \
        } while (0)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610160247.VAA00535>