git: 2a6c2d9c38dc - main - libnetbsd: add math.h and sys/time.h
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Feb 2026 23:35:02 UTC
The branch main has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=2a6c2d9c38dc421025b6c18cac68fe9965c574c0
commit 2a6c2d9c38dc421025b6c18cac68fe9965c574c0
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-02-25 23:19:56 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-02-25 23:34:32 +0000
libnetbsd: add math.h and sys/time.h
- `math.h`: `isinff(..)`
- `sys/time.h`: `timespec*(x)`
These two headers are used by tests in newer snapshots of
`contrib/netbsd-tests`.
MFC after: 1 week
---
lib/libnetbsd/math.h | 14 ++++++++++++++
lib/libnetbsd/sys/time.h | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/lib/libnetbsd/math.h b/lib/libnetbsd/math.h
new file mode 100644
index 000000000000..bffc94f82d67
--- /dev/null
+++ b/lib/libnetbsd/math.h
@@ -0,0 +1,14 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Enji Cooper
+ */
+
+#ifndef __LIBNETBSD_MATH_H__
+#define __LIBNETBSD_MATH_H__
+
+#include_next <math.h>
+
+#define isinff(x) __isinff(x)
+
+#endif
diff --git a/lib/libnetbsd/sys/time.h b/lib/libnetbsd/sys/time.h
new file mode 100644
index 000000000000..9ddde16e84e3
--- /dev/null
+++ b/lib/libnetbsd/sys/time.h
@@ -0,0 +1,35 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Enji Cooper
+ */
+
+#ifndef _LIBNETBSD_SYS_TIME_H_
+#define _LIBNETBSD_SYS_TIME_H_
+
+#include_next <sys/time.h>
+
+#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 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)
+#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