Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Jul 2004 12:47:43 -0700 (PDT)
From:      Julian Elischer <julian@elischer.org>
To:        Anil Madhavapeddy <anil@recoil.org>
Cc:        freebsd-net@lists.freebsd.org
Subject:   Re: Packing netgraph structs
Message-ID:  <Pine.BSF.4.21.0407011242510.91303-100000@InterJet.elischer.org>
In-Reply-To: <C98C976C-CB94-11D8-99F8-000A95DA50A6@recoil.org>

next in thread | previous in thread | raw e-mail | index | archive | help


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
> 
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0407011242510.91303-100000>