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
Subject: Re: [PATCH] atomic_long_t & include/asm-generic/atomic.h V2
Date: Tue, 13 Dec 2005 15:49:16 -0800	[thread overview]
Message-ID: <20051213154916.6667b6d8.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.62.0512131417390.24002@schroedinger.engr.sgi.com>

Christoph Lameter <clameter@engr.sgi.com> wrote:
>
> V1->V2:
>  - Allow an arch to provide its on atomic_long_t, so that arches such
>    as sh64 can provide their own atomic_long_t.
>  - Make sure that atomic_long_read() always returns (long) even if the
>    arch uses 32 bit for atomic_long_t so that
>     printk("%ld", atomic_long_read(v))
>    always works (not sure how this could work right if atomic_long is
>    long long like for sh4 but I think that is up to the sh64 developers to
>    figure out).
> 
>  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 atomic64.
> 
>  This patch introduces a new type atomic_long_t by providing definitions in
>  asm-generic/atomic.h that works similar to the c "long" type. Its 32 bits on
>  32 bit platforms and 64 bits on 64 bit platforms.

I dunno, this still looks kludgy.  It looks like we couldn't be assed
implementing atomic_long_t in each architecture ;)

How about requiring that all 64-bit archs implement atomic64_t and do:

#if BIT_PER_LONG == 64

typedef atomic64_t atomic_long_t

static inline long atomic_long_read(atomic_long_t *vl)
{
	/* typecast the return value in case arch uses long long */
	return (long)atomic64_read((atomic64_t *)vl);
}

...

static inline void atomic_long_set(atomic_long_t *vl, long i)
{
	/*
	 * Do the cast separately to avoid possible cast-as-lval errors
	 */
	atomic64_t *v = (atomic64_t *)vl;
	atomic64_set(v, i);
}

#else

typedef atomic_t atomic_long_t

static inline long atomic_long_read(atomic_long_t *vl)
{
	return atomic_read((atomic_t *)vl);
}

...

static inline void atomic_long_set(atomic_long_t *vl, long i)
{
	atomic_t *v = (atomic_t *)vl;
	atomic_set(v, i);
}

#endif

?

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

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 22:19 Christoph Lameter
2005-12-13 23:49 ` Andrew Morton [this message]
2005-12-14  2:55   ` Christoph Lameter
2005-12-14  2:57     ` Andi Kleen
2005-12-14  3:26       ` David S. Miller
2005-12-14  5:18         ` Christoph Lameter
2005-12-14  9:00     ` Paul Jackson

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=20051213154916.6667b6d8.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=ak@suse.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®