Page MenuHomeFreeBSD

D55135.id171282.diff
No OneTemporary

D55135.id171282.diff

diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -38,24 +38,6 @@
#include <sys/user.h>
#include <sys/_ffcounter.h>
-/*
- * i386 is the only arch with a 32-bit time_t.
- * Also it is the only arch with (u)int64_t having 4-bytes alignment.
- */
-typedef struct {
-#ifdef __amd64__
- uint32_t val[2];
-#else
- uint64_t val;
-#endif
-} freebsd32_uint64_t;
-
-#ifdef __amd64__
-typedef int32_t time32_t;
-#else
-typedef int64_t time32_t;
-#endif
-
struct timeval32 {
time32_t tv_sec;
int32_t tv_usec;
@@ -80,7 +62,7 @@
struct bintime32 update_time;
ffcounter update_ffcount;
ffcounter leapsec_next;
- uint64_t period;
+ freebsd32_uint64_t period;
uint32_t errb_abs;
uint32_t errb_rate;
uint32_t status;
@@ -248,12 +230,12 @@
#endif
struct timespec32 st_birthtim;
off_t st_size;
- int64_t st_blocks;
+ freebsd32_uint64_t st_blocks;
uint32_t st_blksize;
uint32_t st_flags;
- uint64_t st_gen;
- uint64_t st_filerev;
- uint64_t st_spare[9];
+ freebsd32_uint64_t st_gen;
+ freebsd32_uint64_t st_filerev;
+ freebsd32_uint64_t st_spare[9];
};
struct freebsd11_stat32 {
uint32_t st_dev;
@@ -267,7 +249,7 @@
struct timespec32 st_mtim;
struct timespec32 st_ctim;
off_t st_size;
- int64_t st_blocks;
+ freebsd32_uint64_t st_blocks;
uint32_t st_blksize;
uint32_t st_flags;
uint32_t st_gen;
@@ -392,7 +374,7 @@
u_int ki_slptime;
u_int ki_swtime;
u_int ki_cow;
- uint64_t ki_runtime;
+ freebsd32_uint64_t ki_runtime;
struct timeval32 ki_start;
struct timeval32 ki_childtime;
int ki_flag;
@@ -414,7 +396,7 @@
char ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
char ki_sparestrings[46];
int ki_spareints[KI_NSPARE_INT];
- uint64_t ki_tdev;
+ freebsd32_uint64_t ki_tdev;
int ki_oncpu;
int ki_lastcpu;
int ki_tracer;
@@ -431,6 +413,7 @@
uint32_t ki_kstack;
uint32_t ki_udata;
uint32_t ki_tdaddr;
+ uint32_t ki_pd;
uint32_t ki_uerrmsg;
uint32_t ki_spareptrs[KI_NSPARE_PTR]; /* spare room for growth */
int ki_sparelongs[KI_NSPARE_LONG];
@@ -469,12 +452,12 @@
union {
struct {
int knt_vnode_type;
- uint32_t knt_vnode_fsid[2];
- uint32_t knt_vnode_fileid[2];
+ freebsd32_uint64_t knt_vnode_fsid;
+ freebsd32_uint64_t knt_vnode_fileid;
char knt_vnode_fullpath[PATH_MAX];
} knt_vnode;
struct {
- uint32_t knt_pipe_ino[2];
+ freebsd32_uint64_t knt_pipe_ino;
} knt_pipe;
};
};
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -713,31 +713,16 @@
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
@@ -754,38 +739,12 @@
break;
case KNOTE_EXTDATA_VNODE:
CP(*kin, *kin32, knt_vnode.knt_vnode_type);
-#if BYTE_ORDER == LITTLE_ENDIAN
- kin32->knt_vnode.knt_vnode_fsid[0] = kin->knt_vnode.
- knt_vnode_fsid;
- kin32->knt_vnode.knt_vnode_fsid[1] = kin->knt_vnode.
- knt_vnode_fsid >> 32;
- kin32->knt_vnode.knt_vnode_fileid[0] = kin->knt_vnode.
- knt_vnode_fileid;
- kin32->knt_vnode.knt_vnode_fileid[1] = kin->knt_vnode.
- knt_vnode_fileid >> 32;
-#else
- kin32->knt_vnode.knt_vnode_fsid[1] = kin->knt_vnode.
- knt_vnode_fsid;
- kin32->knt_vnode.knt_vnode_fsid[0] = kin->knt_vnode.
- knt_vnode_fsid >> 32;
- kin32->knt_vnode.knt_vnode_fileid[1] = kin->knt_vnode.
- knt_vnode_fileid;
- kin32->knt_vnode.knt_vnode_fileid[0] = kin->knt_vnode.
- knt_vnode_fileid >> 32;
-#endif
+ FU64_CP(*kin, *kin32, knt_vnode.knt_vnode_fsid);
memcpy(kin32->knt_vnode.knt_vnode_fullpath,
kin->knt_vnode.knt_vnode_fullpath, PATH_MAX);
break;
case KNOTE_EXTDATA_PIPE:
-#if BYTE_ORDER == LITTLE_ENDIAN
- kin32->knt_pipe.knt_pipe_ino[0] = kin->knt_pipe.knt_pipe_ino;
- kin32->knt_pipe.knt_pipe_ino[1] = kin->knt_pipe.
- knt_pipe_ino >> 32;
-#else
- kin32->knt_pipe.knt_pipe_ino[1] = kin->knt_pipe.knt_pipe_ino;
- kin32->knt_pipe.knt_pipe_ino[0] = kin->knt_pipe.
- knt_pipe_ino >> 32;
-#endif
+ FU64_CP(*kin, *kin32, knt_pipe.knt_pipe_ino);
break;
}
}
@@ -819,7 +778,6 @@
{
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 +793,10 @@
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);
@@ -2338,11 +2286,11 @@
TS_CP(*in, *out, st_mtim);
TS_CP(*in, *out, st_ctim);
CP(*in, *out, st_size);
- CP(*in, *out, st_blocks);
+ FU64_CP(*in, *out, st_blocks);
CP(*in, *out, st_blksize);
CP(*in, *out, st_flags);
- CP(*in, *out, st_gen);
- CP(*in, *out, st_filerev);
+ FU64_CP(*in, *out, st_gen);
+ FU64_CP(*in, *out, st_filerev);
CP(*in, *out, st_bsdflags);
TS_CP(*in, *out, st_birthtim);
out->st_padding1 = 0;
@@ -2551,7 +2499,7 @@
TS_CP(*in, *out, st_mtim);
TS_CP(*in, *out, st_ctim);
CP(*in, *out, st_size);
- CP(*in, *out, st_blocks);
+ FU64_CP(*in, *out, st_blocks);
CP(*in, *out, st_blksize);
CP(*in, *out, st_flags);
CP(*in, *out, st_gen);
@@ -4200,7 +4148,7 @@
memcpy(&cest.update_time.frac, &cest32.update_time.frac, sizeof(uint64_t));
CP(cest, cest32, update_ffcount);
CP(cest, cest32, leapsec_next);
- CP(cest, cest32, period);
+ FU64_CP(cest, cest32, period);
CP(cest, cest32, errb_abs);
CP(cest, cest32, errb_rate);
CP(cest, cest32, status);
@@ -4230,7 +4178,7 @@
memcpy(&cest32.update_time.frac, &cest.update_time.frac, sizeof(uint64_t));
CP(cest32, cest, update_ffcount);
CP(cest32, cest, leapsec_next);
- CP(cest32, cest, period);
+ FU64_CP(cest32, cest, period);
CP(cest32, cest, errb_abs);
CP(cest32, cest, errb_rate);
CP(cest32, cest, status);
diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c
--- a/sys/dev/mfi/mfi.c
+++ b/sys/dev/mfi/mfi.c
@@ -3084,8 +3084,6 @@
return (error);
}
-#define PTRIN(p) ((void *)(uintptr_t)(p))
-
static int
mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
{
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1437,7 +1437,7 @@
CP(*ki, *ki32, ki_sid);
CP(*ki, *ki32, ki_tsid);
CP(*ki, *ki32, ki_jobc);
- CP(*ki, *ki32, ki_tdev);
+ FU64_CP(*ki, *ki32, ki_tdev);
CP(*ki, *ki32, ki_tdev_freebsd11);
CP(*ki, *ki32, ki_siglist);
CP(*ki, *ki32, ki_sigmask);
@@ -1464,7 +1464,7 @@
CP(*ki, *ki32, ki_slptime);
CP(*ki, *ki32, ki_swtime);
CP(*ki, *ki32, ki_cow);
- CP(*ki, *ki32, ki_runtime);
+ FU64_CP(*ki, *ki32, ki_runtime);
TV_CP(*ki, *ki32, ki_start);
TV_CP(*ki, *ki32, ki_childtime);
CP(*ki, *ki32, ki_flag);
@@ -1503,6 +1503,7 @@
PTRTRIM_CP(*ki, *ki32, ki_kstack);
PTRTRIM_CP(*ki, *ki32, ki_udata);
PTRTRIM_CP(*ki, *ki32, ki_tdaddr);
+ PTRTRIM_CP(*ki, *ki32, ki_pd);
CP(*ki, *ki32, ki_sflag);
CP(*ki, *ki32, ki_tdflags);
PTRTRIM_CP(*ki, *ki32, ki_uerrmsg);
diff --git a/sys/sys/abi_compat.h b/sys/sys/abi_compat.h
--- a/sys/sys/abi_compat.h
+++ b/sys/sys/abi_compat.h
@@ -4,6 +4,11 @@
* Copyright (c) 2001 Doug Rabson
* All rights reserved.
*
+ * Copyright 2026 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -26,13 +31,33 @@
* SUCH DAMAGE.
*/
-#ifndef _COMPAT_H_
-#define _COMPAT_H_
+#ifndef _ABI_COMPAT_H_
+#define _ABI_COMPAT_H_
+
+#include <sys/_types.h>
/*
- * Helper macros for translating objects between different ABIs.
+ * Helper types and macros for translating objects between different ABIs.
*/
+/*
+ * i386 is the only arch with a 32-bit time_t.
+ * Also it is the only arch with (u)int64_t having 4-bytes alignment.
+ */
+typedef struct {
+#ifdef __amd64__
+ __uint32_t val[2];
+#else
+ __uint64_t val;
+#endif
+} freebsd32_uint64_t;
+
+#ifdef __amd64__
+typedef __int32_t time32_t;
+#else
+typedef __int64_t time32_t;
+#endif
+
#define PTRIN(v) (void *)(uintptr_t)(v)
#define PTROUT(v) (uintptr_t)(v)
@@ -80,4 +105,4 @@
FU64_CP((src).fld, (dst).fld, frac); \
} while (0)
-#endif /* !_COMPAT_H_ */
+#endif /* !_ABI_COMPAT_H_ */
diff --git a/sys/sys/event.h b/sys/sys/event.h
--- a/sys/sys/event.h
+++ b/sys/sys/event.h
@@ -104,6 +104,8 @@
#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 @@
#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

File Metadata

Mime Type
text/plain
Expires
Wed, Aug 5, 1:57 AM (16 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35980565
Default Alt Text
D55135.id171282.diff (9 KB)

Event Timeline