Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Sep 2023 15:04:18 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 27d567847b18 - stable/14 - timerfd: Relocate 32-bit compat code
Message-ID:  <202309171504.38HF4IjN072300@gitrepo.freebsd.org>

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

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

commit 27d567847b18275012bf39fb517dceee41b1ed33
Author:     Jake Freeland <jfree@FreeBSD.org>
AuthorDate: 2023-09-17 15:01:58 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-09-17 15:01:59 +0000

    timerfd: Relocate 32-bit compat code
    
    32-bit compatibility code is conventionally stored in
    sys/compat/freebsd32. Move freebsd32_timerfd_gettime() and
    freebsd32_timerfd_settime() from sys/kern/sys_timerfd.c to
    sys/compat/freebsd32/freebsd32_misc.c.
    
    MFC After: 3 days
    Reviewed by: imp, markj
    Differential Revision; https://reviews.freebsd.org/D41640
    
    (cherry picked from commit 918966a27479b4fb7c4c8999c4926d83c2c081e5)
---
 sys/compat/freebsd32/freebsd32_misc.c | 55 +++++++++++++++++++++++++++++++
 sys/kern/sys_timerfd.c                | 61 -----------------------------------
 2 files changed, 55 insertions(+), 61 deletions(-)

diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 22ee4897083e..c26e7b97e717 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -82,6 +82,7 @@
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 #include <sys/thr.h>
+#include <sys/timerfd.h>
 #include <sys/timex.h>
 #include <sys/unistd.h>
 #include <sys/ucontext.h>
@@ -3138,6 +3139,60 @@ freebsd32_ktimer_gettime(struct thread *td,
 	return (error);
 }
 
+int
+freebsd32_timerfd_gettime(struct thread *td,
+    struct freebsd32_timerfd_gettime_args *uap)
+{
+	struct itimerspec curr_value;
+	struct itimerspec32 curr_value32;
+	int error;
+
+	error = kern_timerfd_gettime(td, uap->fd, &curr_value);
+	if (error == 0) {
+		CP(curr_value, curr_value32, it_value.tv_sec);
+		CP(curr_value, curr_value32, it_value.tv_nsec);
+		CP(curr_value, curr_value32, it_interval.tv_sec);
+		CP(curr_value, curr_value32, it_interval.tv_nsec);
+		error = copyout(&curr_value32, uap->curr_value,
+		    sizeof(curr_value32));
+	}
+
+	return (error);
+}
+
+int
+freebsd32_timerfd_settime(struct thread *td,
+    struct freebsd32_timerfd_settime_args *uap)
+{
+	struct itimerspec new_value, old_value;
+	struct itimerspec32 new_value32, old_value32;
+	int error;
+
+	error = copyin(uap->new_value, &new_value32, sizeof(new_value32));
+	if (error != 0)
+		return (error);
+	CP(new_value32, new_value, it_value.tv_sec);
+	CP(new_value32, new_value, it_value.tv_nsec);
+	CP(new_value32, new_value, it_interval.tv_sec);
+	CP(new_value32, new_value, it_interval.tv_nsec);
+	if (uap->old_value == NULL) {
+		error = kern_timerfd_settime(td, uap->fd, uap->flags,
+		    &new_value, NULL);
+	} else {
+		error = kern_timerfd_settime(td, uap->fd, uap->flags,
+		    &new_value, &old_value);
+		if (error == 0) {
+			CP(old_value, old_value32, it_value.tv_sec);
+			CP(old_value, old_value32, it_value.tv_nsec);
+			CP(old_value, old_value32, it_interval.tv_sec);
+			CP(old_value, old_value32, it_interval.tv_nsec);
+			error = copyout(&old_value32, uap->old_value,
+			    sizeof(old_value32));
+		}
+	}
+	return (error);
+}
+
 int
 freebsd32_clock_getcpuclockid2(struct thread *td,
     struct freebsd32_clock_getcpuclockid2_args *uap)
diff --git a/sys/kern/sys_timerfd.c b/sys/kern/sys_timerfd.c
index a81b5ad0fade..e245baed88be 100644
--- a/sys/kern/sys_timerfd.c
+++ b/sys/kern/sys_timerfd.c
@@ -54,11 +54,6 @@
 
 #include <security/audit/audit.h>
 
-#ifdef COMPAT_FREEBSD32
-#include <compat/freebsd32/freebsd32.h>
-#include <compat/freebsd32/freebsd32_proto.h>
-#endif
-
 static MALLOC_DEFINE(M_TIMERFD, "timerfd", "timerfd structures");
 
 static struct mtx timerfd_list_lock;
@@ -598,59 +593,3 @@ sys_timerfd_settime(struct thread *td, struct timerfd_settime_args *uap)
 	}
 	return (error);
 }
-
-#ifdef COMPAT_FREEBSD32
-int
-freebsd32_timerfd_gettime(struct thread *td,
-    struct freebsd32_timerfd_gettime_args *uap)
-{
-	struct itimerspec curr_value;
-	struct itimerspec32 curr_value32;
-	int error;
-
-	error = kern_timerfd_gettime(td, uap->fd, &curr_value);
-	if (error == 0) {
-		CP(curr_value, curr_value32, it_value.tv_sec);
-		CP(curr_value, curr_value32, it_value.tv_nsec);
-		CP(curr_value, curr_value32, it_interval.tv_sec);
-		CP(curr_value, curr_value32, it_interval.tv_nsec);
-		error = copyout(&curr_value32, uap->curr_value,
-		    sizeof(curr_value32));
-	}
-
-	return (error);
-}
-
-int
-freebsd32_timerfd_settime(struct thread *td,
-    struct freebsd32_timerfd_settime_args *uap)
-{
-	struct itimerspec new_value, old_value;
-	struct itimerspec32 new_value32, old_value32;
-	int error;
-
-	error = copyin(uap->new_value, &new_value32, sizeof(new_value32));
-	if (error != 0)
-		return (error);
-	CP(new_value32, new_value, it_value.tv_sec);
-	CP(new_value32, new_value, it_value.tv_nsec);
-	CP(new_value32, new_value, it_interval.tv_sec);
-	CP(new_value32, new_value, it_interval.tv_nsec);
-	if (uap->old_value == NULL) {
-		error = kern_timerfd_settime(td, uap->fd, uap->flags,
-		    &new_value, NULL);
-	} else {
-		error = kern_timerfd_settime(td, uap->fd, uap->flags,
-		    &new_value, &old_value);
-		if (error == 0) {
-			CP(old_value, old_value32, it_value.tv_sec);
-			CP(old_value, old_value32, it_value.tv_nsec);
-			CP(old_value, old_value32, it_interval.tv_sec);
-			CP(old_value, old_value32, it_interval.tv_nsec);
-			error = copyout(&old_value32, uap->old_value,
-			    sizeof(old_value32));
-		}
-	}
-	return (error);
-}
-#endif



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