Skip to content

Commit

Permalink
Support rust 1.74.1 (#128)
Browse files Browse the repository at this point in the history
* Add rust 1.74.0 to the test matrix

* Add rust 1.74.0 to the test matrix

* Correct some mistakes in README.md about older macos versions.

* Debug builds

* Rollback changes and disable some lints

* Bump version for next release fixing lints issues

* Add rustc version output to before clippy

* Localize the allows

* Allow all on those lines
  • Loading branch information
andrewdavidmackenzie authored Mar 13, 2024
1 parent 359b222 commit d16c44d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 36 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/clippy_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-11, macos-12, macos-13, macos-14 ]
rust: [stable, beta]
rust: [stable, beta, 1.74.1] # Minimum Rust Version Supported = 1.74.1
experimental: [false]
include:
- os: ubuntu-latest
Expand All @@ -42,22 +42,18 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install latest nightly
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: ${{ matrix.rust }}
override: true
components: clippy

- name: Clippy
run: make clippy

- name: Compile check on redox
if: runner.os == 'Linux'
- name: Run clippy (installed toolchain version as per matrix)
run: |
rustup target add x86_64-unknown-redox
cargo +nightly check --target x86_64-unknown-redox
rustc --version
cargo clippy --all --tests --no-deps --all-targets --all-features -- --warn clippy::pedantic -D warnings
- name: ConfigureCoverage
if: matrix.rust == 'nightly'
Expand All @@ -76,5 +72,5 @@ jobs:
run: sudo env "PATH=$PATH" cargo test

- name: UploadCoverage
if: matrix.rust == 'nightly'
if: matrix.rust == 'stable'
run: make upload-coverage
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libproc"
version = "0.14.5"
version = "0.14.6"
description = "A library to get information about running processes - for Mac OS X and Linux"
authors = ["Andrew Mackenzie <andrew@mackenzie-serres.net>"]
repository = "https://github.com/andrewdavidmackenzie/libproc-rs"
Expand All @@ -15,8 +15,7 @@ libc = "^0.2.62"

[features]
default = ["macosx_10_9"]
macosx_10_7 = []
macosx_10_9 = ["macosx_10_7"]
macosx_10_9 = []

[lib]
name = "libproc"
Expand Down
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,31 @@ You can find the browseable docs for the latest release on [docs.rs](https://doc

NOTE: `master` branch (code and docs) can differ from those docs prior to a new release.

# Rust Channels Tested
The Github Actions CI matrix tests for rust `stable`, `beta` and `nightly` on all platforms
# Minimum rust version
The minimum rust version required is currently: 1.74.1 and this is tested in CI and must pass.

# Platforms
Mac OS X (10.5 and above) and Linux.
# Test Matrix
The Github Actions CI matrix is:

## Mac OS X Versions
Calls were aded to libproc in Mac OS X 10.7 and again in 10.9.
This library can be compiled to not include those calls by using rust `features`
to enable/disable support for those versions.
rust versions:
* `stable` (must pass)
* `beta` (must pass)
* `1.74.1` (currently the minimum rust version supported) (must pass)
* `nightly` (allowed to fail)

The default build is for Mac OS 10.9 or later. See:
```toml
[features]
default = ["macosx_10_9"]
macosx_10_7 = []
macosx_10_9 = ["macosx_10_7"]
```
in Cargo.toml
on the following platforms:
* `ubuntu-latest`
* `macos-11` (Big Sur)
* `macos-12` (Monterey)
* `macos-13` (Ventura)
* `macos-14` (Sonoma)

To build for versions prior to Mac OS 10.7 disable the default features by passing --no-default-features to cargo.

To build for Mac OS X 10.7 (or 10.8) you can enable that feature alone using
--no-default-features --features "macosx_10_7"
## Mac OS X Versions
Calls were added to libproc in 10.9 (Mavericks) and they are under a rust "feature" switch called "macosx_10_9".
The default build includes the "macosx_10_9" feature.

To build for versions prior to Mac OS 10.9 disable the default features by passing `--no-default-features` to cargo.

# Examples
Two simple examples are included to show libproc-rs working.
Expand Down
3 changes: 2 additions & 1 deletion src/libproc/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ pub fn pidfdinfo<T: PIDFDInfo>(pid: i32, fd: i32) -> Result<T, String> {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
let buffer_size = mem::size_of::<T>() as i32;
let mut pidinfo = T::default();
let buffer_ptr = std::ptr::from_mut::<T>(&mut pidinfo).cast::<c_void>();
#[allow(clippy::pedantic)]
let buffer_ptr = &mut pidinfo as *mut _ as *mut c_void;
let ret: i32;

unsafe {
Expand Down
3 changes: 2 additions & 1 deletion src/libproc/pid_rusage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ impl PIDRUsage for RUsageInfoV4 {
pub fn pidrusage<T: PIDRUsage>(pid: i32) -> Result<T, String> {
let flavor = T::flavor() as i32;
let mut pidrusage = T::default();
let buffer_ptr = std::ptr::from_mut::<T>(&mut pidrusage).cast::<c_void>();
#[allow(clippy::pedantic)]
let buffer_ptr = &mut pidrusage as *mut _ as *mut c_void;
let ret: i32;

unsafe {
Expand Down
3 changes: 2 additions & 1 deletion src/libproc/proc_pid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ pub fn pidinfo<T: PIDInfo>(pid: i32, arg: u64) -> Result<T, String> {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
let buffer_size = mem::size_of::<T>() as c_int;
let mut pidinfo = unsafe { mem::zeroed() };
let buffer_ptr = std::ptr::from_mut::<T>(&mut pidinfo).cast::<c_void>();
#[allow(clippy::pedantic)]
let buffer_ptr = &mut pidinfo as *mut _ as *mut c_void;
let ret: i32;

unsafe {
Expand Down

0 comments on commit d16c44d

Please sign in to comment.