From owner-freebsd-arch@FreeBSD.ORG Sun Jan 16 00:12:46 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0FF7106566B for ; Sun, 16 Jan 2011 00:12:46 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 8CB908FC13 for ; Sun, 16 Jan 2011 00:12:46 +0000 (UTC) Received: by iwn39 with SMTP id 39so3624873iwn.13 for ; Sat, 15 Jan 2011 16:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:date:x-google-sender-auth :message-id:subject:from:to:content-type; bh=oVL5OOIXiSM6OTJkE1+U0j7omGPBHAKlwPIFOa3UTeQ=; b=dOCsCwtu4cGa4gBwR5TTuHvgJqZqa3c2vMuObrGLk43jBZnWsVGVFL2tRpQFSDnZRI on+c8elM/M03ydYAMVY8EGHHgXGeqx8YP81obd4oiw1wEoU6OjH/701ZjKLQpXwmJw2P Z2kq7DEA1qBNlx48xsfJy5Le4+x4xaDhgGsr8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=slh0Bf8d579z5uph/RSLRawe7ACipQXH8OxG5lNkrwKenTZF4hBi21UT0TFlwF5u7s oX2hwWZ5jplQinBoa1mIvKP3LRUm7+Cdvdect5GhNVLfwfPzoMB6KcsVEV+nC7tNHvmj s/ucOXunikJ2+ulpWMST+Rw+yhnoHd5sZWjME= MIME-Version: 1.0 Received: by 10.231.35.141 with SMTP id p13mr2430037ibd.79.1295136765957; Sat, 15 Jan 2011 16:12:45 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.231.160.147 with HTTP; Sat, 15 Jan 2011 16:12:45 -0800 (PST) Date: Sat, 15 Jan 2011 16:12:45 -0800 X-Google-Sender-Auth: QkULITlZ2OZ2JPqRN1AYFQYNAsk Message-ID: From: mdf@FreeBSD.org To: FreeBSD Arch Content-Type: text/plain; charset=ISO-8859-1 Subject: Automagic SYSCTLs X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Jan 2011 00:12:46 -0000 I started out with a plan to import a patch from Isilon that adds type-safety to the existing SYSCTLs for scalar variables in the kernel. After the discussion on the svn mailing list here (http://lists.freebsd.org/pipermail/svn-src-head/2011-January/024097.html) I now have a prototype patch for SYSCTL_ADD_SCALAR that could replace most uses of SYSCTL_ADD_{INT, UINT, LONG, ULONG, QUAD} and is suitable for the SYSCTL_ADD_FOO that are used on 16 and 8 bit members (without type checking) today. The gist is that the handler knows the sizeof the variable in the kernel and uses this to copy out. For the case of a long, there's some goop for SCTL_MASK32. For the case of 8 and 16 bit variables, they are still copied in and out as 32-bit quantities. Let me know if this seems like the right or wrong direction in which to move. I haven't tackled the static sysctls as the code I have does some run-time evaluation because the code is easier to write that way. One possibility is to change the sysctl_oid struct or at least add a SIGNED flag; this would also have the advantage of making it possible to clean up the CTLTYPE_[U]INT issue where there is no real difference between the two CTLTYPEs. http://people.freebsd.org/~mdf/bsd-sysctl-scalar.diff Thanks, matthew