[lkml]   [2007]   [Aug]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] make atomic_t volatile on all architectures

On Wed, 8 Aug 2007, Chris Snook wrote:
> Some architectures currently do not declare the contents of an atomic_t to be
> volatile. This causes confusion since atomic_read() might not actually read
> anything if an optimizing compiler re-uses a value stored in a register, which
> can break code that loops until something external changes the value of an
> atomic_t.

I'd be *much* happier with "atomic_read()" doing the "volatile" instead.

The fact is, volatile on data structures is a bug. It's a wart in the C
language. It shouldn't be used.

Volatile accesses in *code* can be ok, and if we have "atomic_read()"
expand to a "*(volatile int *)&(x)->value", then I'd be ok with that.

But marking data structures volatile just makes the compiler screw up
totally, and makes code for initialization sequences etc much worse.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-08-09 06:23    [W:0.204 / U:0.636 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site