[plt-scheme] Re: large blocks inside cstructs

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Dec 18 00:38:37 EST 2006

On Dec 18, Dave Herman wrote:
> >> How should I do this?  Other than putting 260 / 4 dummy _int32 slots
> >> in a row, I mean. :)
> > 
> > There's no good solution for that, sorry.  One way would be to
> > generate dummy slots, which would be a hassle to generate, but will
> > allow you to address slots conveniently.  Another way is to just use
> > malloc directly, which is a different kind of a hassle.
> 
> Okay, well then I guess this is better than nothing:
> [...]
>    (define-inline-cstruct _ADAPTER_NAME _byte 260)
>    (define-inline-cstruct _ADAPTER_DESCRIPTION _byte 132)
>    (define-cstruct _IP_ADAPTER_INFO (...
>                                      [AdapterName _ADAPTER_NAME]
>                                      [Description _ADAPTER_DESCRIPTION]
>                                      ...))
> [...]

Yes, better than nothing, but not good.  I agree.


> A serious down-side is the enormous code-bloat from generating a
> separate field for every single byte in the array. :(

There's no way around that, given what libffi currently provides.


> I'm considering creating a small fixed prefix of the sequence of
> blocks of size 2^n bytes (say, from _byte up to _kilobyte) and use
> the largest chunks possible in the implementation of
> define-inline-cstruct.

I don't think that this will work right -- I think that the alignment
of these blocks will always be 4 bytes.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.