aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Freeland <jfree@FreeBSD.org>2023-09-17 15:02:09 +0000
committerWarner Losh <imp@FreeBSD.org>2023-10-01 04:40:03 +0000
commit7454117918cd9f7900d92513a7a4e3ed361987bc (patch)
treeec8151b1682616f10fe557f1e4548f1b8500ae65
parentcefd82e00fec12794c3cff81a17fa7fdf2f3a014 (diff)
downloadsrc-7454117918cd.tar.gz
src-7454117918cd.zip
timerfd: Namespace pollution adjustments
Do not pollute userspace with <sys/proc.h>, instead declare struct thread when _KERNEL is defined. Include <sys/time.h> instead of <sys/timespec.h>. This causes intentional namespace pollution that mimics Linux. g/musl libcs include <time.h> in their <sys/timerfd.h>, exposing clock gettime, settime functions and CLOCK_ macro constants. Ports like Chromium expect this namespace pollution and fail without it. MFC After: 3 days Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D41641 (cherry picked from commit fb5daae920bae84e3eec8175bf9e46304c3b2ae6) (cherry picked from commit 8bcf9a87c79d8de05bc79ff2f8530bf4a52162ca) Approved-by: re (gjb)
-rw-r--r--sys/sys/timerfd.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/sys/timerfd.h b/sys/sys/timerfd.h
index 8cb9939ba60f..cace3b71498c 100644
--- a/sys/sys/timerfd.h
+++ b/sys/sys/timerfd.h
@@ -30,8 +30,12 @@
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <sys/proc.h>
-#include <sys/timespec.h>
+/*
+ * We only need <sys/timespec.h>, but glibc pollutes the namespace
+ * with <time.h>. This pollution is expected by most programs, so
+ * reproduce it by including <sys/time.h> here.
+ */
+#include <sys/time.h>
typedef uint64_t timerfd_t;
@@ -54,6 +58,8 @@ __END_DECLS
#else /* _KERNEL */
+struct thread;
+
int kern_timerfd_create(struct thread *td, int clockid, int flags);
int kern_timerfd_gettime(struct thread *td, int fd,
struct itimerspec *curr_value);