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
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!(universal_prefixed, universal_prefixed_crypto);
23platform_binding!(universal_no_u1_prefixed, universal_no_u1_prefixed_crypto);
24platform_binding!(universal_no_u1, universal_no_u1_crypto);
25platform_binding!(universal, universal_crypto);
26
27platform_binding!(aarch64_linux_android, aarch64_linux_android_crypto);
28platform_binding!(aarch64_apple_darwin, aarch64_apple_darwin_crypto);
29platform_binding!(aarch64_pc_windows_msvc, aarch64_pc_windows_msvc_crypto);
30platform_binding!(aarch64_unknown_linux_gnu, aarch64_unknown_linux_gnu_crypto);
31platform_binding!(
32    aarch64_unknown_linux_musl,
33    aarch64_unknown_linux_musl_crypto
34);
35platform_binding!(i686_pc_windows_msvc, i686_pc_windows_msvc_crypto);
36platform_binding!(i686_unknown_linux_gnu, i686_unknown_linux_gnu_crypto);
37platform_binding!(
38    riscv64gc_unknown_linux_gnu,
39    riscv64gc_unknown_linux_gnu_crypto
40);
41platform_binding!(x86_64_apple_darwin, x86_64_apple_darwin_crypto);
42platform_binding!(x86_64_pc_windows_gnu, x86_64_pc_windows_gnu_crypto);
43platform_binding!(x86_64_pc_windows_msvc, x86_64_pc_windows_msvc_crypto);
44platform_binding!(x86_64_unknown_linux_gnu, x86_64_unknown_linux_gnu_crypto);
45platform_binding!(x86_64_unknown_linux_musl, x86_64_unknown_linux_musl_crypto);
46
47#[cfg(use_bindgen_pregenerated)]
48#[allow(
49    clippy::cast_lossless,
50    clippy::cast_possible_truncation,
51    clippy::cast_possible_wrap,
52    clippy::default_trait_access,
53    clippy::missing_safety_doc,
54    clippy::must_use_candidate,
55    clippy::not_unsafe_ptr_arg_deref,
56    clippy::ptr_as_ptr,
57    clippy::ptr_offset_with_cast,
58    clippy::pub_underscore_fields,
59    clippy::semicolon_if_nothing_returned,
60    clippy::too_many_lines,
61    clippy::unreadable_literal,
62    clippy::used_underscore_binding,
63    clippy::useless_transmute,
64    dead_code,
65    improper_ctypes,
66    non_camel_case_types,
67    non_snake_case,
68    non_upper_case_globals,
69    unpredictable_function_pointer_comparisons,
70    unused_imports
71)]
72mod generated {
73    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
74}
75#[cfg(use_bindgen_pregenerated)]
76pub use generated::*;
77
78#[allow(non_snake_case, clippy::cast_possible_wrap)]
79#[must_use]
80pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
81    ((packed_error >> 24) & 0xFF) as i32
82}
83
84#[allow(non_snake_case, clippy::cast_possible_wrap)]
85#[must_use]
86pub fn ERR_GET_REASON(packed_error: u32) -> i32 {
87    (packed_error & 0xFFF) as i32
88}
89
90#[allow(non_snake_case)]
91#[must_use]
92pub fn ERR_GET_FUNC(_packed_error: u32) -> i32 {
93    0
94}
95
96#[cfg(feature = "all-bindings")]
97use std::os::raw::{c_char, c_long, c_void};
98
99#[cfg(feature = "all-bindings")]
100#[allow(non_snake_case, clippy::not_unsafe_ptr_arg_deref)]
101pub fn BIO_get_mem_data(b: *mut BIO, pp: *mut *mut c_char) -> c_long {
102    unsafe { BIO_ctrl(b, BIO_CTRL_INFO, 0, pp.cast::<c_void>()) }
103}
104
105pub fn init() {
106    unsafe { CRYPTO_library_init() }
107}