From owner-freebsd-current@FreeBSD.ORG Mon Dec 2 07:14:39 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1BEC692D; Mon, 2 Dec 2013 07:14:39 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E7448173B; Mon, 2 Dec 2013 07:14:38 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id rB27EaQI096116 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 1 Dec 2013 23:14:36 -0800 (PST) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id rB27Eais096115; Sun, 1 Dec 2013 23:14:36 -0800 (PST) (envelope-from jmg) Date: Sun, 1 Dec 2013 23:14:36 -0800 From: John-Mark Gurney To: Venkata Duvvuru Subject: Re: sysctl add macros Message-ID: <20131202071436.GI55638@funkthat.com> Mail-Followup-To: Venkata Duvvuru , Matthew Fleming , "freebsd-current@freebsd.org" References: <20131130213006.GC55638@funkthat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Sun, 01 Dec 2013 23:14:36 -0800 (PST) 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:14:39 -0000 Venkata Duvvuru wrote this message on Mon, Dec 02, 2013 at 07:10 +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 nodes and even if most of these variables are char I have to declare them as int, hence resulting in an increased footprint. If it's a few 10s of vars, then it isn't a big deal, but if it is 1000's, then you might want to look at another method to extract the data since the overhead of sysctl is expensive... Something like writing a _PROC routine that will copy them all out in a single sysctl call.. > -----Original Message----- > From: John-Mark Gurney [mailto:jmg@funkthat.com] > 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 considering 4 bytes. Hence I see an undesired output. It is actually considering the next two bytes also as the value. > > If you _NEED_ to use a char or short, you need to write your own/clone it from the macros... > > Why can't you use an int for this variable? > > > From: mdf356@gmail.com [mailto:mdf356@gmail.com] On Behalf Of Matthew > > Fleming > > Sent: Monday, November 25, 2013 8:18 PM > > To: Venkata Duvvuru > > Cc: freebsd-current@freebsd.org > > Subject: Re: sysctl add macros > > > > 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. > > > > Could you please let me know how to add them? > > > > FreeBSD does not have any sysctl handlers for 1 or 2 byte values. FreeBSD code that wants to do this has used int or u_int instead of a smaller type. > > -- > John-Mark Gurney Voice: +1 415 225 5579 > > "All that I will do, has been done, All that I have, has not." > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."