On Wed, May 27, 2009 at 9:20 AM, Nathan Wharton naw@greptar.com wrote:
On Tue, May 26, 2009 at 5:13 PM, Sven Eckelmann sven.eckelmann@gmx.de wrote:
========================================= #include <stdio.h> #include <stdlib.h>
#define x_moved(pos) ((int*)&x[pos])[0] static const int value1 = 0x01234567; static const int value2 = 0x89abcdef;
int main() { volatile char *x = (char*)malloc(sizeof(int) * 2); x_moved(0) = value1; x_moved(2) = value2;
if (x_moved(2) != value2) { printf("ERROR Value: "); } else { printf("Value: "); } printf("%x %x\n", x_moved(0) , x_moved(2));
free(x); return 0; } =========================================
This results in: ERROR Value: 89abcdef cdef89ab
Some good info is here: http://lecs.cs.ucla.edu/wiki/index.php/XScale_alignment