summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/doc_src_atomic-operations.qdoc
blob: acda5e4135a77c137ea30b8f944371f91e6479dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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]