All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@osdl.org>
Subject: Re: [patch 2/5] atomic: cmpxchg
Date: Sat, 5 Nov 2005 09:00:10 +0000	[thread overview]
Message-ID: <20051105090010.GA18926@flint.arm.linux.org.uk> (raw)
In-Reply-To: <436C65E8.8080501@yahoo.com.au>

On Sat, Nov 05, 2005 at 06:57:28PM +1100, Nick Piggin wrote:
> Index: linux-2.6/include/asm-arm/atomic.h
> ===================================================================
> --- linux-2.6.orig/include/asm-arm/atomic.h
> +++ linux-2.6/include/asm-arm/atomic.h
> @@ -80,6 +80,23 @@ static inline int atomic_sub_return(int 
>  	return result;
>  }
>  
> +static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
> +{
> +	u32 oldval, res;
> +
> +	do {
> +		__asm__ __volatile__("@ atomic_cmpxchg\n"
> +		"ldrex	%1, [%2]\n"
> +		"teq	%1, %3\n"
> +		"strexeq %0, %4, [%2]\n"
> +		    : "=&r" (res), "=&r" (oldval)
> +		    : "r" (&ptr->counter), "r" (old), "r" (new)
> +		    : "cc");
> +	} while (res);
> +
> +	return oldval;
> +}
> +
>  static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
>  {
>  	unsigned long tmp, tmp2;
> @@ -131,6 +148,21 @@ static inline int atomic_sub_return(int 
>  	return val;
>  }
>  
> +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
> +{
> +	int ret;
> +	unsigned long flags;
> +
> +	local_irq_save(flags);
> +	ret = v->counter;
> +	if (likely(ret == old))
> +		v->counter = new;
> +	local_irq_restore(flags);
> +
> +	return ret;
> +}
> +
> +static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
>  static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)

This is obviously going to break ARM...

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

  parent reply	other threads:[~2005-11-05  9:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-05  7:55 [patch 0/4] atomic primitives again Nick Piggin
2005-11-05  7:56 ` [patch 1/5] i386: generic cmpxchg Nick Piggin
2005-11-05  7:57   ` [patch 2/5] atomic: cmpxchg Nick Piggin
2005-11-05  7:58     ` [patch 3/5] atomic: inc_not_zero Nick Piggin
2005-11-05  7:58       ` [patch 4/5] rcu file: use atomic Nick Piggin
2005-11-05  7:59         ` [patch 5/5] atomic: dec_and_lock " Nick Piggin
2005-11-05  9:00     ` Russell King [this message]
2005-11-05  9:10       ` [patch 2/5] atomic: cmpxchg Nick Piggin
2005-11-05  9:13         ` Russell King
2005-11-05  9:21           ` Nick Piggin

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=20051105090010.GA18926@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.