From 4932d2376cc03c64eb82972824be673cdc2e0741 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 22 Sep 2020 18:26:53 +0200 Subject: Do not include layout tests in generated bindings We are generating the Rust bindings in src/ffi.rs using bindgen once for all platforms on an amd64 machine. These bindings previously included layout tests. But these tests fail on some 32-bit architecture. See this discussion for more information: https://lists.sr.ht/~ireas/nitrokey-rs-dev/%3C20200919182408.GA1513%40ireas.org%3E With this patch, we remove the layout tests from the generated bindings. Instead, we will add the option to re-generate the bindings, including the layout tests, during the build in the next patch. --- src/ffi.rs | 689 ------------------------------------------------------------- 1 file changed, 689 deletions(-) (limited to 'src') diff --git a/src/ffi.rs b/src/ffi.rs index d335280..94ac5ae 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -28,59 +28,6 @@ pub struct NK_device_info { #[doc = " if this is the last element in the list."] pub next: *mut NK_device_info, } -#[test] -fn bindgen_test_layout_NK_device_info() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(NK_device_info)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(NK_device_info)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).model as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NK_device_info), - "::", - stringify!(model) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).path as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(NK_device_info), - "::", - stringify!(path) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).serial_number as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(NK_device_info), - "::", - stringify!(serial_number) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).next as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(NK_device_info), - "::", - stringify!(next) - ) - ); -} impl Default for NK_device_info { fn default() -> Self { unsafe { ::std::mem::zeroed() } @@ -112,95 +59,6 @@ pub struct NK_status { #[doc = " an OTP value."] pub otp_user_password: bool, } -#[test] -fn bindgen_test_layout_NK_status() { - assert_eq!( - ::std::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(NK_status)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NK_status)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).firmware_version_major as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(firmware_version_major) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).firmware_version_minor as *const _ as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(firmware_version_minor) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serial_number_smart_card as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(serial_number_smart_card) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_numlock as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(config_numlock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_capslock as *const _ as usize }, - 9usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(config_capslock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).config_scrolllock as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(config_scrolllock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).otp_user_password as *const _ as usize }, - 11usize, - concat!( - "Offset of field: ", - stringify!(NK_status), - "::", - stringify!(otp_user_password) - ) - ); -} #[doc = " Stores the status of a Storage device."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -239,219 +97,6 @@ pub struct NK_storage_status { #[doc = " the AES keys."] pub stick_initialized: bool, } -#[test] -fn bindgen_test_layout_NK_storage_status() { - assert_eq!( - ::std::mem::size_of::(), - 28usize, - concat!("Size of: ", stringify!(NK_storage_status)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NK_storage_status)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).unencrypted_volume_read_only as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(unencrypted_volume_read_only) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).unencrypted_volume_active as *const _ - as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(unencrypted_volume_active) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).encrypted_volume_read_only as *const _ - as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(encrypted_volume_read_only) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).encrypted_volume_active as *const _ - as usize - }, - 3usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(encrypted_volume_active) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hidden_volume_read_only as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(hidden_volume_read_only) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).hidden_volume_active as *const _ as usize - }, - 5usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(hidden_volume_active) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).firmware_version_major as *const _ - as usize - }, - 6usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(firmware_version_major) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).firmware_version_minor as *const _ - as usize - }, - 7usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(firmware_version_minor) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).firmware_locked as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(firmware_locked) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serial_number_sd_card as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(serial_number_sd_card) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).serial_number_smart_card as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(serial_number_smart_card) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).user_retry_count as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(user_retry_count) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).admin_retry_count as *const _ as usize - }, - 21usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(admin_retry_count) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).new_sd_card_found as *const _ as usize - }, - 22usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(new_sd_card_found) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).filled_with_random as *const _ as usize - }, - 23usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(filled_with_random) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).stick_initialized as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_status), - "::", - stringify!(stick_initialized) - ) - ); -} #[doc = " Data about the usage of the SD card."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -463,43 +108,6 @@ pub struct NK_SD_usage_data { #[doc = " size."] pub write_level_max: u8, } -#[test] -fn bindgen_test_layout_NK_SD_usage_data() { - assert_eq!( - ::std::mem::size_of::(), - 2usize, - concat!("Size of: ", stringify!(NK_SD_usage_data)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(NK_SD_usage_data)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).write_level_min as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NK_SD_usage_data), - "::", - stringify!(write_level_min) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).write_level_max as *const _ as usize - }, - 1usize, - concat!( - "Offset of field: ", - stringify!(NK_SD_usage_data), - "::", - stringify!(write_level_max) - ) - ); -} #[doc = " The general configuration of a Nitrokey device."] #[repr(C)] #[derive(Debug, Default, Copy, Clone)] @@ -516,69 +124,6 @@ pub struct NK_config { #[doc = " Unused."] pub disable_user_password: bool, } -#[test] -fn bindgen_test_layout_NK_config() { - assert_eq!( - ::std::mem::size_of::(), - 5usize, - concat!("Size of: ", stringify!(NK_config)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(NK_config)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).numlock as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NK_config), - "::", - stringify!(numlock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).capslock as *const _ as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(NK_config), - "::", - stringify!(capslock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).scrolllock as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(NK_config), - "::", - stringify!(scrolllock) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).enable_user_password as *const _ as usize }, - 3usize, - concat!( - "Offset of field: ", - stringify!(NK_config), - "::", - stringify!(enable_user_password) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).disable_user_password as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(NK_config), - "::", - stringify!(disable_user_password) - ) - ); -} #[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct NK_storage_ProductionTest { @@ -596,187 +141,6 @@ pub struct NK_storage_ProductionTest { pub SD_WriteSpeed_u16: u16, pub SD_Card_Manufacturer_u8: u8, } -#[test] -fn bindgen_test_layout_NK_storage_ProductionTest() { - assert_eq!( - ::std::mem::size_of::(), - 28usize, - concat!("Size of: ", stringify!(NK_storage_ProductionTest)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NK_storage_ProductionTest)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).FirmwareVersion_au8 as *const _ - as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(FirmwareVersion_au8) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).FirmwareVersionInternal_u8 - as *const _ as usize - }, - 2usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(FirmwareVersionInternal_u8) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_Card_Size_u8 as *const _ - as usize - }, - 3usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_Card_Size_u8) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).CPU_CardID_u32 as *const _ - as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(CPU_CardID_u32) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SmartCardID_u32 as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SmartCardID_u32) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_CardID_u32 as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_CardID_u32) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SC_UserPwRetryCount as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SC_UserPwRetryCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SC_AdminPwRetryCount as *const _ - as usize - }, - 17usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SC_AdminPwRetryCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_Card_ManufacturingYear_u8 - as *const _ as usize - }, - 18usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_Card_ManufacturingYear_u8) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_Card_ManufacturingMonth_u8 - as *const _ as usize - }, - 19usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_Card_ManufacturingMonth_u8) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_Card_OEM_u16 as *const _ - as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_Card_OEM_u16) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_WriteSpeed_u16 as *const _ - as usize - }, - 22usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_WriteSpeed_u16) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).SD_Card_Manufacturer_u8 - as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(NK_storage_ProductionTest), - "::", - stringify!(SD_Card_Manufacturer_u8) - ) - ); -} extern "C" { pub fn NK_get_storage_production_info( out: *mut NK_storage_ProductionTest, @@ -1548,59 +912,6 @@ pub struct ReadSlot_t { pub slot_token_id: [u8; 13usize], pub slot_counter: u64, } -#[test] -fn bindgen_test_layout_ReadSlot_t() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(ReadSlot_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(ReadSlot_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot_name as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(ReadSlot_t), - "::", - stringify!(slot_name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::()))._slot_config as *const _ as usize }, - 15usize, - concat!( - "Offset of field: ", - stringify!(ReadSlot_t), - "::", - stringify!(_slot_config) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot_token_id as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(ReadSlot_t), - "::", - stringify!(slot_token_id) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).slot_counter as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(ReadSlot_t), - "::", - stringify!(slot_counter) - ) - ); -} extern "C" { pub fn NK_read_HOTP_slot(slot_num: u8, out: *mut ReadSlot_t) -> ::std::os::raw::c_int; } -- cgit v1.2.1