From owner-freebsd-net@FreeBSD.ORG Thu Jul 1 19:49: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 8A2E716A4CE for ; Thu, 1 Jul 2004 19:49:25 +0000 (GMT) Received: from mx2.freebsd.org (mx2.freebsd.org [216.136.204.119]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8135B43D2F for ; Thu, 1 Jul 2004 19:49:25 +0000 (GMT) (envelope-from julian@elischer.org) Received: from hub.freebsd.org (hub.freebsd.org [216.136.204.18]) by mx2.freebsd.org (Postfix) with ESMTP id 4D2E8565E0 for ; Thu, 1 Jul 2004 19:48:40 +0000 (GMT) (envelope-from julian@elischer.org) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 49EA016A4CF for ; Thu, 1 Jul 2004 19:48:40 +0000 (GMT) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id F16E743D5A for ; Thu, 1 Jul 2004 19:48:39 +0000 (GMT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([24.7.73.28]) by comcast.net (sccrmhc13) with ESMTP id <2004070119474601600k9tsre>; Thu, 1 Jul 2004 19:47:47 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id MAA93275; Thu, 1 Jul 2004 12:47:44 -0700 (PDT) Date: Thu, 1 Jul 2004 12:47:43 -0700 (PDT) From: Julian Elischer To: Anil Madhavapeddy In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-net@lists.freebsd.org Subject: Re: Packing netgraph structs X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list 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 19:49:25 -0000 On Thu, 1 Jul 2004, Anil Madhavapeddy wrote: > On 1 Jul 2004, at 18:20, Julian Elischer wrote: > > > > are syscall arguments packed? I know that they are defined rather > > strangely.. > > On OpenBSD at least, they are wrapped in unions to pad them to register > sizes. > > > > > what messages are you having troubles with? > > > > Usually, in my experience, 'packed' structures are limitted to > > structures that are defined in hardware, and message structures ae > > defined unpacked so that they can be efficiently passed around within a > > single system. > > Can you give me better examples.. > > I'm also a little worried about architectures that have certain > > allignment restrictions on data, which is why packed and unpacked > > structures are different in the first place. > > I'm just looking for a non-fragile way to create the structure > specified by Netgraph without actually using C. Of course, I can > create a whole bunch of C structs using the local compiler and mirror > OCaml functions, but it's an inelegant solution. > > As others have helpfully pointed out, the current struct has been > carefully designed to work well on existing architectures without the > compiler padding (in particular, it looks like it will work on ARM > which requires structs to be multiples of word size), and my initial > tests have worked fine on i386. Just wondering if others have come up > with a better solution than a large set of FFI bindings. I think that nearly all languages these day shave to take into account "what C does" and they need to have packing etc taken explicitly into account when they do syscalls etc. so I don't think that you will have too many problems and there should be some facility available to you to do the right packing if it's needed. The C packing is done to maximise the efficiency of the structure given that particular platform. I don't think that packing it would be useful as the messages are never supposed to leave the machine, and if we pack netgraph messages, then where do we stop? Should we pack all ioctl structures too? (sorry to make life more difficult for you but...) julian BTW what IS OCaml? I've seen it mentionned a few times now.. > > -- > Anil Madhavapeddy > http://anil.recoil.org > University of Cambridge > http://www.cl.cam.ac.uk > >