epoll_data alignement problem #3879
Unanswered
Stargateur
asked this question in
Q&A
Replies: 2 comments
-
Reading more deeply I may have miss interpreted the alignment 1, it's only work for field of size 1 like |
Beta Was this translation helpful? Give feedback.
0 replies
-
How about using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
rust-lang/rust#46043 introduce a problem concerning
epoll_data
. I didn't find a way to assume it safe for me to take a reference ofu64
orevents
.My crate define a struct:
This allow me to copy layout from
libc::epoll_event
on every os very easily without the need to handle every os layout myself but this disallow me to know when the alignment of the struct is 1.For
events
is not a big deal for me cause I just copy according to the linked issue the compiler will handle it correctly but my use ofu64
can't allow copy.Is there a rust cfg like
cfg_attr(aligned_is(1))
or something like that ? With this I could assume is safe to take using unsafe and if aligned is not 1 I can use a code that doesn't use unsafe letting the compiler check the safety for me.Without something like this is become very hard for me to use
libc::epoll_event
. I need to assume that the packed structure is 1 aligned. Of course I expect every OS that use a packedlibc::epoll_event
should be#[repr(packed(1))]
so it should not be a big deal but nothing prevent an OS to do that.Beta Was this translation helpful? Give feedback.
All reactions