From owner-svn-src-all@FreeBSD.ORG Sat Jun 15 22:18:00 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9C05DD40; Sat, 15 Jun 2013 22:18:00 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8CB7C1AF3; Sat, 15 Jun 2013 22:18:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5FMI0m6047136; Sat, 15 Jun 2013 22:18:00 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5FMI0uT047135; Sat, 15 Jun 2013 22:18:00 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201306152218.r5FMI0uT047135@svn.freebsd.org> From: Ed Schouten Date: Sat, 15 Jun 2013 22:18:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251796 - head/sbin/hastd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jun 2013 22:18:00 -0000 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. 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 +#include #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); }