Commit b29f38a4 authored by Daniel Colascione's avatar Daniel Colascione Committed by Facebook Github Bot 7

Explain union safety in MicroLock comment

Reviewed By: ot

Differential Revision: D3045850

fb-gh-sync-id: ee19b146c43410d8d8804c9bfe79c3811394b10e
shipit-source-id: ee19b146c43410d8d8804c9bfe79c3811394b10e
parent 4bdddb9e
...@@ -43,6 +43,10 @@ namespace folly { ...@@ -43,6 +43,10 @@ namespace folly {
* limit yourself to MicroLock slot zero, which will use the two * limit yourself to MicroLock slot zero, which will use the two
* least-significant bits in the bottom byte. * least-significant bits in the bottom byte.
* *
* (Note that such a union is safe only because MicroLock is based on
* a character type, and even under a strict interpretation of C++'s
* aliasing rules, character types may alias anything.)
*
* MicroLock uses a dirty trick: it actually operates on the full * MicroLock uses a dirty trick: it actually operates on the full
* word-size, word-aligned bit of memory into which it is embedded. * word-size, word-aligned bit of memory into which it is embedded.
* It never modifies bits outside the ones it's defined to modify, but * It never modifies bits outside the ones it's defined to modify, but
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment