[vlc-devel] [PATCH] core: Add atomic refcounter helper

Romain Vimont rom1v at videolabs.io
Sun Jul 1 19:56:03 CEST 2018


On Sun, Jul 01, 2018 at 08:10:54PM +0300, Rémi Denis-Courmont wrote:
> Le sunnuntaina 1. heinäkuuta 2018, 12.30.33 EEST Romain Vimont a écrit :
> > On Sun, Jul 01, 2018 at 11:59:08AM +0300, Rémi Denis-Courmont wrote:
> > > Furthermore the boolean evaluation of the return value is the opposite of
> > > what any other ref counting API does (other than VLC's). Usually, zero is
> > > for last reference and non-zero for non-last references. Again, this is
> > > prone to errors.
> > 
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/
> > refcount.c?h=v4.17#n208
> 
> This is very new.

In 2009, there were already atomic_dec_and_test(), with the same
behavior:
<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/asm-generic/atomic.h?h=v2.6.31#n123>

> And for a decade or two, it was the other way around.
> 
> Confusing, I tell.


More information about the vlc-devel mailing list