Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Community Discord
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# core.volatile

This module declares intrinsics for volatile operations.
License:
Boost License 1.0
Authors:
Walter Bright, Ernesto Castellotti

Source core/volatile.d

nothrow @nogc @safe ubyte `volatileLoad`(ubyte* `ptr`);
nothrow @nogc @safe ushort `volatileLoad`(ushort* `ptr`);
nothrow @nogc @safe uint `volatileLoad`(uint* `ptr`);
nothrow @nogc @safe ulong `volatileLoad`(ulong* `ptr`);
nothrow @nogc @safe void `volatileStore`(ubyte* `ptr`, ubyte `value`);
nothrow @nogc @safe void `volatileStore`(ushort* `ptr`, ushort `value`);
nothrow @nogc @safe void `volatileStore`(uint* `ptr`, uint `value`);
nothrow @nogc @safe void `volatileStore`(ulong* `ptr`, ulong `value`);
  Read/write value from/to the memory location indicated by ptr.
  These functions are recognized by the compiler, and calls to them are guaranteed to not be removed (as dead assignment elimination or presumed to have no effect) or reordered in the same thread.
  These reordering guarantees are only made with regards to other operations done through these functions; the compiler is free to reorder regular loads/stores with regards to loads/stores done through these functions.
  This is useful when dealing with memory-mapped I/O (MMIO) where a store can have an effect other than just writing a value, or where sequential loads with no intervening stores can retrieve different values from the same location due to external stores to the location.
  These functions will, when possible, do the load/store as a single operation. In general, this is possible when the size of the operation is less than or equal to (void*).sizeof, although some targets may support larger operations. If the load/store cannot be done as a single operation, multiple smaller operations will be used.
  These are not to be conflated with atomic operations. They do not guarantee any atomicity. This may be provided by coincidence as a result of the instructions used on the target, but this should not be relied on for portable programs. Further, no memory fences are implied by these functions. They should not be used for communication between threads. They may be used to guarantee a write or read cycle occurs at a specified address.

Copyright © 1999-2020 by the D Language Foundation | Page generated by Ddoc on Sun Jan 5 12:40:28 2020