Skip to contentSkip to conversation

x86, atomic: atomic64_read() take a const pointer

tip:x86/urgent tip-bot for H. Peter Anvin 1 participant 1 message Jan 10, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Commit-ID:  8030c36d13f030103356709e63638678fdc66fdc
Gitweb:     http://git.kernel.org/tip/8030c36d13f030103356709e63638678fdc66fdc
Author:     H. Peter Anvin <[email protected]>
AuthorDate: Mon, 9 Jan 2012 19:33:24 -0800
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Mon, 9 Jan 2012 19:33:24 -0800

x86, atomic: atomic64_read() take a const pointer

atomic64_read() doesn't actually write anything (as far as the C environment is concerned... the CPU does actually write but that's an implementation quirk), so it should take a const pointer.

This does NOT mean that it is safe to use atomic64_read() on an object in readonly storage (it will trap!)

---
 arch/x86/include/asm/atomic64_32.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/include/asm/atomic64_32.h +1 -1
index 24098aa..fa13f0e 100644
@@ -82,7 +82,7 @@ static inline void atomic64_set(atomic64_t *v, long long i)
  *
  * Atomically reads the value of @v and returns it.
  */
-static inline long long atomic64_read(atomic64_t *v)
+static inline long long atomic64_read(const atomic64_t *v)
 {
 	long long r;
 	asm volatile(ATOMIC64_ALTERNATIVE(read)