Skip to content

Commit 8136462

Browse files
committed
epoll: use repr(packed) for EpollEvent
otherwise it may cause alignment issue Signed-off-by: Tianhao Wang <[email protected]> Suggested-by: Yiliang Dong <[email protected]>
1 parent fbf09b9 commit 8136462

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

qlib/kernel/kernel/epoll/epoll.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub unsafe fn InitSingleton() {
4949
// format to avoid extra copying/allocation when writing events to userspace.
5050
#[cfg(target_arch = "x86_64")]
5151
#[derive(Default, Clone, Copy, Debug)]
52+
#[repr(packed)]
5253
#[repr(C)]
5354
pub struct Event {
5455
// Events is the event mask containing the set of events that have been
@@ -62,6 +63,7 @@ pub struct Event {
6263

6364
#[cfg(target_arch = "aarch64")]
6465
#[derive(Default, Clone, Copy, Debug)]
66+
#[repr(packed)]
6567
#[repr(C)]
6668
pub struct Event {
6769
// Events is the event mask containing the set of events that have been

qlib/linux_def.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ pub struct LibcSysinfo {
260260
}
261261

262262
#[cfg(target_arch = "x86_64")]
263+
#[repr(packed)]
263264
#[repr(C)]
264265
#[derive(Debug, Default, Copy, Clone)]
265266
pub struct EpollEvent {
@@ -268,6 +269,7 @@ pub struct EpollEvent {
268269
}
269270

270271
#[cfg(target_arch = "aarch64")]
272+
#[repr(packed)]
271273
#[repr(C)]
272274
#[derive(Debug, Default, Copy, Clone)]
273275
pub struct EpollEvent {

0 commit comments

Comments
 (0)