From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn To: Jonathan Larmour Cc: Andrew Lunn , "Trenton D. Adams" , "'eCos Discussion'" Subject: Re: [ECOS] Network programming for eCos under linux Date: Wed, 08 Aug 2001 06:51:00 -0000 Message-id: <20010808155117.E3658@biferten.ma.tech.ascom.ch> References: <019301c11f92$0aad4b60$090110ac@TRENT> <20010808093506.B3658@biferten.ma.tech.ascom.ch> <3B713E35.B7C21FA@redhat.com> X-SW-Source: 2001-08/msg00221.html > 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