#atomic #pointers #load #size #stores #platform

no-std atomic_fn

Generic AtomicFnPtr<T> wrapper type for atomic function pointers

1 unstable release

0.2.1 Apr 3, 2022

#339 in No standard library

Download history 8/week @ 2024-07-22 72/week @ 2024-07-29 33/week @ 2024-08-05 12/week @ 2024-08-12 3/week @ 2024-08-19 6/week @ 2024-08-26 14/week @ 2024-09-02 3/week @ 2024-09-09 9/week @ 2024-09-16 40/week @ 2024-09-23 14/week @ 2024-09-30 10/week @ 2024-10-07 19/week @ 2024-10-14 13/week @ 2024-10-21 19/week @ 2024-10-28 26/week @ 2024-11-04

77 downloads per month
Used in 3 crates (via simple_pg_client)

MIT/Apache

24KB
259 lines

atomic_fn

A library which provides a generic AtomicFnPtr<T> type for all T where T is a function pointer such as fn() or fn(usize) -> usize. Probably works, but not recommended for serious use yet.

This library always uses native atomic instructions since function pointers almost always have the right size and alignment for atomic loads and stores. In case function pointers on the target platform do not have the right size or alignment for atomic loads and stores, the library fails to compile, and if that is bypassed, there are runtime guards that panic if the size or alignment is not supported.

This crate uses #![no_std] and only depends on libcore.

Usage

Add this to your Cargo.toml:

[dependencies]
atomic_fn = "0.2"

and this to your crate root:

extern crate atomic;

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps