From dc1956e2efed951b9cfaa64109956707859c0573 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Sun, 15 Apr 2018 14:45:26 +0200 Subject: [PATCH] fix undefined behavior due to incorrect packing on macosx --- libc-test/build.rs | 3 --- src/unix/bsd/apple/mod.rs | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 0f4efdca..9805ef0e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -416,9 +416,6 @@ fn main() { // which is absent in glibc, has to be defined. "__timeval" if linux => true, - // The alignment of this is 4 on 64-bit OSX... - "kevent" | "shmid_ds" if apple && x86_64 => true, - // This is actually a union, not a struct "sigval" => true, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 9cd5db65..00110e13 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -245,7 +245,7 @@ s! { pub f_reserved: [::uint32_t; 8], } - // FIXME: this should have align 4 but it's got align 8 on 64-bit + #[repr(packed(4))] pub struct kevent { pub ident: ::uintptr_t, pub filter: ::int16_t, @@ -524,7 +524,7 @@ s! { pub _key: ::key_t, } - // FIXME: this should have align 4 but it's got align 8 on 64-bit + #[repr(packed(4))] pub struct shmid_ds { pub shm_perm: ipc_perm, pub shm_segsz: ::size_t,