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

Commit 0c1c171

Browse files
acatangiuSamuel Ortiz
authored and
Samuel Ortiz
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 cdaf9bf commit 0c1c171

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@ toml:
2525
```toml
2626
kvm-bindings = { version = "0.1", features = ["kvm_v4_20_0"]}
2727
```
28-
In the `kvm-bindings` crate each feature maps to exactly one Linux version
29-
as follows:
28+
Bindings are generated for each specific Linux kernel version based on the enabled
29+
crate features 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+
This crate also offers safe wrappers over FAM structs - FFI structs that have
34+
a Flexible Array Member in their definition.
35+
These safe wrappers can be used if the `fam-wrappers` feature is enabled for
36+
this crate. Example:
37+
```toml
38+
kvm-bindings = { version = "0.1", features = ["kvm_v4_20_0", "fam-wrappers"]}
39+
```
40+
41+
# Dependencies
42+
The crate has an `optional` dependency to
43+
[vmm-sys-util](https://crates.io/crates/vmm-sys-util) when enabling the
44+
`fam-wrappers` feature.

src/lib.rs

Lines changed: 4 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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)