diff options
Diffstat (limited to 'doc/src/snippets/code/doc_src_atomic-operations.qdoc')
-rw-r--r-- | doc/src/snippets/code/doc_src_atomic-operations.qdoc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/doc/src/snippets/code/doc_src_atomic-operations.qdoc b/doc/src/snippets/code/doc_src_atomic-operations.qdoc new file mode 100644 index 0000000..acda5e4 --- /dev/null +++ b/doc/src/snippets/code/doc_src_atomic-operations.qdoc @@ -0,0 +1,71 @@ +//! [0] +if (*ptr == expected) { + *ptr = newval; + return !0; +} +return 0; +//! [0] + + +//! [1] +if (*ptr == expected) { + *ptr = newval; + return !0; +} +return 0; +//! [1] + + +//! [2] +++(*ptr); +return *ptr ? !0 : 0; +//! [2] + + +//! [3] +return ++(*ptr); +//! [3] + + +//! [4] +++(*ptr); +return !(ControlRegister & ZeroFlag); +//! [4] + + +//! [5] +--(*ptr); +return *ptr ? : 0; +//! [5] + + +//! [6] +return --(*ptr); +//! [6] + + +//! [7] +--(*ptr); +return !(ControlRegister & ZeroFlag); +//! [7] + + +//! [8] +tmp = *ptr; +*ptr = newval; +return tmp; +//! [8] + + +//! [9] +tmp = *ptr; +*ptr = newval; +return tmp; +//! [9] + + +//! [10] +tmp = *ptr; +*ptr += value; +return tmp; +//! [10] |