Skip to content

Commit

Permalink
Merge pull request #131 from notgull/msrv
Browse files Browse the repository at this point in the history
Add an MSRV policy
  • Loading branch information
zesterer committed Oct 19, 2022
2 parents 8181441 + 5860ee1 commit 0dfb21e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ jobs:
- run: rustup target add thumbv7m-none-eabi
- name: Ensure we don't depend on libstd
run: cargo hack build --target thumbv7m-none-eabi --no-dev-deps --no-default-features

msrv:
runs-on: ubuntu-latest
strategy:
matrix:
version: [1.38.0]
steps:
- uses: actions/checkout@v2
- name: Install Rust
run: rustup update ${{ matrix.version }} && rustup default ${{ matrix.version }}
- run: cargo build --all --all-features --all-targets

miri:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = "MIT"
repository = "https://github.com/mvdnes/spin-rs.git"
keywords = ["spinlock", "mutex", "rwlock"]
description = "Spin-based synchronization primitives"
rust-version = "1.38"

[dependencies]
lock_api_crate = { package = "lock_api", version = "0.4", optional = true }
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ time for your crate's users. You can do this like so:
spin = { version = "x.y", default-features = false, features = [...] }
```

## Minimum Safe Rust Version (MSRV)

This crate is guaranteed to compile on a Minimum Safe Rust Version (MSRV) of 1.38.0 and above.
This version will not be changed without a minor version bump.

## License

`spin` is distributed under the MIT License, (See `LICENSE`).
5 changes: 4 additions & 1 deletion src/relax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ pub struct Spin;
impl RelaxStrategy for Spin {
#[inline(always)]
fn relax() {
core::hint::spin_loop();
// Use the deprecated spin_loop_hint() to ensure that we don't get
// a higher MSRV than we need to.
#[allow(deprecated)]
core::sync::atomic::spin_loop_hint();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl<T: ?Sized, R> RwLock<T, R> {
// Acquire a read lock, returning the new lock value.
fn acquire_reader(&self) -> usize {
// An arbitrary cap that allows us to catch overflows long before they happen
const MAX_READERS: usize = usize::MAX / READER / 2;
const MAX_READERS: usize = core::usize::MAX / READER / 2;

let value = self.lock.fetch_add(READER, Ordering::Acquire);

Expand Down

0 comments on commit 0dfb21e

Please sign in to comment.