Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit c6b7e19

Browse files
committed
use a 'fam-wrappers' feature to gate the FamStructWrappers
The FamStructWrappers definitions as well as the vmm-sys-util dependency are now gated by an opt-in `fam-wrappers` feature. Signed-off-by: Adrian Catangiu <[email protected]>
1 parent ef8ecc4 commit c6b7e19

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ license = "Apache-2.0"
1111
[features]
1212
kvm-v4_14_0 = []
1313
kvm-v4_20_0 = []
14+
fam-wrappers = ["vmm-sys-util"]
1415

1516
[dependencies]
16-
vmm-sys-util = ">=0.2.0"
17+
vmm-sys-util = { version = ">=0.2.0", optional = true }

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,18 @@ In the `kvm-bindings` crate each feature maps to exactly one Linux version
2929
as follows:
3030
- `kvm_v4_14_0` contains the bindings for the Linux kernel version 4.14
3131
- `kvm_v4_20_0` contains the bindings for the Linux kernel version 4.20
32+
33+
# Additional features
34+
This crate also offers safe wrappers over FAM structs - FFI structs that have
35+
a Flexible Array Member in their definition.
36+
These safe wrappers can be used if the `fam-wrappers` feature is enabled for
37+
this crate. Example:
38+
```toml
39+
kvm-bindings = { version = "0.1", features = ["kvm_v4_20_0", "fam-wrappers"]}
40+
```
41+
42+
# Dependencies
43+
This crate has no external dependencies when used with `default` features.
44+
45+
When enabling the `fam-wrappers` feature, this crate will take a dependency on
46+
the [vmm-sys-util](https://crates.io/crates/vmm-sys-util) crate.

src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
#![allow(non_snake_case)]
77

88
#[macro_use]
9-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
9+
#[cfg(all(
10+
feature = "fam-wrappers",
11+
any(target_arch = "x86", target_arch = "x86_64")
12+
))]
1013
extern crate vmm_sys_util;
1114

1215
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

src/x86/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#[cfg(feature = "fam-wrappers")]
45
mod fam_wrappers;
56

67
#[cfg(feature = "kvm-v4_14_0")]
@@ -24,5 +25,6 @@ pub mod bindings {
2425
#[cfg(all(not(feature = "kvm-v4_14_0"), not(feature = "kvm-v4_20_0")))]
2526
pub use super::bindings_v4_20_0::*;
2627

28+
#[cfg(feature = "fam-wrappers")]
2729
pub use super::fam_wrappers::*;
2830
}

0 commit comments

Comments
 (0)