From 771f543cb5a9c0bd548191142ac2a7433b2ef8c4 Mon Sep 17 00:00:00 2001 From: Aydin Mercan Date: Sat, 5 Nov 2022 16:12:38 +0300 Subject: [PATCH] bearssl-sys: use bindgen's usize setting * `bindgen` can now set size_t as usize. This should remove the annoying type definition. --- bearssl-sys/README.md | 6 ------ bearssl-sys/build/main.rs | 3 +++ bearssl-sys/src/lib.rs | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bearssl-sys/README.md b/bearssl-sys/README.md index aae90c8..0c61a60 100644 --- a/bearssl-sys/README.md +++ b/bearssl-sys/README.md @@ -11,12 +11,6 @@ Currently BearSSL 0.6 and latest Rust stable is supported. * `bundled`: Build and link statically BearSSL. Needs a working C compiler and autoenables some sensible flags for the build target. * `dont-assume-size_t-equals-uintptr_t`: Use libc's `size_t` instead of `usize`. Should only needed when `sizeof(uintptr_t) != sizeof(size_t)`. -## Misc. - -Once `core::ffi` types are stable, the bindings can and should be -dependency-free for platforms where `dont-assume-size_t-equals-uintptr_t` -isn't required. - ## License This repository is licensed under the BSD-3-Clause. Please refer to `LICENSE` and diff --git a/bearssl-sys/build/main.rs b/bearssl-sys/build/main.rs index ff4c5dd..900d204 100644 --- a/bearssl-sys/build/main.rs +++ b/bearssl-sys/build/main.rs @@ -5,6 +5,8 @@ use std::path::PathBuf; fn main() { linkage::configure(); + let usize_equals_size_t = !cfg!(feature = "dont-assume-size_t-equals-uintptr_t"); + let bindings = bindgen::builder() .use_core() .ctypes_prefix("::core::ffi") @@ -17,6 +19,7 @@ fn main() { .blocklist_type("__.*_t") .blocklist_type("size_t") .generate_comments(false) + .size_t_is_usize(usize_equals_size_t) .generate() .expect("Unable to generate bindings"); diff --git a/bearssl-sys/src/lib.rs b/bearssl-sys/src/lib.rs index f297c0a..916cf82 100644 --- a/bearssl-sys/src/lib.rs +++ b/bearssl-sys/src/lib.rs @@ -15,7 +15,4 @@ #[cfg(feature = "dont-assume-size_t-equals-uintptr_t")] use libc::size_t; -#[cfg(not(feature = "dont-assume-size_t-equals-uintptr_t"))] -type size_t = usize; - include!(concat!(env!("OUT_DIR"), "/bindings.rs"));