Skip to content

Commit

Permalink
bindings: Create 32b compatible bindings
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje committed Oct 29, 2024
1 parent 8f23768 commit 629c1da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions src/pkcs11/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 can't 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 {
Expand Down

0 comments on commit 629c1da

Please sign in to comment.