From owner-freebsd-current@FreeBSD.ORG Mon Dec 2 07:10:19 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D5DC47E1; Mon, 2 Dec 2013 07:10:19 +0000 (UTC) Received: from CMEXEDGE2.ext.emulex.com (cmexedge2.ext.emulex.com [138.239.224.100]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B35D31707; Mon, 2 Dec 2013 07:10:19 +0000 (UTC) Received: from CMEXHTCAS2.ad.emulex.com (138.239.115.218) by CMEXEDGE2.ext.emulex.com (138.239.224.100) with Microsoft SMTP Server (TLS) id 14.3.146.0; Sun, 1 Dec 2013 23:10:21 -0800 Received: from CMEXMB1.ad.emulex.com ([169.254.1.137]) by CMEXHTCAS2.ad.emulex.com ([2002:8aef:73da::8aef:73da]) with mapi id 14.03.0146.002; Sun, 1 Dec 2013 23:10:11 -0800 From: Venkata Duvvuru To: John-Mark Gurney Subject: RE: sysctl add macros Thread-Topic: sysctl add macros Thread-Index: Ac7py2Eb3GYul2HXQGupi09t7TvnXQAZRFYAABCOHkAA+O5hAAA1n36w Date: Mon, 2 Dec 2013 07:10:11 +0000 Message-ID: References: <20131130213006.GC55638@funkthat.com> In-Reply-To: <20131130213006.GC55638@funkthat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [138.239.141.136] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: Matthew Fleming , "freebsd-current@freebsd.org" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Dec 2013 07:10:19 -0000 I could use an int variable but if I have to dump huge number of statistics= through sysctl in which case I need to add many such variables to the node= s and even if most of these variables are char I have to declare them as in= t, hence resulting in an increased footprint. /Venkat. -----Original Message----- From: John-Mark Gurney [mailto:jmg@funkthat.com]=20 Sent: Sunday, December 01, 2013 3:00 AM To: Venkata Duvvuru Cc: Matthew Fleming; freebsd-current@freebsd.org Subject: Re: sysctl add macros Venkata Duvvuru wrote this message on Mon, Nov 25, 2013 at 14:58 +0000: > The problem with using int or u_int for 1 or 2 byte values is that while = printing these 1 or 2 byte values I observed that sysctl module is consider= ing 4 bytes. Hence I see an undesired output. It is actually considering th= e next two bytes also as the value. If you _NEED_ to use a char or short, you need to write your own/clone it f= rom the macros... Why can't you use an int for this variable? > From: mdf356@gmail.com [mailto:mdf356@gmail.com] On Behalf Of Matthew=20 > Fleming > Sent: Monday, November 25, 2013 8:18 PM > To: Venkata Duvvuru > Cc: freebsd-current@freebsd.org > Subject: Re: sysctl add macros >=20 > On Mon, Nov 25, 2013 at 3:35 AM, Venkata Duvvuru > wrote: > Hi, > I'm unable to figure out how to add an unsigned short or an unsigned char= values to a sysctl node. > SYSCTL_ADD_INT, SYSCTL_ADD_UINT, etc., are present but to add a char or a= short values I couldn't find any macros. >=20 > Could you please let me know how to add them? >=20 > FreeBSD does not have any sysctl handlers for 1 or 2 byte values. FreeBS= D code that wants to do this has used int or u_int instead of a smaller typ= e. --=20 John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."