svn commit: r251796 - head/sbin/hastd

Pawel Jakub Dawidek pjd at FreeBSD.org
Sat Jun 15 23:23:13 UTC 2013


On Sat, Jun 15, 2013 at 10:18:00PM +0000, Ed Schouten wrote:
> Author: ed
> Date: Sat Jun 15 22:17:59 2013
> New Revision: 251796
> URL: http://svnweb.freebsd.org/changeset/base/251796
> 
> Log:
>   Let hastd use C11 atomics.
>   
>   C11 atomics now work on all the architectures. Have at least a single
>   piece of software in our base system that uses C11 atomics. This
>   somewhat makes it less likely that we break it because of LLVM imports,
>   etc.

Hmm, I don't like HAST to be a victim of bad LLVM import. This is not
the kind of software you run on HEAD (so it might go unnoticed
initially)  and this is the kind of software that when breaks can have
serious consequences.

What kind of breaks are we talking about? That HAST will stop compiling
or HAST can start corrupting data?

> Modified:
>   head/sbin/hastd/refcnt.h
> 
> Modified: head/sbin/hastd/refcnt.h
> ==============================================================================
> --- head/sbin/hastd/refcnt.h	Sat Jun 15 21:29:47 2013	(r251795)
> +++ head/sbin/hastd/refcnt.h	Sat Jun 15 22:17:59 2013	(r251796)
> @@ -32,24 +32,24 @@
>  #ifndef __REFCNT_H__
>  #define __REFCNT_H__
>  
> -#include <machine/atomic.h>
> +#include <stdatomic.h>
>  
>  #include "pjdlog.h"
>  
> -typedef unsigned int refcnt_t;
> +typedef atomic_uint refcnt_t;
>  
>  static __inline void
>  refcnt_init(refcnt_t *count, unsigned int v)
>  {
>  
> -	*count = v;
> +	atomic_init(count, v);
>  }
>  
>  static __inline void
>  refcnt_acquire(refcnt_t *count)
>  {
>  
> -	atomic_add_acq_int(count, 1);
> +	atomic_fetch_add_explicit(count, 1, memory_order_acquire);
>  }
>  
>  static __inline unsigned int
> @@ -58,7 +58,7 @@ refcnt_release(refcnt_t *count)
>  	unsigned int old;
>  
>  	/* XXX: Should this have a rel membar? */
> -	old = atomic_fetchadd_int(count, -1);
> +	old = atomic_fetch_sub(count, 1);
>  	PJDLOG_ASSERT(old > 0);
>  	return (old - 1);
>  }

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://mobter.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20130616/d4fb7e1f/attachment.sig>


More information about the svn-src-head mailing list