From owner-freebsd-net@FreeBSD.ORG Thu Jul 1 15:43:25 2004 Return-Path: Delivered-To: freebsd-net@www.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A373516A4CE for ; Thu, 1 Jul 2004 15:43:25 +0000 (GMT) Received: from n33.kp.t-systems-sfr.com (n33.kp.t-systems-sfr.com [129.247.16.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id CE74243D39 for ; Thu, 1 Jul 2004 15:43:24 +0000 (GMT) (envelope-from harti@freebsd.org) Received: from n81.sp.op.dlr.de (n81g.sp.op.dlr.de [129.247.163.1]) i61FgIj38436; Thu, 1 Jul 2004 17:42:18 +0200 Received: from zeus.nt.op.dlr.de (zeus.nt.op.dlr.de [129.247.173.3]) i61FgID142422; Thu, 1 Jul 2004 17:42:18 +0200 Received: from beagle.kn.op.dlr.de (opkndnwsbsd178 [129.247.173.178]) by zeus.nt.op.dlr.de (8.11.7+Sun/8.9.1) with ESMTP id i61FgHV15895; Thu, 1 Jul 2004 17:42:17 +0200 (MET DST) Date: Thu, 1 Jul 2004 18:59:13 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt@beagle.kn.op.dlr.de To: Anil Madhavapeddy In-Reply-To: <931572E3-CB5E-11D8-99F8-000A95DA50A6@recoil.org> Message-ID: <20040701185404.G81202@beagle.kn.op.dlr.de> References: <122AE07F-CB5B-11D8-99F8-000A95DA50A6@recoil.org> <40E40839.20500@cronyx.ru> <931572E3-CB5E-11D8-99F8-000A95DA50A6@recoil.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@www.freebsd.org cc: Roman Kurakin Subject: Re: Packing netgraph structs X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Harti Brandt List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2004 15:43:25 -0000 On Thu, 1 Jul 2004, Anil Madhavapeddy wrote: AM>On 1 Jul 2004, at 13:48, Roman Kurakin wrote: AM>> AM>> If this is a problem why can't you make some wrapper that will pack/unpack AM>> written on C, AM>> which will be a lib for you? AM> AM>Because I want to minimise the size of the foreign bindings - this would AM>require C code for every single Netgraph struct. If they were packed, I AM>could just do it all in OCaml. AM> AM>Isn't this a problem for other language bindings as well, or is everyone AM>doing Netgraph userland hacking in C at the moment? Packing structs is a evil thing to do because this requires non-standard compiler support. Traditionally this was done with carefully designing the struct and inserting explicit spare fields where the compiler would pad. Unfortunately with decreasing $/bit for memory this knowledge has been lost and in any case it helps only for a concrete compiler/platform combination. So why can't you just guess the padding and handle it explicitely? Have a look at ng_parse.c. harti