bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/11] include: add lock-less reference counting primitives


From: Samuel Thibault
Subject: Re: [PATCH 03/11] include: add lock-less reference counting primitives
Date: Tue, 13 May 2014 12:55:29 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Tue 13 May 2014 12:52:03 +0200, a écrit :
> Quoting Neal H. Walfield (2014-05-13 09:44:21)
> > At Mon, 12 May 2014 12:05:41 +0200,
> > Justus Winter wrote:
> > > +/* Decrement REF.  Return the result of the operation.  This function
> > > +   uses atomic operations.  It is not required to serialize calls to
> > > +   this function.  */
> > > +static inline unsigned int
> > > +refcount_deref (refcount_t *ref)
> > > +{
> > > +  return __atomic_sub_fetch (ref, 1, __ATOMIC_RELAXED);
> > > +}
> > 
> > How about adding assert(*ref >= 0)?
> 
> It is there, you just can't see it because I optimized it away (as gcc
> would, as refcount_t is unsigned ;).

Well, he means assert(*ref != UINT_MAX) then.  It'd be good to make sure
we don't underflow.

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]