From 4082e91b59e7fe34fe50964ecfc970ed2283b3d9 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 24 Sep 2019 08:34:35 +0200 Subject: [PATCH] Move timeval macros to In FreeBSD, NetBSD, and OpenBSD these macros are defined in . --- newlib/libc/include/sys/_timeval.h | 35 +++--------------------------- newlib/libc/include/sys/time.h | 28 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/newlib/libc/include/sys/_timeval.h b/newlib/libc/include/sys/_timeval.h index 676a0b894..6b250c0d0 100644 --- a/newlib/libc/include/sys/_timeval.h +++ b/newlib/libc/include/sys/_timeval.h @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2002 Mike Barcroft * All rights reserved. * @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: head/sys/sys/_timeval.h 326256 2017-11-27 15:01:59Z pfg $ */ #ifndef _SYS__TIMEVAL_H_ @@ -53,37 +55,6 @@ struct timeval { time_t tv_sec; /* seconds */ 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 /* !_SYS__TIMEVAL_H_ */ diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h index 370c13406..84a429bf2 100644 --- a/newlib/libc/include/sys/time.h +++ b/newlib/libc/include/sys/time.h @@ -367,6 +367,34 @@ tvtosbt(struct timeval _tv) (vsp)->tv_nsec += 1000000000L; \ } \ } 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 */ /*