lkml.org 
[lkml]   [2005]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Introduce atomic_long_t and asm-generic/atomic.h
Christoph Lameter <clameter@engr.sgi.com> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-12-13 00:47    [W:0.077 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site