From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 8 13:06:26 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6B2A81065675; Sun, 8 Aug 2010 13:06:26 +0000 (UTC) (envelope-from emaste@freebsd.org) Received: from mail1.sandvine.com (mail1.sandvine.com [64.7.137.162]) by mx1.freebsd.org (Postfix) with ESMTP id D96C08FC15; Sun, 8 Aug 2010 13:06:25 +0000 (UTC) Received: from labgw2.phaedrus.sandvine.com (192.168.222.22) by WTL-EXCH-1.sandvine.com (192.168.196.31) with Microsoft SMTP Server id 14.0.694.0; Sun, 8 Aug 2010 09:06:23 -0400 Received: by labgw2.phaedrus.sandvine.com (Postfix, from userid 10332) id 1514F33C00; Sun, 8 Aug 2010 09:06:25 -0400 (EDT) Date: Sun, 8 Aug 2010 09:06:25 -0400 From: Ed Maste To: Ivan Voras Message-ID: <20100808130624.GB40928@sandvine.com> References: <86fwyq8rsc.fsf@ds4.des.no> <86d3tujh72.fsf@ds4.des.no> <864of680wv.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Cc: Dag-Erling Sm??rgrav , Garrett, Cooper , freebsd-hackers@freebsd.org Subject: Re: Why is TUNABLE_INT discouraged? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Aug 2010 13:06:26 -0000 On Sun, Aug 08, 2010 at 01:30:19AM +0200, Ivan Voras wrote: > 2010/8/8 Dag-Erling Sm??rgrav : > > Garrett Cooper writes: > >> Dag-Erling Sm??rgrav writes: > >> > Perhaps. ??I don't remember all the details; I can't find a discussion in > >> > the list archives (other than me announcing the change in response to a > >> > bug report), but there must have been one, either on IRC or in Karlsruhe. > >> > In any case, I never removed TUNABLE_INT(), so... > >> It does matter for integers on 64-bit vs 32-bit architectures though, > >> right > > > > Not sure what you mean. ??The original issue was that someone had used > > TUNABLE_INT() for something that was actually a memory address. ??I > > changed it to TUNABLE_ULONG(). ??Of course, if your tunable is a boolean > > value or something like maxprocs, an int is fine - but so is a long. > > Semantically valid but using TUNABLE_INT to hold pointers is a > developer bug, not the fault of the API, and there's nothing wrong > with "int" as a data type in this context. I agree with Ivan here. If we can't find an actual reason to universally prefer long I'd like to remove this comment. As a counterpoint to the preference for long I can offer a reason to prefer int: the same variable is often exposed by both a tunable and a sysctls, and a sysctl using long can have 32-bit compat issues. (That is, a 32-bit app using sysctlbyname will try to use 4 bytes for a long.) -Ed