1#![cfg_attr(not(clippy), allow(unexpected_cfgs))]
5#![cfg_attr(not(clippy), allow(unknown_lints))]
6
7#[allow(unused_macros)]
8macro_rules! use_bindings {
9 ($bindings:ident) => {
10 mod $bindings;
11 pub use $bindings::*;
12 };
13}
14
15macro_rules! platform_binding {
16 ($platform:ident, $platform_crypto:ident) => {
17 #[cfg(all($platform, not(feature = "ssl"), not(use_bindgen_pregenerated)))]
18 use_bindings!($platform_crypto);
19 };
20}
21
22platform_binding!(aarch64_apple_darwin, aarch64_apple_darwin_crypto);
23platform_binding!(aarch64_unknown_linux_gnu, aarch64_unknown_linux_gnu_crypto);
24platform_binding!(
25 aarch64_unknown_linux_musl,
26 aarch64_unknown_linux_musl_crypto
27);
28platform_binding!(x86_64_apple_darwin, x86_64_apple_darwin_crypto);
29platform_binding!(x86_64_unknown_linux_gnu, x86_64_unknown_linux_gnu_crypto);
30platform_binding!(x86_64_unknown_linux_musl, x86_64_unknown_linux_musl_crypto);
31
32#[cfg(use_bindgen_pregenerated)]
33#[allow(
34 clippy::cast_lossless,
35 clippy::cast_possible_truncation,
36 clippy::cast_possible_wrap,
37 clippy::default_trait_access,
38 clippy::doc_markdown,
39 clippy::missing_safety_doc,
40 clippy::must_use_candidate,
41 clippy::not_unsafe_ptr_arg_deref,
42 clippy::ptr_as_ptr,
43 clippy::ptr_offset_with_cast,
44 clippy::pub_underscore_fields,
45 clippy::semicolon_if_nothing_returned,
46 clippy::too_many_lines,
47 clippy::unreadable_literal,
48 clippy::used_underscore_binding,
49 clippy::useless_transmute,
50 dead_code,
51 improper_ctypes,
52 non_camel_case_types,
53 non_snake_case,
54 non_upper_case_globals,
55 unpredictable_function_pointer_comparisons,
56 unused_imports
57)]
58mod generated {
59 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
60}
61#[cfg(use_bindgen_pregenerated)]
62pub use generated::*;
63
64#[allow(non_snake_case, clippy::cast_possible_wrap)]
65#[must_use]
66pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
67 ((packed_error >> 24) & 0xFF) as i32
68}
69
70#[allow(non_snake_case, clippy::cast_possible_wrap)]
71#[must_use]
72pub fn ERR_GET_REASON(packed_error: u32) -> i32 {
73 (packed_error & 0x0FFF) as i32
74}
75
76#[allow(non_snake_case)]
77#[must_use]
78pub fn ERR_GET_FUNC(_packed_error: u32) -> i32 {
79 0
80}
81
82use core::ffi::{c_char, c_long, c_void};
83#[allow(non_snake_case, clippy::not_unsafe_ptr_arg_deref)]
84pub fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
85 unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp.cast::<c_void>()) }
86}
87
88#[allow(non_snake_case)]
89#[must_use]
90pub fn CFG_CPU_JITTER_ENTROPY() -> bool {
91 cfg!(cpu_jitter_entropy)
92}
93
94pub fn init() {
95 unsafe { CRYPTO_library_init() }
96}