RE: Question on atomic_inc/dec

From: Perez-Gonzalez, Inaky
Date: Wed Oct 15 2003 - 12:40:28 EST


> From: sankar [mailto:san_madhav@xxxxxxxxxxx]

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/