Move timeval macros to <sys/time.h>
In FreeBSD, NetBSD, and OpenBSD these macros are defined in <sys/time.h>.
This commit is contained in:
parent
6e24438819
commit
830418fb7a
|
@ -1,4 +1,6 @@
|
||||||
/*-
|
/*-
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
*
|
||||||
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
|
* Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -23,7 +25,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $FreeBSD$
|
* $FreeBSD: head/sys/sys/_timeval.h 326256 2017-11-27 15:01:59Z pfg $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SYS__TIMEVAL_H_
|
#ifndef _SYS__TIMEVAL_H_
|
||||||
|
@ -53,37 +55,6 @@ struct timeval {
|
||||||
time_t tv_sec; /* seconds */
|
time_t tv_sec; /* seconds */
|
||||||
suseconds_t tv_usec; /* and microseconds */
|
suseconds_t tv_usec; /* and microseconds */
|
||||||
};
|
};
|
||||||
|
|
||||||
#if __BSD_VISIBLE
|
|
||||||
#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
|
|
||||||
|
|
||||||
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
|
|
||||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
|
||||||
#define timercmp(tvp, uvp, cmp) \
|
|
||||||
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
|
||||||
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
|
||||||
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
|
||||||
#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)
|
|
||||||
#endif
|
|
||||||
#endif /* __BSD_VISIBLE */
|
|
||||||
|
|
||||||
#endif /* _TIMEVAL_DEFINED */
|
#endif /* _TIMEVAL_DEFINED */
|
||||||
|
|
||||||
#endif /* !_SYS__TIMEVAL_H_ */
|
#endif /* !_SYS__TIMEVAL_H_ */
|
||||||
|
|
|
@ -367,6 +367,34 @@ tvtosbt(struct timeval _tv)
|
||||||
(vsp)->tv_nsec += 1000000000L; \
|
(vsp)->tv_nsec += 1000000000L; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */
|
||||||
|
|
||||||
|
#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
|
||||||
|
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||||
|
#define timercmp(tvp, uvp, cmp) \
|
||||||
|
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
||||||
|
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
||||||
|
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
||||||
|
#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)
|
||||||
|
#endif
|
||||||
#endif /* __BSD_VISIBLE */
|
#endif /* __BSD_VISIBLE */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue