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 = "riscv64",
81    target_os = "linux"
82))]
83include!(concat!(
84    env!("CARGO_MANIFEST_DIR"),
85    "/src/bindings/riscv64gc-unknown-linux-gnu.rs"
86));
87
88#[cfg(all(
89    not(feature = "generate-bindings"),
90    target_arch = "x86_64",
91    target_os = "macos"
92))]
93include!(concat!(
94    env!("CARGO_MANIFEST_DIR"),
95    "/src/bindings/x86_64-apple-darwin.rs"
96));
97
98#[cfg(all(
99    not(feature = "generate-bindings"),
100    target_arch = "aarch64",
101    target_os = "macos"
102))]
103include!(concat!(
104    env!("CARGO_MANIFEST_DIR"),
105    "/src/bindings/aarch64-apple-darwin.rs"
106));
107
108#[cfg(all(
109    not(feature = "generate-bindings"),
110    target_arch = "x86_64",
111    target_os = "windows"
112))]
113include!(concat!(
114    env!("CARGO_MANIFEST_DIR"),
115    "/src/bindings/x86_64-pc-windows-msvc.rs"
116));
117
118#[cfg(all(
119    not(feature = "generate-bindings"),
120    target_arch = "x86_64",
121    target_os = "freebsd"
122))]
123include!(concat!(
124    env!("CARGO_MANIFEST_DIR"),
125    "/src/bindings/x86_64-unknown-freebsd.rs"
126));
127
128// For supported targets: use the generated and committed bindings.
129#[cfg(not(any(
130    feature = "generate-bindings",
131    all(target_arch = "x86_64", target_os = "linux"),
132    all(target_arch = "x86", target_os = "linux"),
133    all(target_arch = "powerpc64", target_os = "linux"),
134    all(target_arch = "aarch64", target_os = "linux"),
135    all(target_arch = "arm", target_os = "linux"),
136    all(target_arch = "loongarch64", target_os = "linux"),
137    all(target_arch = "riscv64", target_os = "linux"),
138    all(target_arch = "x86_64", target_os = "macos"),
139    all(target_arch = "aarch64", target_os = "macos"),
140    all(target_arch = "x86_64", target_os = "windows"),
141    all(target_arch = "x86_64", target_os = "freebsd"),
142)))]
143include!(concat!(
144    env!("CARGO_MANIFEST_DIR"),
145    "/src/bindings/generic.rs"
146));
147
148// If the "generate-bindings" feature is on, use the generated bindings.
149#[cfg(feature = "generate-bindings")]
150include!(concat!(env!("OUT_DIR"), "/pkcs11_bindings.rs"));
151
152// bindgen generates u64::MAX value for ~0UL macro definition, it's not valid on 32bit ulong platforms.
153// This is a workaround for that.
154pub const CK_UNAVAILABLE_INFORMATION: CK_ULONG = CK_ULONG::MAX;