aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-09-22 18:26:53 +0200
committerRobin Krahl <robin.krahl@ireas.org>2020-09-22 18:26:53 +0200
commit4932d2376cc03c64eb82972824be673cdc2e0741 (patch)
treed1690533683e8fe33be00e4b1eb32f9363f207b4 /src
parent7944af959ca0b48f0e8ea5c506e801e07a6b8124 (diff)
downloadnitrokey-sys-rs-4932d2376cc03c64eb82972824be673cdc2e0741.tar.gz
nitrokey-sys-rs-4932d2376cc03c64eb82972824be673cdc2e0741.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/ffi.rs689
1 files changed, 0 insertions, 689 deletions
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::<NK_device_info>(),
- 32usize,
- concat!("Size of: ", stringify!(NK_device_info))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_device_info>(),
- 8usize,
- concat!("Alignment of ", stringify!(NK_device_info))
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).model as *const _ as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(model)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).path as *const _ as usize },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(path)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).serial_number as *const _ as usize },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_device_info),
- "::",
- stringify!(serial_number)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_device_info>())).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::<NK_status>(),
- 12usize,
- concat!("Size of: ", stringify!(NK_status))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_status>(),
- 4usize,
- concat!("Alignment of ", stringify!(NK_status))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_status>())).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::<NK_status>())).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::<NK_status>())).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::<NK_status>())).config_numlock as *const _ as usize },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(config_numlock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).config_capslock as *const _ as usize },
- 9usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(config_capslock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).config_scrolllock as *const _ as usize },
- 10usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_status),
- "::",
- stringify!(config_scrolllock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_status>())).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::<NK_storage_status>(),
- 28usize,
- concat!("Size of: ", stringify!(NK_storage_status))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_storage_status>(),
- 4usize,
- concat!("Alignment of ", stringify!(NK_storage_status))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).firmware_locked as *const _ as usize
- },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_status),
- "::",
- stringify!(firmware_locked)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_storage_status>())).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::<NK_SD_usage_data>(),
- 2usize,
- concat!("Size of: ", stringify!(NK_SD_usage_data))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_SD_usage_data>(),
- 1usize,
- concat!("Alignment of ", stringify!(NK_SD_usage_data))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_SD_usage_data>())).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::<NK_SD_usage_data>())).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::<NK_config>(),
- 5usize,
- concat!("Size of: ", stringify!(NK_config))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_config>(),
- 1usize,
- concat!("Alignment of ", stringify!(NK_config))
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_config>())).numlock as *const _ as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_config),
- "::",
- stringify!(numlock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_config>())).capslock as *const _ as usize },
- 1usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_config),
- "::",
- stringify!(capslock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_config>())).scrolllock as *const _ as usize },
- 2usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_config),
- "::",
- stringify!(scrolllock)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<NK_config>())).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::<NK_config>())).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::<NK_storage_ProductionTest>(),
- 28usize,
- concat!("Size of: ", stringify!(NK_storage_ProductionTest))
- );
- assert_eq!(
- ::std::mem::align_of::<NK_storage_ProductionTest>(),
- 4usize,
- concat!("Alignment of ", stringify!(NK_storage_ProductionTest))
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).FirmwareVersion_au8 as *const _
- as usize
- },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(FirmwareVersion_au8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).FirmwareVersionInternal_u8
- as *const _ as usize
- },
- 2usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(FirmwareVersionInternal_u8)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).SmartCardID_u32 as *const _
- as usize
- },
- 8usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SmartCardID_u32)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).SC_UserPwRetryCount as *const _
- as usize
- },
- 16usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SC_UserPwRetryCount)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SC_AdminPwRetryCount as *const _
- as usize
- },
- 17usize,
- concat!(
- "Offset of field: ",
- stringify!(NK_storage_ProductionTest),
- "::",
- stringify!(SC_AdminPwRetryCount)
- )
- );
- assert_eq!(
- unsafe {
- &(*(::std::ptr::null::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).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::<NK_storage_ProductionTest>())).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::<ReadSlot_t>(),
- 40usize,
- concat!("Size of: ", stringify!(ReadSlot_t))
- );
- assert_eq!(
- ::std::mem::align_of::<ReadSlot_t>(),
- 8usize,
- concat!("Alignment of ", stringify!(ReadSlot_t))
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>())).slot_name as *const _ as usize },
- 0usize,
- concat!(
- "Offset of field: ",
- stringify!(ReadSlot_t),
- "::",
- stringify!(slot_name)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>()))._slot_config as *const _ as usize },
- 15usize,
- concat!(
- "Offset of field: ",
- stringify!(ReadSlot_t),
- "::",
- stringify!(_slot_config)
- )
- );
- assert_eq!(
- unsafe { &(*(::std::ptr::null::<ReadSlot_t>())).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::<ReadSlot_t>())).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;
}