[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bluetooth-dev] Re: Porting to ARM
Gordon McNutt[SMTP:email@example.com] wrote:
> Erwin Authried wrote:
> > I think a clean solution that solves the alignment- as well as
> > the endianness problems is a rewrite that uses macros similar to the
> > samba implementation:
> > * instead of structures, make #defines of the byte offsets:
> > #define xy 27
> > #define ...
> > * use macros to set/read values:
> > SSVAL(buffer,xy,value) instead of buffer->xy=value
> > and ... = SVAL(buffer,xy)
> > There are a lot of changes necessary, but that's propably unavoidable for
> > a really portable solution.
> > Regards,
> > Erwin
> I've already started rewriting so that I can port the stack to a big-endian
> processor. Anybody else interested in helping out?
That's fine. I'm afraid I can't help much at the moment, but I'd like to make a
proposal for a consistent rewrite:
Macros to read 16/32 bit words from a buffer.
The buffer's value is in little-endian format (le). u=unsigned,s=signed
Macros for writing into the buffer:
and the same game with *_be_*, if necessary, for conversion from/to big-endian buffer values.
The offsets can be defined as <struct-name>_<member>, and the struct typedefs can be discarded. e.g.:
The member "magic" in "bt_tx_buf" is defined as:
#define bt_tx_buf_magic 0
I think that this naming convention is easier to remember than that used in samba, what do you think?