Re: [RFC] Introduce atomic_long_t

Adrian Bunk
2005-12-09T20:11:30Z

On Fri, Dec 09, 2005 at 10:58:40AM -0800, Christoph Lameter wrote:

> Several counters already have the need to use 64 atomic variables on 64
> bit platforms (see mm_counter_t in sched.h). We have to do ugly ifdefs to
> fall back to 32 bit atomic on 32 bit platforms.
>
> The VM statistics patch that I am working on will also need to make more
> extensive use of 64 bit counters when available.
>
> This patch introduces a new type atomic_long_t that works similar to the c
> "long" type. Its 32 bits on 32 bit platforms and 64 bits on 64 bit platforms.
>
> The patch uses atomic_long_t to clean up the mess in include/linux/sched.h.
> Implementations for all arches provided but only tested on ia64.
>...

The idea looks good, but the amount of code duplication is ugly.

What about creating an include/linux/atomic.h [1] that contains both
this new code and other common code like the atomic_t typedef (unless
there's a good reason why counter isn't volatile on h8300 and v850...).

cu
Adrian

[1] include/asm-generic/atomic.h would be another solution, but for
an API that should be available on all architectures, include/linux/
seems to be the more logical place