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

2014-05-13 Thread Justus Winter
Quoting Samuel Thibault (2014-05-13 12:55:29) > 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 f

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

2014-05-13 Thread Samuel Thibault
Richard Braun, le Tue 13 May 2014 14:01:59 +0200, a écrit : > On Tue, May 13, 2014 at 12:56:03PM +0200, Samuel Thibault wrote: > > > > AIUI this cast is a case of type-puning. Why not making refcounts_t the > > > > union itself? That way would be clearly safe with gcc's extension. > > > > > > As

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

2014-05-13 Thread Richard Braun
On Tue, May 13, 2014 at 12:56:03PM +0200, Samuel Thibault wrote: > > > AIUI this cast is a case of type-puning. Why not making refcounts_t the > > > union itself? That way would be clearly safe with gcc's extension. > > > > As stated in the comment for refcounts_t, I like the idea of using the >

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

2014-05-13 Thread Neal H. Walfield
At Tue, 13 May 2014 13:47:51 +0200, Samuel Thibault wrote: > > Neal H. Walfield, le Tue 13 May 2014 13:44:37 +0200, a écrit : > > At Tue, 13 May 2014 12:52:03 +0200, > > Justus Winter wrote: > > > Quoting Neal H. Walfield (2014-05-13 09:44:21) > > > > At Mon, 12 May 2014 12:05:41 +0200, > > > > Ju

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

2014-05-13 Thread Samuel Thibault
Neal H. Walfield, le Tue 13 May 2014 13:44:37 +0200, a écrit : > At Tue, 13 May 2014 12:52:03 +0200, > Justus Winter wrote: > > 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 op

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

2014-05-13 Thread Neal H. Walfield
At Tue, 13 May 2014 12:52:03 +0200, Justus Winter wrote: > > 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 req

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

2014-05-13 Thread Samuel Thibault
Justus Winter, le Tue 13 May 2014 12:50:54 +0200, a écrit : > Quoting Samuel Thibault (2014-05-13 01:04:13) > > Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > > > +/* An opaque type. You must not access these values directly. */ > > > +typedef uint64_t refcounts_t; > > > + > > > +/

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

2014-05-13 Thread Samuel Thibault
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 req

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

2014-05-13 Thread Justus Winter
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 inl

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

2014-05-13 Thread Justus Winter
Quoting Samuel Thibault (2014-05-13 01:04:13) > Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > > +/* An opaque type. You must not access these values directly. */ > > +typedef uint64_t refcounts_t; > > + > > +/* Instead, the functions manipulating refcounts_t values write the > > +

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

2014-05-13 Thread Neal H. Walfield
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) > +{ >

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

2014-05-12 Thread Samuel Thibault
Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > +/* An opaque type. You must not access these values directly. */ > +typedef uint64_t refcounts_t; > + > +/* Instead, the functions manipulating refcounts_t values write the > + results into this kind of objects. */ > +struct refere

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

2014-05-12 Thread Samuel Thibault
Richard Braun, le Tue 13 May 2014 00:36:44 +0200, a écrit : > On Tue, May 13, 2014 at 12:23:48AM +0200, Samuel Thibault wrote: > > Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > > > + const union _references op = { .refs = { .hard = 1 } }; > > > + refcounts_t r = __atomic_add_fetch

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

2014-05-12 Thread Richard Braun
On Tue, May 13, 2014 at 12:23:48AM +0200, Samuel Thibault wrote: > Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > > + const union _references op = { .refs = { .hard = 1 } }; > > + refcounts_t r = __atomic_add_fetch (ref, op.rc, __ATOMIC_RELAXED); > > Mmm, I don't think it is allow

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

2014-05-12 Thread Samuel Thibault
Justus Winter, le Mon 12 May 2014 12:05:41 +0200, a écrit : > + const union _references op = { .refs = { .hard = 1 } }; > + refcounts_t r = __atomic_add_fetch (ref, op.rc, __ATOMIC_RELAXED); Mmm, I don't think it is allowed by C to write into a field and read from another field. The legacy Hurd