From owner-svn-src-projects@FreeBSD.ORG Tue Aug 20 22:53:06 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CF066BD3; Tue, 20 Aug 2013 22:53:06 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BC1C8225D; Tue, 20 Aug 2013 22:53:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7KMr6uC079100; Tue, 20 Aug 2013 22:53:06 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7KMr6ih079099; Tue, 20 Aug 2013 22:53:06 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201308202253.r7KMr6ih079099@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 20 Aug 2013 22:53:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r254586 - projects/atomic64/share/man/man9 X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Aug 2013 22:53:07 -0000 Author: jkim Date: Tue Aug 20 22:53:06 2013 New Revision: 254586 URL: http://svnweb.freebsd.org/changeset/base/254586 Log: - Update for atomic_swap() and atomic_testandclear(). - Try to maintain consistent style. Modified: projects/atomic64/share/man/man9/atomic.9 Modified: projects/atomic64/share/man/man9/atomic.9 ============================================================================== --- projects/atomic64/share/man/man9/atomic.9 Tue Aug 20 22:31:13 2013 (r254585) +++ projects/atomic64/share/man/man9/atomic.9 Tue Aug 20 22:53:06 2013 (r254586) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 27, 2005 +.Dd August 20, 2013 .Dt ATOMIC 9 .Os .Sh NAME @@ -62,6 +62,10 @@ .Fn atomic_subtract_[acq_|rel_] "volatile *p" " v" .Ft void .Fn atomic_store_rel_ "volatile *p" " v" +.Ft +.Fn atomic_swap_ "volatile *p" " v" +.Ft int +.Fn atomic_testandset_ "volatile *p" "u_int v" .Sh DESCRIPTION Each of the atomic operations is guaranteed to be atomic in the presence of interrupts. @@ -184,9 +188,9 @@ This section describes the semantics of .Bd -literal -compact if (*dst == old) { *dst = new; - return 1; + return (1); } else - return 0; + return (0); .Ed .El .Pp @@ -203,7 +207,7 @@ and .Bd -literal -compact tmp = *p; *p += v; -return tmp; +return (tmp); .Ed .El .Pp @@ -216,9 +220,9 @@ and .Dq Li 32 and do not have any variants with memory barriers at this time. .Bl -hang -.It Fn atomic_load addr +.It Fn atomic_load p .Bd -literal -compact -return (*addr) +return (*p); .Ed .El .Pp @@ -226,11 +230,11 @@ The .Fn atomic_load functions are only provided with acquire memory barriers. .Bl -hang -.It Fn atomic_readandclear addr +.It Fn atomic_readandclear p .Bd -literal -compact -temp = *addr; -*addr = 0; -return (temp); +tmp = *p; +*p = 0; +return (tmp); .Ed .El .Pp @@ -243,8 +247,7 @@ functions are not implemented for the ty .Dq Li 8 , and .Dq Li 16 -and do -not have any variants with memory barriers at this time. +and do not have any variants with memory barriers at this time. .Bl -hang .It Fn atomic_set p v .Bd -literal -compact @@ -264,6 +267,44 @@ The .Fn atomic_store functions are only provided with release memory barriers. .Pp +.Bl -hang +.It Fn atomic_swap p v +.Bd -literal -compact +tmp = *p; +*p = v; +return (tmp); +.Ed +.El +.Pp +The +.Fn atomic_swap +functions are not implemented for the types +.Dq Li char , +.Dq Li short , +.Dq Li ptr , +.Dq Li 8 , +and +.Dq Li 16 +and do not have any variants with memory barriers at this time. +.Bl -hang +.It Fn atomic_testandset p v +.Bd -literal -compact +bit = 1 << (v % (sizeof(*p) * NBBY)); +tmp = (*p & bit) != 0; +*p |= bit; +return (tmp); +.Ed +.El +.Pp +The +.Fn atomic_testandset +functions are only implemented for the types +.Dq Li int , +.Dq Li long +and +.Dq Li 32 +and do not have any variants with memory barriers at this time. +.Pp The type .Dq Li 64 is currently not implemented for any of the atomic operations on the @@ -275,15 +316,17 @@ architectures. .Sh RETURN VALUES The .Fn atomic_cmpset -function -returns the result of the compare operation. +function returns the result of the compare operation. The .Fn atomic_fetchadd , .Fn atomic_load , +.Fn atomic_readandclear , and -.Fn atomic_readandclear -functions -return the value at the specified address. +.Fn atomic_swap +functions return the value at the specified address. +The +.Fn atomic_testandset +function returns the result of the test operation. .Sh EXAMPLES This example uses the .Fn atomic_cmpset_acq_ptr @@ -354,3 +397,9 @@ The .Fn atomic_fetchadd operations were added in .Fx 6.0 . +The +.Fn atomic_swap +and +.Fn atomic_testandset +operations were added in +.Fx 10.0 .