On Sat, Apr 29, 2006 at 05:45:44PM -0500, John Donaghy wrote:
+#if defined(ARCH_X86) || defined(ARCH_X86_64) +# define unaligned32(a) (*(const uint32_t*)(a)) +#else +# ifdef __GNUC__ +static inline uint32_t unaligned32(const void *v) { + struct Unaligned { + uint32_t i; + } __attribute__((packed)); + + return ((const struct Unaligned *) v)->i; +} +# elif defined(__DECC) +static inline uint32_t unaligned32(const void *v) { + return *(const __unaligned uint32_t *) v; +} +# else +static inline uint32_t unaligned32(const void *v) { + return *(const uint32_t *) v; +} +# endif +#endif //!ARCH_X86 +
Ugh. Scary. Why can't you use the LOAD_LE32 macros? Or alternatively make similar LOAD_BE32 macros? This at least looks like both a portability and maintainability macros - at best acceptable in highly performance-critical code (if it makes a performance difference at all).
I've replaced this in the attached version with a LOAD_BE32 macro which I think is what you're suggesting but I'm not sure. It appears to work on x86 but I'm not very knowlegable in this area. Can you review and let me know if this is a correct and acceptable approach.
Reimar, are you OK with the patch now? I can confirm that it works on PPC. It would be nice to have this in pre8. Diego