mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RE: Question on atomic_inc/dec
@ 2003-10-15 17:38 Perez-Gonzalez, Inaky
  2003-10-15 18:02 ` [OT] " Petr Vandrovec
  0 siblings, 1 reply; 2+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-15 17:38 UTC (permalink / raw)
  To: sankar, Tim Hockin; +Cc: linux-kernel

> From: sankar [mailto:san_madhav@hotmail.com]

>  any solution to the original problem???
> (atomic_inc() defintion not there in redhat 9.0 asm/atomic.h)

Create an atomic.h header file in your source tree with the code
below, but bear in mind that porting to other arches might be painful:

struct atomic
{
  volatile int i;
}

  /* Simple atomic increment. */

static inline
void atomic_inc (struct atomic *a)
{
    asm volatile (
      "lock; incl %0"
      : "=m" (a->i)
      : "m" (a->i));
}

  /* Simple atomic decrement. */

static inline
void atomic_dec (struct atomic *a)
{
    asm volatile (
      "lock; decl %0"
      : "=m" (a->i)
      : "m" (a->i));
}

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [OT] Question on atomic_inc/dec
  2003-10-15 17:38 Question on atomic_inc/dec Perez-Gonzalez, Inaky
@ 2003-10-15 18:02 ` Petr Vandrovec
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vandrovec @ 2003-10-15 18:02 UTC (permalink / raw)
  To: san_madhav; +Cc: inaky.perez-gonzalez, Tim Hockin, linux-kernel

On Wed, Oct 15, 2003 at 10:38:14AM -0700, Perez-Gonzalez, Inaky wrote:
> > From: sankar [mailto:san_madhav@hotmail.com]
> 
> >  any solution to the original problem???
> > (atomic_inc() defintion not there in redhat 9.0 asm/atomic.h)
> 
> Create an atomic.h header file in your source tree with the code
> below, but bear in mind that porting to other arches might be painful:

It is OT, but if you are interested, take a look at include/private/*atomic*,
include/private/*/*atomic* and relevant portions (ncphost) of configure.ac 
in the ncpfs package (http://platan.vc.cvut.cz/ftp/pub/linux/ncpfs/ncpfs-2.2.3.tar.gz).

It contains UP, pthread based, and several asm optimized versions of
atomic ops. I'm not 100% sure that all asm versions work correctly,
but I have received no complaints yet...
					Best regards,
						Petr Vandrovec
						vandrove@vc.cvut.cz


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-15 18:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-15 17:38 Question on atomic_inc/dec Perez-Gonzalez, Inaky
2003-10-15 18:02 ` [OT] " Petr Vandrovec

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®