xref: /aosp_15_r20/external/minijail/rust/minijail-sys/lib.rs (revision 4b9c6d91573e8b3a96609339b46361b5476dd0f9)
1 // Copyright 2019 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 /// libminijail bindings for Rust.
6 
7 // TODO(crbug.com/1032672): Generate bindings at build time.
8 //
9 // Bindgen will invoke the C preprocessor to process headers, which means that the bindings
10 // generated can depend on the architecture that actually ran bindgen. In particular, for
11 // portability across compilers glibc defines types like __u8 and __rlim64_t in terms of C types
12 // like unsigned char and unsigned long. This is problematic for __rlim64_t since that resolves to
13 // unsigned long int on amd64, which will end up being 32-bit on 32-bit platforms.
14 //
15 // As a workaround to let us commit these bindings and still use them on 32-bit platforms, the
16 // bindgen invocation blocklists some of the generated fixed-width types and redefines them
17 // manually as Rust fixed-width types.
18 //
19 // Generated in CrOS SDK chroot with:
20 // bindgen --default-enum-style rust \
21 //         --blocklist-type '__rlim64_t' \
22 //         --raw-line 'pub type __rlim64_t = u64;' \
23 //         --blocklist-type '__u\d{1,2}' \
24 //         --raw-line 'pub type __u8 = u8;' \
25 //         --raw-line 'pub type __u16 = u16;' \
26 //         --raw-line 'pub type __u32 = u32;' \
27 //         --blocklist-type '__uint64_t' \
28 //         --allowlist-function '^minijail_.*' \
29 //         --allowlist-var '^MINIJAIL_.*' \
30 //         --no-layout-tests \
31 //         --output libminijail.rs \
32 //         libminijail.h -- \
33 //         -DUSE_BINDGEN \
34 //         -D_FILE_OFFSET_BITS=64 \
35 //         -D_LARGEFILE_SOURCE \
36 //         -D_LARGEFILE64_SOURCE
37 //
38 // Enum variants in rust are customarily camel case, but bindgen will leave the original names
39 // intact.
40 #[allow(
41     clippy::all,
42     non_camel_case_types,
43     non_snake_case,
44     non_upper_case_globals
45 )]
46 mod libminijail;
47 pub use crate::libminijail::*;
48