From d8c83ec5431d34f5dc59227f916ade04b7633a48 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Tue, 24 Nov 2020 16:27:53 +0000 Subject: [PATCH] fix build on 32bit architectures Some ffi tests depend on the pointer size. Added a variant for 32bit architectures. The conditional build for 32bit architectures is intentionally done on `not(target_pointer_width = "64")` so the test is not silently skipped on architectures with other pointer sizes. In case somebody really wants to use zmq-sys on 16 bit architectures, the test will fail and another variant for that pointer size would have to be added. --- zmq-sys/src/ffi.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/zmq-sys/src/ffi.rs b/zmq-sys/src/ffi.rs index 17e37fc88..0f5037ad9 100644 --- a/zmq-sys/src/ffi.rs +++ b/zmq-sys/src/ffi.rs @@ -415,6 +415,7 @@ pub struct zmq_pollitem_t { pub revents: ::std::os::raw::c_short, } #[test] +#[cfg(target_pointer_width = "64")] fn bindgen_test_layout_zmq_pollitem_t() { assert_eq!( ::std::mem::size_of::(), @@ -467,6 +468,59 @@ fn bindgen_test_layout_zmq_pollitem_t() { ) ); } +#[cfg(not(target_pointer_width = "64"))] +fn bindgen_test_layout_zmq_pollitem_t() { + assert_eq!( + ::std::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(zmq_pollitem_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(zmq_pollitem_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).socket as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(zmq_pollitem_t), + "::", + stringify!(socket) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).fd as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(zmq_pollitem_t), + "::", + stringify!(fd) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).events as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(zmq_pollitem_t), + "::", + stringify!(events) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).revents as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(zmq_pollitem_t), + "::", + stringify!(revents) + ) + ); +} impl Default for zmq_pollitem_t { fn default() -> Self { unsafe { ::std::mem::zeroed() }