From owner-svn-src-head@FreeBSD.ORG Sun May 23 09:01:44 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA3C1106567F; Sun, 23 May 2010 09:01:44 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail05.syd.optusnet.com.au (mail05.syd.optusnet.com.au [211.29.132.186]) by mx1.freebsd.org (Postfix) with ESMTP id 6149A8FC19; Sun, 23 May 2010 09:01:43 +0000 (UTC) Received: from c122-107-114-249.carlnfd1.nsw.optusnet.com.au (c122-107-114-249.carlnfd1.nsw.optusnet.com.au [122.107.114.249]) by mail05.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o4N91f7A010101 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 23 May 2010 19:01:42 +1000 Date: Sun, 23 May 2010 19:01:41 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Poul-Henning Kamp In-Reply-To: <201005200618.o4K6I3G3010713@svn.freebsd.org> Message-ID: <20100523183502.C13588@delplex.bde.org> References: <201005200618.o4K6I3G3010713@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r208332 - in head/sys: amd64/include i386/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2010 09:01:45 -0000 On Thu, 20 May 2010, Poul-Henning Kamp wrote: > Log: > Rename an argument from "exp" to "expect" since the former makes FlexeLint > uneasy, in case anybody think it might be exp(3) in libm. Bug in FlexeLint. exp(3) is supposed to be in libc, so conflicts with it are more possible than with a function in a pure independent library, but even then exp is only reserved at certain scopes that don't apply here, and this reservation actually reduces the problem (since exp is reserved as a macro iff is included, applications cannot #define it then and shouldn't #define it otherwise). should be kernel-only. > This also makes it consistent with other archs. Bug in the other arches. > Modified: head/sys/amd64/include/atomic.h > ============================================================================== > --- head/sys/amd64/include/atomic.h Thu May 20 06:16:13 2010 (r208331) > +++ head/sys/amd64/include/atomic.h Thu May 20 06:18:03 2010 (r208332) > @@ -76,8 +76,8 @@ > void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \ > void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v) > > -int atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src); > -int atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src); > +int atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src); > +int atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src); > u_int atomic_fetchadd_int(volatile u_int *p, u_int v); > u_long atomic_fetchadd_long(volatile u_long *p, u_long v); > Function parameters are in thir own namespace, so they cannot conflict with the extern function `exp', and one named `exp' is less likely to conflict with anything than one name `p' for example. > @@ -124,13 +124,13 @@ struct __hack > /* > * Atomic compare and set, used by the mutex functions > * > - * if (*dst == exp) *dst = src (all 32 bit words) > + * if (*dst == expect) *dst = src (all 32 bit words) > * > * Returns 0 on failure, non-zero on success > */ > > static __inline int > -atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src) > +atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) This API not only should be kernel-only; it obviously is kernel-only (despite abuses in libc and hopefully nowhere else), since like most kernel-only headers it takes no care with namespaces -- here it uses the popular identifiers dst and src. Style bug: all the parameters had short names of the same length. Now `expect' is odd. The atomic API is also kernel-only in its man page, and its man page uses quite different parameter names to the above, so no change to the man page is needed to be compatible with this commit, but either the code or the man page should be changed to be compatible with each other. In the man page, the parameter names for the above function are (dst, old, new); the man page has no reference to either `exp' or `expect'. Both sets are especially incompletely descriptive for the old/expect parameter because the semantics of this parameter are especially complicated so they cannot be described in 1 word. Bruce