On Dec 11, 2007 6:38 PM, Ivan Vucica <[EMAIL PROTECTED]> wrote: > On Dec 11, 2007 4:28 PM, Nuno Lucas <[EMAIL PROTECTED]> wrote: > > > > > > Allocated memory should always come aligned. That's not the problem. > > I would guess the problem is the array base address in the stack (on > > IA32 the stack is always aligned by 32 bits, but that can not be true > > on other platforms). > > > > You have 3 options: > > > > 1) Use an union - it can not be adequate to the code in question; > > 2) Use memcpy() - assures success even on un-aligned memory; > > 3) Some other algorithm that access the pointed data in an adequate > > way (like the memcpy byte access). > > > > Regards, > > ~Nuno Lucas > > > > P.S.- Only now noticed I wasn't replying to the mailing list. One of > > those gmail things. > > > > I've added the mailing list to CC, since your reply might be helpful to > someone. > > In the meantime I thought; something tells me that it should be > possible to make this kind of access "safe" using some GCC option? It > should mean adding a few assembler instructions before such an access, > for example: > > (more code) > (more code) > > AND r1, 3 > JPZ skip_fixstuff > CALL fixstuff > skip_fixstuff: > > LDR r1, r2 > (more code) > (more code) > > (alert: quasi assembler written by a n00b) > > With the option I'm taking about turned on, those three instructions > and the label are inserted, otherwise they do not exist. R1 > theoretically contains the address of data to access. > > Does such option or its equivalent exist?
http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attributes Don't know how I forgot to include that option, sorry. Probably too focused on portable code. Regards, ~Nuno Lucas > -- > Ivan Vučica > > -- Croatia -- > ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Cegcc-devel mailing list Cegcc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cegcc-devel