Bill Auerbach escreveu:
What about macros to make it portable and universal?
Then we can make macros to be that and optimyzed. There could be a file
of such macros for a few architectures. Let me try an example por ARM
which is intereting because it is 32 bit and does not have byte access:
struct dns_answer {
/* DNS answer record starts with either a domain name or a pointer
to a name already present somewhere in the packet. */
u16_t type;
u16_t class;
u32_t ttl;
u16_t len;
} PACK_STRUCT_STRUCT;
// Create a buffer allways alligned
#define DNS_ANSWER_BUFF(buf) u32_d buf[3]
// Move from buffer to struct
#define DNS_ANSWER_FROM_BUF(buf,str) \
{ \
long t=buf[0]; \
str.type = t & 0xffff; \
str.class = t >>16; \
str.ttl = buf[1]; \
str.len = buf[2] & 0xffff; \
}
// move from struct to buff
#define DNS_ANSWER_TO_BUFF(buf,str) \
{ \
buf[0]=str.class<<16 | str.type; \
buf[1]=str.ttl; \
buf[2]=str.len; \
}
There are only a finite number of such macros... and maybe a serie for
8, 16 and 32 bits will do :)
Alain
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users