Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Feb 2026 19:06:58 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ad639400dc9f - main - sys/event.h: use freebsd32_uint64_t for kevent32 64bit members
Message-ID:  <698a3052.36544.6d7c1a7c@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kib:

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

commit ad639400dc9f1c5aec470996473bb54edc113dba
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-02-05 19:22:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-02-09 18:57:19 +0000

    sys/event.h: use freebsd32_uint64_t for kevent32 64bit members
    
    Reviewed by:    brooks
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D55135
---
 sys/compat/freebsd32/freebsd32_misc.c | 38 ++++++-----------------------------
 sys/sys/event.h                       |  6 ++++--
 usr.bin/kdump/kdump.c                 |  6 +-----
 3 files changed, 11 insertions(+), 39 deletions(-)

diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index c76c9d5c1838..544842803e21 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -713,31 +713,16 @@ freebsd32_pselect(struct thread *td, struct freebsd32_pselect_args *uap)
 static void
 freebsd32_kevent_to_kevent32(const struct kevent *kevp, struct kevent32 *ks32)
 {
-	uint64_t e;
 	int j;
 
 	CP(*kevp, *ks32, ident);
 	CP(*kevp, *ks32, filter);
 	CP(*kevp, *ks32, flags);
 	CP(*kevp, *ks32, fflags);
-#if BYTE_ORDER == LITTLE_ENDIAN
-	ks32->data1 = kevp->data;
-	ks32->data2 = kevp->data >> 32;
-#else
-	ks32->data1 = kevp->data >> 32;
-	ks32->data2 = kevp->data;
-#endif
+	FU64_CP(*kevp, *ks32, data);
 	PTROUT_CP(*kevp, *ks32, udata);
-	for (j = 0; j < nitems(kevp->ext); j++) {
-		e = kevp->ext[j];
-#if BYTE_ORDER == LITTLE_ENDIAN
-		ks32->ext64[2 * j] = e;
-		ks32->ext64[2 * j + 1] = e >> 32;
-#else
-		ks32->ext64[2 * j] = e >> 32;
-		ks32->ext64[2 * j + 1] = e;
-#endif
-	}
+	for (j = 0; j < nitems(kevp->ext); j++)
+		FU64_CP(*kevp, *ks32, ext[j]);
 }
 
 void
@@ -819,7 +804,6 @@ freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count)
 {
 	struct freebsd32_kevent_args *uap;
 	struct kevent32	ks32[KQ_NEVENTS];
-	uint64_t e;
 	int i, j, error;
 
 	KASSERT(count <= KQ_NEVENTS, ("count (%d) > KQ_NEVENTS", count));
@@ -835,20 +819,10 @@ freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count)
 		CP(ks32[i], kevp[i], filter);
 		CP(ks32[i], kevp[i], flags);
 		CP(ks32[i], kevp[i], fflags);
-		kevp[i].data = PAIR32TO64(uint64_t, ks32[i].data);
+		FU64_CP(ks32[i], kevp[i], data);
 		PTRIN_CP(ks32[i], kevp[i], udata);
-		for (j = 0; j < nitems(kevp->ext); j++) {
-#if BYTE_ORDER == LITTLE_ENDIAN
-			e = ks32[i].ext64[2 * j + 1];
-			e <<= 32;
-			e += ks32[i].ext64[2 * j];
-#else
-			e = ks32[i].ext64[2 * j];
-			e <<= 32;
-			e += ks32[i].ext64[2 * j + 1];
-#endif
-			kevp[i].ext[j] = e;
-		}
+		for (j = 0; j < nitems(kevp->ext); j++)
+			FU64_CP(ks32[i], kevp[i], ext[j]);
 	}
 done:
 	return (error);
diff --git a/sys/sys/event.h b/sys/sys/event.h
index ebbcdb703183..0ba8e4796208 100644
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -104,6 +104,8 @@ struct freebsd11_kevent {
 #endif
 
 #if defined(_WANT_KEVENT32) || defined(_KERNEL)
+#include <sys/abi_compat.h>
+
 struct kevent32 {
 	__uint32_t	ident;		/* identifier for this event */
 	short		filter;		/* filter for event */
@@ -112,12 +114,12 @@ struct kevent32 {
 #ifndef __amd64__
 	__uint32_t	pad0;
 #endif
-	__uint32_t	data1, data2;
+	freebsd32_uint64_t data;
 	__uint32_t	udata;		/* opaque user data identifier */
 #ifndef __amd64__
 	__uint32_t	pad1;
 #endif
-	__uint32_t	ext64[8];
+	freebsd32_uint64_t ext[4];
 };
 
 #ifdef _WANT_FREEBSD11_KEVENT
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 17ed43b55c5a..d3f2ac882e61 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -2404,11 +2404,7 @@ ktrstructarray(struct ktr_struct_array *ksa, size_t buflen)
 			kev.filter = kev32.filter;
 			kev.flags = kev32.flags;
 			kev.fflags = kev32.fflags;
-#if BYTE_ORDER == BIG_ENDIAN
-			kev.data = kev32.data2 | ((int64_t)kev32.data1 << 32);
-#else
-			kev.data = kev32.data1 | ((int64_t)kev32.data2 << 32);
-#endif
+			memcpy(&kev.data, &kev32.data, sizeof(kev.data));
 			kev.udata = (void *)(uintptr_t)kev32.udata;
 			ktrkevent(&kev);
 		} else if (strcmp(name, "freebsd11_kevent32") == 0) {


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?698a3052.36544.6d7c1a7c>