mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Christoph Lameter <clameter@engr.sgi.com>
Cc: linux-kernel@vger.kernel.org, ak@suse.de, bunk@stusta.de
Subject: Re: [PATCH] Introduce atomic_long_t and asm-generic/atomic.h
Date: Mon, 12 Dec 2005 15:42:24 -0800	[thread overview]
Message-ID: <20051212154224.10a8c5e4.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.62.0512121028410.14769@schroedinger.engr.sgi.com>

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...

  reply	other threads:[~2005-12-12 23:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-12 18:35 Christoph Lameter
2005-12-12 23:42 ` Andrew Morton [this message]
2005-12-12 23:51   ` Christoph Lameter
2005-12-13 15:13 ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051212154224.10a8c5e4.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=ak@suse.de \
    --cc=bunk@stusta.de \
    --cc=clameter@engr.sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®