[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bluetooth-dev] Re: Porting to ARM



Jonas Wigstein[SMTP:jwn99008@xxxxxxx.se] wrote:
> 
> Hi all ARM porters !!!!
> 
> I'm just wondering if anyone has a nice solution on the struct overlay
> problem?
> We have developed a bluetooth stack for windows and used a struct overlay
> technique similar to axis.
> Now we deeply regrets this technique because of the porting difficulties
> we faces. 
> As we understands it the ARM processor cant fetch a word(2 byte) on an odd
> address and therefore the C-compiler inserts a space in our structs if it
> encounters a int_2 on a odd address and thereby destroying our nice
> structs.   
> 
> So does anyone know a C-compiler that can handle this on ARM or a nice way
> around the problem without a complete rewrite of the package processing?
> 
> // Jonas Wigstein
> 

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