From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 12 12:25:42 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 8A3D31065695; Thu, 12 Aug 2010 12:25:42 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 41E0B8FC1C; Thu, 12 Aug 2010 12:25:42 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 334C61FFC33; Thu, 12 Aug 2010 12:25:41 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 0120B8454D; Thu, 12 Aug 2010 14:25:40 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Garrett Cooper References: <86fwyq8rsc.fsf@ds4.des.no> <86d3tujh72.fsf@ds4.des.no> <864of680wv.fsf@ds4.des.no> <8662zkurx9.fsf@ds4.des.no> Date: Thu, 12 Aug 2010 14:25:40 +0200 In-Reply-To: (Garrett Cooper's message of "Thu, 12 Aug 2010 01:08:48 -0700") Message-ID: <8662zg586z.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org, Ivan Voras 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: Thu, 12 Aug 2010 12:25:42 -0000 Garrett Cooper writes: > Dag-Erling Sm=C3=B8rgrav writes: > > It might be a good idea to introduce TUNABLE_POINTER and TUNABLE_SIZE. > I would actually argue against doing that because it would only create > divergence between sysctl and tunable KPIs... Not if we also introduce corresponding SYSCTLs. Note that my idea is to have these as aliases for the correct primitive types. > (BTW, when you say TUNABLE_SIZE, I assume it would be a size_t quantity?) Yes. > Something might need to be done to the values returned by the tunables > though, because they don't respect boundaries, and can overflow right > now (which exacerbates the issue with values crammed into smaller > datatypes)... Yes. How about this: - rename getenv_quad() to getenv_signed() and getenv_unsigned() - add min / max arguments - implement getenv_quad() (and all the others) in terms of getenv_number() e.g.=20 int getenv_uint(const char *name, unsigned int *data) { unsigned long long tmp; int rval; if ((rval =3D getenv_unsigned(name, &tmp, 0, UINT_MAX)) =3D=3D 0) *data =3D (unsigned int)tmp; return (rval); } (note that due to the min / max arguments, the complexity of handling both signed and unsigned values in the same function probably exceeds the complexity of having two very similar functions) DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no