cryptoki_sys/
lib.rs

1// Copyright 2021,2023 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(clippy::redundant_field_names)]
7#![allow(clippy::missing_safety_doc)]
8#![allow(clippy::string_lit_as_bytes)]
9#![allow(clippy::too_many_arguments)]
10// Public items exportedby this crate should match the C style
11#![allow(clippy::upper_case_acronyms)]
12// Suppress warnings from bindgen-generated code
13// Remove on resolution of
14// https://github.com/rust-lang/rust-bindgen/issues/1651
15#![allow(deref_nullptr)]
16
17// For supported targets: use the generated and committed bindings.
18#[cfg(all(
19    not(feature = "generate-bindings"),
20    target_arch = "x86_64",
21    target_os = "linux"
22))]
23include!(concat!(
24    env!("CARGO_MANIFEST_DIR"),
25    "/src/bindings/x86_64-unknown-linux-gnu.rs"
26));
27
28#[cfg(all(
29    not(feature = "generate-bindings"),
30    target_arch = "x86",
31    target_os = "linux"
32))]
33include!(concat!(
34    env!("CARGO_MANIFEST_DIR"),
35    "/src/bindings/i686-unknown-linux-gnu.rs"
36));
37
38#[cfg(all(
39    not(feature = "generate-bindings"),
40    target_arch = "powerpc64",
41    target_os = "linux"
42))]
43include!(concat!(
44    env!("CARGO_MANIFEST_DIR"),
45    "/src/bindings/powerpc64-unknown-linux-gnu.rs"
46));
47
48#[cfg(all(
49    not(feature = "generate-bindings"),
50    target_arch = "aarch64",
51    target_os = "linux"
52))]
53include!(concat!(
54    env!("CARGO_MANIFEST_DIR"),
55    "/src/bindings/aarch64-unknown-linux-gnu.rs"
56));
57
58#[cfg(all(
59    not(feature = "generate-bindings"),
60    target_arch = "arm",
61    target_os = "linux"
62))]
63include!(concat!(
64    env!("CARGO_MANIFEST_DIR"),
65    "/src/bindings/arm-unknown-linux-gnueabi.rs"
66));
67
68#[cfg(all(
69    not(feature = "generate-bindings"),
70    target_arch = "loongarch64",
71    target_os = "linux"
72))]
73include!(concat!(
74    env!("CARGO_MANIFEST_DIR"),
75    "/src/bindings/loongarch64-unknown-linux-gnu.rs"
76));
77
78#[cfg(all(
79    not(feature = "generate-bindings"),
80    target_arch = "x86_64",
81    target_os = "macos"
82))]
83include!(concat!(
84    env!("CARGO_MANIFEST_DIR"),
85    "/src/bindings/x86_64-apple-darwin.rs"
86));
87
88#[cfg(all(
89    not(feature = "generate-bindings"),
90    target_arch = "aarch64",
91    target_os = "macos"
92))]
93include!(concat!(
94    env!("CARGO_MANIFEST_DIR"),
95    "/src/bindings/aarch64-apple-darwin.rs"
96));
97
98#[cfg(all(
99    not(feature = "generate-bindings"),
100    target_arch = "x86_64",
101    target_os = "windows"
102))]
103include!(concat!(
104    env!("CARGO_MANIFEST_DIR"),
105    "/src/bindings/x86_64-pc-windows-msvc.rs"
106));
107
108#[cfg(all(
109    not(feature = "generate-bindings"),
110    target_arch = "x86_64",
111    target_os = "freebsd"
112))]
113include!(concat!(
114    env!("CARGO_MANIFEST_DIR"),
115    "/src/bindings/x86_64-unknown-freebsd.rs"
116));
117
118// For supported targets: use the generated and committed bindings.
119#[cfg(not(any(
120    feature = "generate-bindings",
121    all(target_arch = "x86_64", target_os = "linux"),
122    all(target_arch = "x86", target_os = "linux"),
123    all(target_arch = "powerpc64", target_os = "linux"),
124    all(target_arch = "aarch64", target_os = "linux"),
125    all(target_arch = "arm", target_os = "linux"),
126    all(target_arch = "loongarch64", target_os = "linux"),
127    all(target_arch = "x86_64", target_os = "macos"),
128    all(target_arch = "aarch64", target_os = "macos"),
129    all(target_arch = "x86_64", target_os = "windows"),
130    all(target_arch = "x86_64", target_os = "freebsd"),
131)))]
132include!(concat!(
133    env!("CARGO_MANIFEST_DIR"),
134    "/src/bindings/generic.rs"
135));
136
137// If the "generate-bindings" feature is on, use the generated bindings.
138#[cfg(feature = "generate-bindings")]
139include!(concat!(env!("OUT_DIR"), "/pkcs11_bindings.rs"));
140
141// bindgen generates u64::MAX value for ~0UL macro definition, it's not valid on 32bit ulong platforms.
142// This is a workaround for that.
143pub const CK_UNAVAILABLE_INFORMATION: CK_ULONG = CK_ULONG::MAX;