From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: newlib@sourceware.org
Subject: [PATCH 4/4] Move timeval macros to <sys/time.h>
Date: Tue, 24 Sep 2019 07:01:00 -0000 [thread overview]
Message-ID: <20190924070054.24447-5-sebastian.huber@embedded-brains.de> (raw)
In-Reply-To: <20190924070054.24447-1-sebastian.huber@embedded-brains.de>
In FreeBSD, NetBSD, and OpenBSD these macros are defined in
<sys/time.h>.
---
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 <mike@FreeBSD.org>
* 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 */
/*
--
2.16.4
next prev parent reply other threads:[~2019-09-24 7:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 7:01 [PATCH 0/4] Synchronize <sys/time.h>, etc. with FreeBSD Sebastian Huber
2019-09-24 7:01 ` Sebastian Huber [this message]
2019-09-24 7:01 ` [PATCH 1/4] Fix sbttons for values > 2s Sebastian Huber
2019-09-24 7:01 ` [PATCH 3/4] Synchronize <sys/time.h> with FreeBSD Sebastian Huber
2019-09-24 7:01 ` [PATCH 2/4] Synchronize <sys/_timespec.h> " Sebastian Huber
2019-10-14 6:57 ` [PATCH 0/4] Synchronize <sys/time.h>, etc. " Sebastian Huber
2019-10-31 7:05 ` Sebastian Huber
2019-11-02 15:26 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190924070054.24447-5-sebastian.huber@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).