summaryrefslogtreecommitdiffstats
path: root/Documentation/atomic_t.txt
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2019-02-11 12:09:43 -0500
committerPaul E. McKenney <paulmck@linux.ibm.com>2019-03-18 13:27:52 -0400
commitf1887143f5984f23d2360f2efed6ef481bb41117 (patch)
tree81f6da1d80d8ba7e9472b5c346379b2bdf332851 /Documentation/atomic_t.txt
parentdb467147f131b8ab799066b9779addb8603d3baf (diff)
Documentation/atomic_t: Clarify signed vs unsigned
Clarify the whole signed vs unsigned issue for atomic_t. There has been enough confusion on this topic to warrant a few explicit words I feel. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Will Deacon <will.deacon@arm.com> Acked-by: Boqun Feng <boqun.feng@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
Diffstat (limited to 'Documentation/atomic_t.txt')
-rw-r--r--Documentation/atomic_t.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/Documentation/atomic_t.txt b/Documentation/atomic_t.txt
index 913396ac5824..dca3fb0554db 100644
--- a/Documentation/atomic_t.txt
+++ b/Documentation/atomic_t.txt
@@ -56,6 +56,23 @@ Barriers:
56 smp_mb__{before,after}_atomic() 56 smp_mb__{before,after}_atomic()
57 57
58 58
59TYPES (signed vs unsigned)
60-----
61
62While atomic_t, atomic_long_t and atomic64_t use int, long and s64
63respectively (for hysterical raisins), the kernel uses -fno-strict-overflow
64(which implies -fwrapv) and defines signed overflow to behave like
652s-complement.
66
67Therefore, an explicitly unsigned variant of the atomic ops is strictly
68unnecessary and we can simply cast, there is no UB.
69
70There was a bug in UBSAN prior to GCC-8 that would generate UB warnings for
71signed types.
72
73With this we also conform to the C/C++ _Atomic behaviour and things like
74P1236R1.
75
59 76
60SEMANTICS 77SEMANTICS
61--------- 78---------