I should have said uint8_t * to uint32_t *. The problem is that that there is a lot of distance between where the conversion to uint8_t * happens and where the cast back to uint32_t * happens.
It is not obvious at all from the context that there is an alignment guarantee. Hence the simplest solution is to write a fn(the one that I wrote is correct), to handle unaligned uint32_t access. The version below yields decent code across architectures after Stefan showed that the mileage varies greatly with intrinsic memcpy(). #include <string.h> #include <stdint.h> uint32_t uint32_read_unaligned(const uint8_t *data) { uint32_t t; // Let's trust the compiler to do something very clever here. int i; for (i = 0; i < sizeof(t); i++) { ((uint8_t *)&t)[i] = data[i]; } return t; } -- Øyvind Harboe - Can Zylin Consulting help on your project? US toll free 1-866-980-3434 / International +47 51 87 40 27 http://www.zylin.com/ _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development