This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Network programming for eCos under linux
> I'm not sure this is a compiler bug - I would suspect the linux compiler
> can't access non-aligned memory either, but at a guess the kernel catches
> the exception and emulates it for you. If that is the case, it's best
> avoided as performance would suck.
I don't remeber the exact details. The code was something like...
static int
func(char * msg, char * name ; short rr_type) {
char *ptr;
int len;
strcpy(msg,name);
ptr = msg + strlen(name);
*ptr++ = ((char *)&rr_type)[0];
*ptr++ = ((char *)&rr_type)[1];
len = ptr - msg;
return len;
}
Maybe i don't have the casts correct. Anyway, i found the ptr was not
being incremented when ptr was not word aligned before the first
*ptr++ operation. This could happen because name can be any length. It
worked fine on i386, but not on arm-elf. To me, this is a compile
bug. I got around it by using shifts and ands instead of casts and
array access.
Andrew