tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Lua in-kernel (lbuf library)
On Wed, Oct 16, 2013 at 7:56 AM, Alan Barrett <apb%cequrux.com@localhost> wrote:
> On Tue, 15 Oct 2013, Lourival Vieira Neto wrote:
>>>
>>> In order to indicate that endianness conversion is necessary I need to
>>> know the future uses of the buffer. Clairvoyance excepted, that is kinda
>>> hard.
>>
>>
>> It's a generic data structure that could be used to handle bit fields
>> or nonaligned data.
>
>
> Endianness should be a property of a field in a data structure, not a
> property of the entire data structure. There might be a mixture of big- and
> little-endian fields of different sizes in the same data structure. It
> seemed to me from a superficial reading that the proposed endianness flag in
> the Lua "buf" interface would not handle that.
>
> --apb (Alan Barrett)
I thought to use an optional parameter in mask fields to allow local
decision. Thus, you could have a global behavior defined in the lbuf
userdatum creation and a per field behavior defined in the mask field.
For example:
lbuf.mask{ field = { offset, length, net }, ... }
Also, I was thinking about have a signedness flag (both global, in
buffer creation, and local, in mask field).
Other syntax that I'm considering is to also have named parameters
(optionally) in mask declaration:
lbuf.mask{ field = { __offset = offset, __length = length, __net =
net, __signed = signed }, ... }
Regards,
--
Lourival Vieira Neto
Home |
Main Index |
Thread Index |
Old Index