{"id":22911271,"url":"https://github.com/rust-osdev/volatile","last_synced_at":"2025-04-04T19:09:45.045Z","repository":{"id":38408871,"uuid":"69866859","full_name":"rust-osdev/volatile","owner":"rust-osdev","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-06T11:49:30.000Z","size":242,"stargazers_count":74,"open_issues_count":2,"forks_count":19,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-28T18:13:56.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-osdev.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-03T12:04:09.000Z","updated_at":"2025-03-18T22:36:26.000Z","dependencies_parsed_at":"2024-04-28T10:22:32.200Z","dependency_job_id":"48f4d4a7-3fb7-47b3-9db2-a98fb6404600","html_url":"https://github.com/rust-osdev/volatile","commit_stats":{"total_commits":88,"total_committers":10,"mean_commits":8.8,"dds":"0.15909090909090906","last_synced_commit":"2a629b3ffc3728b2a482ac57afbbac3687d03f9f"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fvolatile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fvolatile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fvolatile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-osdev%2Fvolatile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-osdev","download_url":"https://codeload.github.com/rust-osdev/volatile/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234921,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T04:15:59.393Z","updated_at":"2025-04-04T19:09:44.995Z","avatar_url":"https://github.com/rust-osdev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `volatile`\n\n[![Build Status](https://github.com/rust-osdev/volatile/workflows/Build/badge.svg)](https://github.com/rust-osdev/volatile/actions?query=workflow%3ABuild) [![Docs.rs Badge](https://docs.rs/volatile/badge.svg)](https://docs.rs/volatile/)\n\nProvides volatile wrapper types for raw pointers.\n\nThe volatile wrapper types in this crate wrap a pointer to any `Copy`-able type and provide volatile memory access to wrapped value.\nVolatile memory accesses are never optimized away by the compiler, and are useful in many low-level systems programming and concurrent contexts.\n\nThis crate provides two different wrapper types: `VolatilePtr` and `VolatileRef`.\nThe difference between the two types is that the former behaves like a raw pointer, while the latter behaves like a Rust reference type.\nFor example, `VolatilePtr` can be freely copied, but not sent across threads because this could introduce mutable aliasing.\nThe `VolatileRef` type, on the other hand, requires exclusive access for mutation, so that sharing it across thread boundaries is safe.\n\nBoth wrapper types *do not* enforce any atomicity guarantees; to also get atomicity, consider looking at the `Atomic` wrapper types found in `libcore` or `libstd`.\n\n## Why is there no `VolatileCell`?\n\nMany people expressed interest in a `VolatileCell` type, i.e. a transparent wrapper type that owns the wrapped value.\nSuch a type would be similar to `core::cell::Cell`, with the difference that all methods are volatile.\nUnfortunately, it is not sound to implement such a `VolatileCell` type in Rust.\nThe reason is that Rust and LLVM consider `\u0026` and `\u0026mut` references as _dereferencable_.\nThis means that the compiler is allowed to freely access the referenced value without any restrictions.\nSo no matter how a `VolatileCell` type is implemented, the compiler is allowed to perform non-volatile read operations of the contained value, which can lead to unexpected (or even undefined?) behavior.\nFor more details, see the discussion [in our repository](https://github.com/rust-osdev/volatile/issues/31) and [in the `unsafe-code-guidelines` repository](https://github.com/rust-lang/unsafe-code-guidelines/issues/411).\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or\n  http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\nUnless 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-osdev%2Fvolatile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-osdev%2Fvolatile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-osdev%2Fvolatile/lists"}