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 01:04:13 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

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 references {
> +  uint32_t hard;
> +  uint32_t weak;
> +};
> +
> +union _references {
> +  struct references refs;
> +  refcounts_t rc;
> +};
> +
> +/* Initialize REF with HARD and WEAK references.  */
> +static inline void
> +refcounts_init (refcounts_t *ref, uint32_t hard, uint32_t weak)
> +{
> +  ((union _references *) ref)->refs =

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.

Samuel



reply via email to

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