blob: 3206bde0216eccf0d9d1166a0de845d5dae8bdcb [file] [log] [blame]
Stephen Barber27c58232019-12-09 17:20:28 -08001// Copyright 2019 The Chromium OS Authors. All rights reserved.
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 blacklists 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// --blacklist-type '__rlim64_t' \
22// --raw-line 'pub type __rlim64_t = u64;' \
23// --blacklist-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// --blacklist-type '__uint64_t' \
28// --whitelist-function '^minijail_.*' \
29// --whitelist-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(non_camel_case_types)]
41mod libminijail;
42pub use crate::libminijail::*;