Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142191812
D54663.id169851.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D54663.id169851.diff
View Options
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
@@ -36,8 +36,18 @@
#include <sys/_ffcounter.h>
/*
- * i386 is the only arch with a 32-bit time_t
+ * 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 val1;
+ uint32_t val2;
+#else
+ uint64_t val;
+#endif
+} freebsd32_uint64_t;
+
#ifdef __amd64__
typedef int32_t time32_t;
#else
@@ -61,7 +71,7 @@
struct bintime32 {
time32_t sec;
- uint32_t frac[2];
+ freebsd32_uint64_t frac;
};
struct ffclock_estimate32 {
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
@@ -67,9 +67,17 @@
TS_CP((src), (dst), it_value); \
} while (0)
+#define FU64_CP(src, dst, fld) do { \
+ _Static_assert(sizeof((src).fld) == sizeof(uint64_t), \
+ "FU64_CP src: " #src "." #fld "is not 8 bytes"); \
+ _Static_assert(sizeof((dst).fld) == sizeof(uint64_t), \
+ "FU64_CP dst: " #dst "." #fld "is not 8 bytes"); \
+ memcpy(&(dst).fld, &(src).fld, sizeof(uint64_t)); \
+} while (0)
+
#define BT_CP(src, dst, fld) do { \
CP((src).fld, (dst).fld, sec); \
- *(uint64_t *)&(dst).fld.frac[0] = (src).fld.frac; \
+ FU64_CP((src).fld, (dst).fld, frac); \
} while (0)
#endif /* !_COMPAT_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 18, 1:07 AM (2 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27702371
Default Alt Text
D54663.id169851.diff (1 KB)
Attached To
Mode
D54663: sys/abi_compat.h: fix UB
Attached
Detach File
Event Timeline
Log In to Comment