mozilla/rust — pull request #12063 by TheHydroImpulse (2014-02-06 09:06:05+00:00)
Title: Added Volatile Types

This PR adds a nicer wrapper around the volatile intrinsics. This PR adds a new volatile module under the unstable module.

I added the following types:

* `VolatilePtr`
* `VolatileInt`
* `VolatileBool`

There is also static types that deal with the specialized types (such as `VolatileBool` and `VolatileInt`)

* `INIT_VOLATILE_BOOL`
* `INIT_VOLATILE_INT`

These can be used basically the same way Atomics are used (I think).

Somethings to consider:

* I'm not sure if the static API/method is correct
* Only two specialized types exist (`int` and `bool`). Other types are super easy to add.
* The `VolatilePtr` doesn't work with static values. The only way I can think of allowing this directly (without using another variable) is to reserve a memory block, the size based on the passed type.

I added tests for all the current functionality and they all seem to pass on my machine.

Let me know if there's anything else I need to change, add, remove, etc...