From 9e11dca89e8df270420e5c42aa51e1528c6799b3 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Tue, 29 Oct 2024 12:02:25 +0100 Subject: [PATCH] bindings: Create 32b compatible bindings This is a workaround for a bindgen, not setting the correct value for unsigned long constants: https://github.com/rust-lang/rust-bindgen/issues/2965 Remove when the above issue is fixed. Signed-off-by: Jakub Jelen --- build.rs | 1 + src/pkcs11/interface.rs | 3 +++ 2 files changed, 4 insertions(+) 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 40997961..463e08fb 100644 --- a/src/pkcs11/interface.rs +++ b/src/pkcs11/interface.rs @@ -6,6 +6,9 @@ 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. +pub const CK_UNAVAILABLE_INFORMATION: CK_ULONG = CK_ULONG::MAX; #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct CK_INTERFACE {