Christoph Lameter <[email protected]> wrote:
>
> +#ifdef ATOMIC64_INIT
> +
> +#define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
> +#define atomic_long_t atomic64_t
> +#define atomic_long_read(v) atomic64_read(v)
> +#define atomic_long_set(v,i) atomic64_set(v,i)
> +#define atomic_long_inc(v) atomic64_inc(v)
> +#define atomic_long_dec(v) atomic64_dec(v)
> +#define atomic_long_add(i,v) atomic64_add(i,v)
> +#define atomic_long_sub(i,v) atomic64_sub(i,v)
> +
> +#else
> +
> +#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
> +#define atomic_long_t atomic_t
> +#define atomic_long_read(v) atomic_read(v)
> +#define atomic_long_set(v,i) atomic_set(v,i)
> +#define atomic_long_inc(v) atomic_inc(v)
> +#define atomic_long_dec(v) atomic_dec(v)
> +#define atomic_long_add(i,v) atomic_add(i,v)
> +#define atomic_long_sub(i,v) atomic_sub(i,v)
> +
> +#endif
It's sneaky, but it's not really good enough, IMO.
It assumes that sizeof(long) = sizeof(int) ifndef ATOMIC64_INIT. Which is
true, but there are still problems. For example, I'd reasonably expect this:
printk("%ld", atomic_long_read(v));
to not produce a warning. It may also lead to long*/int* warnings or build
errors.
Also, it kind-of assumes that each 64-bit arch uses `long' for its 64-bit
value. sh64, for example, appears to use `long long'.
Perhaps all this can be fixed by filling the above macros with typecasts.
Remember that typecasted lvals are illegal with gcc-4.x.
Or we bite the bullet and implement these guys in each arch...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]