Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145493701
D54663.id169500.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.id169500.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
@@ -37,6 +37,7 @@
/*
* 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.
*/
#ifdef __amd64__
typedef int32_t time32_t;
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
@@ -29,6 +29,8 @@
#ifndef _COMPAT_H_
#define _COMPAT_H_
+#include <sys/endian.h>
+
/*
* Helper macros for translating objects between different ABIs.
*/
@@ -67,9 +69,18 @@
TS_CP((src), (dst), it_value); \
} while (0)
+#if _BYTE_ORDER == _LITTLE_ENDIAN
#define BT_CP(src, dst, fld) do { \
CP((src).fld, (dst).fld, sec); \
- *(uint64_t *)&(dst).fld.frac[0] = (src).fld.frac; \
+ (dst).fld.frac[0] = (src).fld.frac; \
+ (dst).fld.frac[1] = (src).fld.frac >> 32; \
} while (0)
+#elif _BYTE_ORDER == _BIG_ENDIAN
+#define BT_CP(src, dst, fld) do { \
+ CP((src).fld, (dst).fld, sec); \
+ (dst).fld.frac[0] = (src).fld.frac >> 32; \
+ (dst).fld.frac[1] = (src).fld.frac; \
+} while (0)
+#endif
#endif /* !_COMPAT_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 21, 1:06 PM (1 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28923066
Default Alt Text
D54663.id169500.diff (1 KB)
Attached To
Mode
D54663: sys/abi_compat.h: fix UB
Attached
Detach File
Event Timeline
Log In to Comment