Re: [PATCH] atomic: generalize atomic_add_unless_return

From: Eric Dumazet
Date: Sun Jun 05 2011 - 03:35:33 EST


Le dimanche 05 juin 2011 Ã 00:09 -0400, Mike Frysinger a Ãcrit :
> On Tue, May 31, 2011 at 20:57, Arun Sharma wrote:

> > --- a/include/linux/atomic.h
> > +++ b/include/linux/atomic.h
> > /**
> > + * atomic_add_unless - add unless the number is already a given value
> > + * @v: pointer of type atomic_t
> > + * @a: the amount to add to v...
> > + * @u: ...unless v is equal to u.
> > + *
> > + * Atomically adds @a to @v, so long as @v was not already @u.
> > + * Returns the old value of @v + @a.
> > + */
> > +static inline int atomic_add_unless_return(atomic_t *v, int a, int u)
>
> the name of the func in the comment does not match the actual name of the func
>
> also, the semantics here appear to deviate from the other atomic
> funcs. the existing xxx_return funcs return the new result, not the
> old.
> -mike

Arun comment is wrong, this function does return the new value of the
atomic_t after our operation, not the old ;)



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