diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4aa9a60..e75b437 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,8 +30,9 @@ jobs: cargo check --features v5_4 cargo check --features v5_11 cargo check --features "v3_2 netlink" - cargo check --no-default-features --features "v5_11 netlink" - cargo check --features no_std + cargo check --no-default-features --features "std v5_11 netlink" + cargo check --no-default-features --features "no_std v5_4 netlink" + cargo check --no-default-features --features "no_std general errno" gen: name: Update generated files diff --git a/Cargo.toml b/Cargo.toml index 9decd4c..eba06b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,5 +31,6 @@ v4_4 = [] v4_20 = [] v5_4 = [] v5_11 = [] -default = ["general", "errno"] +default = ["std", "general", "errno"] +std = [] no_std = ['cty'] diff --git a/gen/src/main.rs b/gen/src/main.rs index c8c062c..07fa465 100644 --- a/gen/src/main.rs +++ b/gen/src/main.rs @@ -239,7 +239,8 @@ fn main() { } } - writeln!(cargo_toml, "default = [{}]", DEFAULT_FEATURES).unwrap(); + writeln!(cargo_toml, "default = [\"std\", {}]", DEFAULT_FEATURES).unwrap(); + writeln!(cargo_toml, "std = []").unwrap(); writeln!(cargo_toml, "no_std = ['cty']").unwrap(); // Reset the `linux` directory back to the original branch. diff --git a/src/lib.rs b/src/lib.rs index a8391a7..7a81825 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,7 @@ #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] -#![no_std] +#![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "no_std"))] -extern crate std; -#[cfg(not(feature = "no_std"))] +#[cfg(feature = "std")] use std::os::raw as ctypes; #[cfg(feature = "no_std")]