Date: Sun, 8 Aug 2010 09:06:25 -0400 From: Ed Maste <emaste@freebsd.org> To: Ivan Voras <ivoras@freebsd.org> Cc: Dag-Erling Sm??rgrav <des@des.no>, Garrett, Cooper <gcooper@freebsd.org>, freebsd-hackers@freebsd.org Subject: Re: Why is TUNABLE_INT discouraged? Message-ID: <20100808130624.GB40928@sandvine.com> In-Reply-To: <AANLkTinraF50O%2Bcp_h1m6TODnoz_7R3WXfjTanh-86mn@mail.gmail.com> References: <AANLkTinKaiGFhKRgqQ%2BFjm=02VfWCxULe0a68y-PkJx6@mail.gmail.com> <86fwyq8rsc.fsf@ds4.des.no> <i3kbis$73l$1@dough.gmane.org> <86d3tujh72.fsf@ds4.des.no> <AANLkTi=puD%2B-WeZ%2BFGdtZtw1v%2BNnGD_htwNa%2BEn9fcML@mail.gmail.com> <864of680wv.fsf@ds4.des.no> <AANLkTinraF50O%2Bcp_h1m6TODnoz_7R3WXfjTanh-86mn@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Aug 08, 2010 at 01:30:19AM +0200, Ivan Voras wrote: > 2010/8/8 Dag-Erling Sm??rgrav <des@des.no>: > > Garrett Cooper <gcooper@FreeBSD.org> writes: > >> Dag-Erling Sm??rgrav <des@des.no> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100808130624.GB40928>