diff --git a/build.rs b/build.rs index 4dcc271c..1fae18ce 100644 --- a/build.rs +++ b/build.rs @@ -162,6 +162,7 @@ fn main() { .blocklist_type("CK_FUNCTION_LIST_PTR") .blocklist_type("CK_FUNCTION_LIST_3_0_PTR") .blocklist_type("CK_INTERFACE") + .blocklist_var("CK_UNAVAILABLE_INFORMATION") .parse_callbacks(Box::new(Pkcs11Callbacks)) .generate() .expect("Unable to generate bindings") diff --git a/src/pkcs11/interface.rs b/src/pkcs11/interface.rs index 6656a1d0..67a34125 100644 --- a/src/pkcs11/interface.rs +++ b/src/pkcs11/interface.rs @@ -6,6 +6,14 @@ include!("bindings.rs"); // types that need different mutability than bindgen provides pub type CK_FUNCTION_LIST_PTR = *const CK_FUNCTION_LIST; pub type CK_FUNCTION_LIST_3_0_PTR = *const CK_FUNCTION_LIST_3_0; +// this is wrongly converted on 32b architecture to too large value +// which can not be represented in CK_ULONG. Docs says it cant have +// any other value so enumerate them here: +// https://doc.rust-lang.org/std/os/raw/type.c_ulong.html +#[cfg(target_pointer_width = "64")] +pub const CK_UNAVAILABLE_INFORMATION: CK_ULONG = u64::MAX; +#[cfg(target_pointer_width = "32")] +pub const CK_UNAVAILABLE_INFORMATION: CK_ULONG = u32::MAX; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct CK_INTERFACE {