mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 06:45:24 +00:00
std: better definition for std.os.linux.epoll_event
The previous definition depends on a non-lang-spec-compliant memory layout for packed structs, which happens to trigger #11989 in stage2. This commit changes the struct to be an extern struct with an align(4) field. However, stage1 cannot handle this, so conditional compilation logic is used to select different struct definitions depending on stage1 vs stage2. This works around #11989 but does not solve the underlying problem - putting an extern union inside a packed struct will still trigger the assert. After this, both stage1 and stage2 std lib tests run assertion-clean with a debug LLVM 13.
This commit is contained in:
parent
5735ce39ae
commit
314ce5465d
@ -3222,16 +3222,21 @@ pub const epoll_data = extern union {
|
||||
@"u64": u64,
|
||||
};
|
||||
|
||||
// On x86_64 the structure is packed so that it matches the definition of its
|
||||
// 32bit counterpart
|
||||
pub const epoll_event = switch (native_arch) {
|
||||
.x86_64 => packed struct {
|
||||
events: u32,
|
||||
data: epoll_data,
|
||||
pub const epoll_event = switch (builtin.zig_backend) {
|
||||
// stage1 crashes with the align(4) field so we have this workaround
|
||||
.stage1 => switch (native_arch) {
|
||||
.x86_64 => packed struct {
|
||||
events: u32,
|
||||
data: epoll_data,
|
||||
},
|
||||
else => extern struct {
|
||||
events: u32,
|
||||
data: epoll_data,
|
||||
},
|
||||
},
|
||||
else => extern struct {
|
||||
events: u32,
|
||||
data: epoll_data,
|
||||
data: epoll_data align(4),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user