Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Sep 2023 22:26:15 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: fb5daae920ba - main - timerfd: Namespace pollution adjustments
Message-ID:  <202309052226.385MQF5F075354@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=fb5daae920bae84e3eec8175bf9e46304c3b2ae6

commit fb5daae920bae84e3eec8175bf9e46304c3b2ae6
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2023-09-05 22:11:50 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-09-05 22:25:01 +0000

    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
---
 sys/sys/timerfd.h | 10 ++++++++--
 1 file 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202309052226.385MQF5F075354>