#include <assert.h>
#include <limits.h>
-/* Unions for type-punning without aliasing violations.
+/* Unions for type-punning.
* Mn: load or store n bits, aligned, native-endian
* CPn: copy n bits, aligned, native-endian
* we don't use memcpy for CPn because memcpy's args aren't assumed to be aligned */
-typedef union { uint16_t i; uint8_t c[2]; } x264_union16_t;
-typedef union { uint32_t i; uint16_t b[2]; uint8_t c[4]; } x264_union32_t;
-typedef union { uint64_t i; uint32_t a[2]; uint16_t b[4]; uint8_t c[8]; } x264_union64_t;
+typedef union { uint16_t i; uint8_t c[2]; } MAY_ALIAS x264_union16_t;
+typedef union { uint32_t i; uint16_t b[2]; uint8_t c[4]; } MAY_ALIAS x264_union32_t;
+typedef union { uint64_t i; uint32_t a[2]; uint16_t b[4]; uint8_t c[8]; } MAY_ALIAS x264_union64_t;
#define M16(src) (((x264_union16_t*)(src))->i)
#define M32(src) (((x264_union32_t*)(src))->i)
#define M64(src) (((x264_union64_t*)(src))->i)
#define UNUSED __attribute__((unused))
#define ALWAYS_INLINE __attribute__((always_inline)) inline
#define NOINLINE __attribute__((noinline))
+#define MAY_ALIAS __attribute__((may_alias))
#define x264_constant_p(x) __builtin_constant_p(x)
#else
#define UNUSED
#define ALWAYS_INLINE inline
#define NOINLINE
+#define MAY_ALIAS
#define x264_constant_p(x) 0
#endif
if( strncmp( header, Y4M_FRAME_MAGIC, slen ) )
{
fprintf( stderr, "Bad header magic (%"PRIx32" <=> %s)\n",
- *((uint32_t*)header), header );
+ M32(header), header );
return -1;
}