aws_lc_sys/
lib.rs

1// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0 OR ISC
3
4#![cfg_attr(not(clippy), allow(unexpected_cfgs))]
5#![cfg_attr(not(clippy), allow(unknown_lints))]
6
7use std::os::raw::{c_char, c_long, c_void};
8
9#[allow(unused_macros)]
10macro_rules! use_bindings {
11    ($bindings:ident) => {
12        mod $bindings;
13        pub use $bindings::*;
14    };
15}
16
17macro_rules! platform_binding {
18    ($platform:ident, $platform_crypto:ident, $platform_ssl:ident) => {
19        #[cfg(all($platform, not(feature = "ssl"), not(use_bindgen_generated)))]
20        use_bindings!($platform_crypto);
21        #[cfg(all($platform, feature = "ssl", not(use_bindgen_generated)))]
22        use_bindings!($platform_ssl);
23    };
24}
25
26platform_binding!(
27    aarch64_linux_android,
28    aarch64_linux_android_crypto,
29    aarch64_linux_android_crypto_ssl
30);
31platform_binding!(
32    aarch64_apple_darwin,
33    aarch64_apple_darwin_crypto,
34    aarch64_apple_darwin_crypto_ssl
35);
36platform_binding!(
37    aarch64_pc_windows_msvc,
38    aarch64_pc_windows_msvc_crypto,
39    aarch64_pc_windows_msvc_crypto_ssl
40);
41platform_binding!(
42    aarch64_unknown_linux_gnu,
43    aarch64_unknown_linux_gnu_crypto,
44    aarch64_unknown_linux_gnu_crypto_ssl
45);
46platform_binding!(
47    aarch64_unknown_linux_musl,
48    aarch64_unknown_linux_musl_crypto,
49    aarch64_unknown_linux_musl_crypto_ssl
50);
51platform_binding!(
52    i686_pc_windows_msvc,
53    i686_pc_windows_msvc_crypto,
54    i686_pc_windows_msvc_crypto_ssl
55);
56platform_binding!(
57    i686_unknown_linux_gnu,
58    i686_unknown_linux_gnu_crypto,
59    i686_unknown_linux_gnu_crypto_ssl
60);
61platform_binding!(
62    riscv64gc_unknown_linux_gnu,
63    riscv64gc_unknown_linux_gnu_crypto,
64    riscv64gc_unknown_linux_gnu_crypto_ssl
65);
66platform_binding!(
67    x86_64_apple_darwin,
68    x86_64_apple_darwin_crypto,
69    x86_64_apple_darwin_crypto_ssl
70);
71platform_binding!(
72    x86_64_pc_windows_gnu,
73    x86_64_pc_windows_gnu_crypto,
74    x86_64_pc_windows_gnu_crypto_ssl
75);
76platform_binding!(
77    x86_64_pc_windows_msvc,
78    x86_64_pc_windows_msvc_crypto,
79    x86_64_pc_windows_msvc_crypto_ssl
80);
81platform_binding!(
82    x86_64_unknown_linux_gnu,
83    x86_64_unknown_linux_gnu_crypto,
84    x86_64_unknown_linux_gnu_crypto_ssl
85);
86platform_binding!(
87    x86_64_unknown_linux_musl,
88    x86_64_unknown_linux_musl_crypto,
89    x86_64_unknown_linux_musl_crypto_ssl
90);
91
92#[cfg(use_bindgen_generated)]
93#[allow(
94    clippy::cast_lossless,
95    clippy::cast_possible_truncation,
96    clippy::cast_possible_wrap,
97    clippy::default_trait_access,
98    clippy::missing_safety_doc,
99    clippy::must_use_candidate,
100    clippy::not_unsafe_ptr_arg_deref,
101    clippy::ptr_as_ptr,
102    clippy::ptr_offset_with_cast,
103    clippy::pub_underscore_fields,
104    clippy::semicolon_if_nothing_returned,
105    clippy::too_many_lines,
106    clippy::unreadable_literal,
107    clippy::used_underscore_binding,
108    clippy::useless_transmute,
109    dead_code,
110    improper_ctypes,
111    non_camel_case_types,
112    non_snake_case,
113    non_upper_case_globals,
114    unpredictable_function_pointer_comparisons,
115    unused_imports
116)]
117mod generated {
118    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
119}
120#[cfg(use_bindgen_generated)]
121pub use generated::*;
122
123#[allow(non_snake_case)]
124#[must_use]
125pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
126    unsafe { ERR_GET_LIB_RUST(packed_error) }
127}
128
129#[allow(non_snake_case)]
130#[must_use]
131pub fn ERR_GET_REASON(packed_error: u32) -> i32 {
132    unsafe { ERR_GET_REASON_RUST(packed_error) }
133}
134
135#[allow(non_snake_case)]
136#[must_use]
137pub fn ERR_GET_FUNC(packed_error: u32) -> i32 {
138    unsafe { ERR_GET_FUNC_RUST(packed_error) }
139}
140
141#[allow(non_snake_case, clippy::not_unsafe_ptr_arg_deref)]
142pub fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
143    unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp.cast::<c_void>()) }
144}
145
146pub fn init() {
147    unsafe { CRYPTO_library_init() }
148}