From d2bf2d875e8e463bf4a52b5798099bde91dab385 Mon Sep 17 00:00:00 2001 From: Dirreke Date: Thu, 7 Sep 2023 21:25:02 +0800 Subject: [PATCH 1/6] update ci and deps --- .github/bors.toml | 24 ------------------------ .github/workflows/ci.yml | 22 +++++++++++----------- CHANGELOG.md | 4 +++- Cargo.toml | 5 +++-- README.md | 2 +- examples/monitor.rs | 15 +++++++-------- src/async_tokio.rs | 2 +- src/lib.rs | 27 ++++++++++++++++++++++----- 8 files changed, 48 insertions(+), 53 deletions(-) delete mode 100644 .github/bors.toml diff --git a/.github/bors.toml b/.github/bors.toml deleted file mode 100644 index e69d000..0000000 --- a/.github/bors.toml +++ /dev/null @@ -1,24 +0,0 @@ -block_labels = ["needs-decision"] -delete_merged_branches = true -required_approvals = 1 -status = [ - "build (stable, aarch64-unknown-linux-gnu)", - "build (stable, arm-unknown-linux-gnueabi)", - "build (stable, armv7-unknown-linux-gnueabihf)", - "build (stable, i686-unknown-linux-gnu)", - "build (stable, i686-unknown-linux-musl)", - "build (stable, mips-unknown-linux-gnu)", - "build (stable, mips64-unknown-linux-gnuabi64)", - "build (stable, mips64el-unknown-linux-gnuabi64)", - "build (stable, mipsel-unknown-linux-gnu)", - "build (stable, powerpc-unknown-linux-gnu)", - "build (stable, powerpc64le-unknown-linux-gnu)", - "build (stable, s390x-unknown-linux-gnu)", - "build (stable, x86_64-unknown-linux-gnu)", - "build (stable, x86_64-unknown-linux-musl)", - - "build (1.59.0, x86_64-unknown-linux-gnu)", - - "checks" -] -timeout_sec = 7200 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2751727..569cd2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,9 @@ on: - push: - branches: [ staging, trying, master ] - pull_request: + push: # Run CI for all branches except GitHub merge queue tmp branches + branches-ignore: + - "gh-readonly-queue/**" + pull_request: # Run CI for PRs on any branch + merge_group: # Run CI for the GitHub merge queue name: Build @@ -16,24 +18,24 @@ jobs: rust: [stable] TARGET: - aarch64-unknown-linux-gnu + - aarch64-unknown-linux-musl - arm-unknown-linux-gnueabi + - arm-unknown-linux-gnueabihf - armv7-unknown-linux-gnueabihf - i686-unknown-linux-gnu - i686-unknown-linux-musl - - mips-unknown-linux-gnu - - mips64-unknown-linux-gnuabi64 - - mips64el-unknown-linux-gnuabi64 - - mipsel-unknown-linux-gnu + # - loongarch64-unknown-linux-gnu - powerpc-unknown-linux-gnu # - powerpc64-unknown-linux-gnu - powerpc64le-unknown-linux-gnu + - riscv64gc-unknown-linux-gnu - s390x-unknown-linux-gnu - x86_64-unknown-linux-gnu - x86_64-unknown-linux-musl include: # MSRV - - rust: 1.59.0 + - rust: 1.65.0 TARGET: x86_64-unknown-linux-gnu # Test nightly but don't fail @@ -63,7 +65,6 @@ jobs: args: --target=${{ matrix.TARGET }} --all-features - name: Test - if: ${{ ! contains(matrix.TARGET, 'mips') }} # https://github.com/rust-lang/rust/issues/108835 uses: actions-rs/cargo@v1 with: use-cross: true @@ -71,7 +72,6 @@ jobs: args: --target=${{ matrix.TARGET }} - name: Test all features - if: ${{ ! contains(matrix.TARGET, 'mips') }} # https://github.com/rust-lang/rust/issues/108835 uses: actions-rs/cargo@v1 with: use-cross: true @@ -109,7 +109,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.59.0 + toolchain: 1.65.0 components: clippy - uses: actions-rs/clippy-check@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index a9f57ae..6b21a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -- MSRV is now 1.59.0. +- Updated nix to version `0.27`. +- Updated bitflags to version `2.4`. +- MSRV is now 1.65.0. ## [v0.5.1] - 2021-11-22 diff --git a/Cargo.toml b/Cargo.toml index 1ff489e..05d28c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,9 @@ name = "async_tokio" required-features = ["async-tokio"] [dependencies] -bitflags = "1.3" +bitflags = "2.4" libc = "0.2" -nix = "0.23" +nix = { version = "0.27", features = ["ioctl"] } tokio = { version = "1", features = ["io-std", "net"], optional = true } futures = { version = "0.3", optional = true } @@ -31,6 +31,7 @@ quicli = "0.4" structopt = "0.3" anyhow = "1.0" tokio = { version = "1", features = ["io-std", "rt-multi-thread", "macros", "net"] } +nix = { version = "0.27", features = ["ioctl", "poll"] } [package.metadata.docs.rs] # To build locally: diff --git a/README.md b/README.md index 6db8098..5efdcef 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ to be considered reliable. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.59.0 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.65.0 and up. It *might* compile with older versions but that may change in any new patch release. ## License diff --git a/examples/monitor.rs b/examples/monitor.rs index 0e4e372..7925907 100644 --- a/examples/monitor.rs +++ b/examples/monitor.rs @@ -9,7 +9,7 @@ use gpio_cdev::*; use nix::poll::*; use quicli::prelude::*; -use std::os::unix::io::AsRawFd; +use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd}; use structopt::StructOpt; type PollEventFlags = nix::poll::PollFlags; @@ -41,14 +41,13 @@ fn do_main(args: Cli) -> anyhow::Result<()> { .collect(); // Create a vector of file descriptors for polling - let mut pollfds: Vec = evt_handles + let ownedfd: Vec = evt_handles .iter() - .map(|h| { - PollFd::new( - h.as_raw_fd(), - PollEventFlags::POLLIN | PollEventFlags::POLLPRI, - ) - }) + .map(|h| unsafe { OwnedFd::from_raw_fd(h.as_raw_fd()) }) + .collect(); + let mut pollfds: Vec = ownedfd + .iter() + .map(|fd| PollFd::new(fd, PollEventFlags::POLLIN | PollEventFlags::POLLPRI)) .collect(); loop { diff --git a/src/async_tokio.rs b/src/async_tokio.rs index 9e4a73f..327272c 100644 --- a/src/async_tokio.rs +++ b/src/async_tokio.rs @@ -97,6 +97,6 @@ impl Stream for AsyncLineEventHandle { impl AsRef for AsyncLineEventHandle { fn as_ref(&self) -> &LineEventHandle { - &self.asyncfd.get_ref() + self.asyncfd.get_ref() } } diff --git a/src/lib.rs b/src/lib.rs index dd3461f..b8b6506 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,7 +95,7 @@ use std::fs::{read_dir, File, ReadDir}; use std::io::Read; use std::mem; use std::ops::Index; -use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; +use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; use std::path::{Path, PathBuf}; use std::ptr; use std::slice; @@ -335,7 +335,7 @@ pub struct Line { /// Wraps kernel [`struct gpioline_info`]. /// /// [`struct gpioline_info`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L36 -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct LineInfo { line: Line, flags: LineFlags, @@ -349,6 +349,7 @@ bitflags! { /// Maps to kernel [`GPIOHANDLE_REQUEST_*`] flags. /// /// [`GPIOHANDLE_REQUEST_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L58 + #[derive(Debug, Clone)] pub struct LineRequestFlags: u32 { const INPUT = (1 << 0); const OUTPUT = (1 << 1); @@ -367,7 +368,7 @@ bitflags! { pub struct EventRequestFlags: u32 { const RISING_EDGE = (1 << 0); const FALLING_EDGE = (1 << 1); - const BOTH_EDGES = Self::RISING_EDGE.bits | Self::FALLING_EDGE.bits; + const BOTH_EDGES = Self::RISING_EDGE.bits() | Self::FALLING_EDGE.bits(); } } @@ -377,6 +378,7 @@ bitflags! { /// Maps to kernel [`GPIOLINE_FLAG_*`] flags. /// /// [`GPIOLINE_FLAG_*`]: https://elixir.bootlin.com/linux/v4.9.127/source/include/uapi/linux/gpio.h#L29 + #[derive(Debug)] pub struct LineFlags: u32 { const KERNEL = (1 << 0); const IS_OUT = (1 << 1); @@ -572,7 +574,7 @@ impl Line { consumer: &str, ) -> Result { let events = self.events(handle_flags, event_flags, consumer)?; - Ok(AsyncLineEventHandle::new(events)?) + AsyncLineEventHandle::new(events) } } @@ -693,7 +695,7 @@ impl LineHandle { /// Get the flags with which this handle was created pub fn flags(&self) -> LineRequestFlags { - self.flags + self.flags.clone() } } @@ -985,6 +987,14 @@ impl LineEventHandle { &self.line } + pub fn file(&self) -> &File { + &self.file + } + + pub fn file2(&mut self) -> &File { + &self.file + } + /// Helper function which returns the line event if a complete event was read, Ok(None) if not /// enough data was read or the error returned by `read()`. pub(crate) fn read_event(&mut self) -> std::io::Result> { @@ -1011,6 +1021,13 @@ impl AsRawFd for LineEventHandle { } } +impl AsFd for LineEventHandle { + /// Gets the raw file descriptor for the `LineEventHandle`. + fn as_fd(&self) -> BorrowedFd<'_> { + self.file.as_fd() + } +} + impl Iterator for LineEventHandle { type Item = Result; From 06b8787d3239a1b045d9d7fed273884f0d5f2baf Mon Sep 17 00:00:00 2001 From: Dirreke Date: Tue, 12 Sep 2023 14:26:54 +0800 Subject: [PATCH 2/6] prepare for 0.6.0 --- CHANGELOG.md | 5 ++++- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b21a17..01d2c7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.6.0] - 2023-09-11 + - Updated nix to version `0.27`. - Updated bitflags to version `2.4`. - MSRV is now 1.65.0. @@ -60,7 +62,8 @@ Adds the ability to create a collection of lines from a single chip and read or - Initial release of the library with basic operations centered around operating on a single line at a time. -[Unreleased]: https://github.com/rust-embedded/gpio-cdev/compare/0.5.1...HEAD +[Unreleased]: https://github.com/rust-embedded/gpio-cdev/compare/0.6.0...HEAD +[v0.6.0]: https://github.com/rust-embedded/gpio-cdev/compare/0.5.1...0.6.0 [v0.5.1]: https://github.com/rust-embedded/gpio-cdev/compare/0.5.0...0.5.1 [v0.5.0]: https://github.com/rust-embedded/gpio-cdev/compare/0.4.0...0.5.0 [v0.4.0]: https://github.com/rust-embedded/gpio-cdev/compare/0.3.0...0.4.0 diff --git a/Cargo.toml b/Cargo.toml index 05d28c0..c7d44a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gpio-cdev" -version = "0.5.1" +version = "0.6.0" authors = ["Paul Osborne ", "Frank Pagliughi "] description = "Linux GPIO Character Device Support (/dev/gpiochipN)" homepage = "https://github.com/rust-embedded/gpio-cdev" From 5a41d7f3bf1f8557a7f02234935fbcddd13c8288 Mon Sep 17 00:00:00 2001 From: Jonathan Bastien-Filiatrault Date: Tue, 20 May 2025 21:59:58 -0400 Subject: [PATCH 3/6] Update MSRV to 1.82. backtrace requires it. --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 1 + README.md | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 569cd2d..628c3e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: include: # MSRV - - rust: 1.65.0 + - rust: 1.82.0 TARGET: x86_64-unknown-linux-gnu # Test nightly but don't fail @@ -109,7 +109,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.65.0 + toolchain: 1.82.0 components: clippy - uses: actions-rs/clippy-check@v1 diff --git a/Cargo.toml b/Cargo.toml index c7d44a9..55822c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ categories = ["embedded", "hardware-support", "os", "os::unix-apis"] keywords = ["linux", "gpio", "gpiochip", "embedded"] license = "MIT OR Apache-2.0" edition = "2018" +rust-version = "1.82" [features] default = [] diff --git a/README.md b/README.md index 5efdcef..a44d08d 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ to be considered reliable. ## Minimum Supported Rust Version (MSRV) -This crate is guaranteed to compile on stable Rust 1.65.0 and up. It *might* +This crate is guaranteed to compile on stable Rust 1.82.0 and up. It *might* compile with older versions but that may change in any new patch release. ## License From 4462f510f9687b858171c1ebb8bafb76b48c7a74 Mon Sep 17 00:00:00 2001 From: Jonathan Bastien-Filiatrault Date: Wed, 2 Jul 2025 21:45:51 -0400 Subject: [PATCH 4/6] Update Cargo.toml Co-authored-by: Diego Barrios Romero --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 55822c8..c7d44a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ categories = ["embedded", "hardware-support", "os", "os::unix-apis"] keywords = ["linux", "gpio", "gpiochip", "embedded"] license = "MIT OR Apache-2.0" edition = "2018" -rust-version = "1.82" [features] default = [] From 924ac5ef0157f5bea5dcc7aa34daae787c5f08f2 Mon Sep 17 00:00:00 2001 From: Jonathan Bastien-Filiatrault Date: Wed, 2 Jul 2025 21:47:53 -0400 Subject: [PATCH 5/6] Update changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01d2c7c..7d7fdf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- MSRV is now 1.82.0. + ## [v0.6.0] - 2023-09-11 - Updated nix to version `0.27`. From 4186e9d1d3ca9063904b337afe17ab039b29f04d Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Thu, 3 Jul 2025 09:00:38 +0200 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d7fdf9..135e768 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed + - MSRV is now 1.82.0. ## [v0.6.0] - 2023-09-11 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy