Hello Jani,
could you please test run the program below to see how the nested
struct is aligned under arm-gcc?
Actually, I think you are on to something here... Someone said that
gcc for arm puts all structs on 4 byte boundarys in order to use the
efficient load and store multiple instructions... I have not
considered this. It would surely break the etharp struct.
This piece of code should show the actual alignments under GCC when
using nested structs.
#include <stdio.h>
#include <stddef.h>
#if 1
#define PACKED __attribute__ ((packed))
#else
#define PACKED
#endif
struct A {
u16_t x[2];
} PACKED;
struct B {
u16_t p;
struct A q;
u16_t r;
} PACKED;
int main ()
{
printf ("offsetof(p) = %d\n", offsetof(p));
printf ("offsetof(q.x[0]) = %d\n", offsetof(q.x[0]));
printf ("offsetof(q.x[1]) = %d\n", offsetof(q.x[1]));
printf ("offsetof(r) = %d\n", offsetof(r));
printf ("sizeof(struct B) = %d\n", sizeof(struct B));
return 0;
}
/*
Hopefully:
offsetof(p) is 0
offsetof(q.x[0]) is 2
offsetof(q.x[1]) is 4
offsetof(r) is 6
sizeof(struct B) is 8
*/
Thanks, Leon.
_______________________________________________
lwip-users mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/lwip-users