[FFmpeg-devel] [PATCH 4/7] Use alias-safe types in AV_[RW] macros
Mans Rullgard
mans
Fri Jan 29 03:12:11 CET 2010
---
libavutil/intreadwrite.h | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
index 8a4ef72..904ac3f 100644
--- a/libavutil/intreadwrite.h
+++ b/libavutil/intreadwrite.h
@@ -173,12 +173,12 @@ typedef union {
#if HAVE_ATTRIBUTE_PACKED
-struct unaligned_64 { uint64_t l; } __attribute__((packed));
-struct unaligned_32 { uint32_t l; } __attribute__((packed));
-struct unaligned_16 { uint16_t l; } __attribute__((packed));
+union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
+union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
+union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
-# define AV_RN(s, p) (((const struct unaligned_##s *) (p))->l)
-# define AV_WN(s, p, v) ((((struct unaligned_##s *) (p))->l) = (v))
+# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
+# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
#elif defined(__DECC)
@@ -187,8 +187,8 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
#elif HAVE_FAST_UNALIGNED
-# define AV_RN(s, p) (*((const uint##s##_t*)(p)))
-# define AV_WN(s, p, v) (*((uint##s##_t*)(p)) = (v))
+# define AV_RN(s, p) (((const ff_alias##s*)(p))->u##s)
+# define AV_WN(s, p, v) (((uint##s##_t*)(p))->u##s = (v))
#else
--
1.6.6.1
More information about the ffmpeg-devel
mailing list