[FFmpeg-devel] [PATCH 5/7] Use alias-safe types in AV_COPY/SWAP/ZERO macros

Mans Rullgard mans
Fri Jan 29 03:12:12 CET 2010


---
 libavutil/intreadwrite.h |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
index 904ac3f..70b3d28 100644
--- a/libavutil/intreadwrite.h
+++ b/libavutil/intreadwrite.h
@@ -424,7 +424,8 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
  * afterwards.
  */
 
-#define AV_COPY(n, d, s) (*(uint##n##_t*)(d) = *(const uint##n##_t*)(s))
+#define AV_COPY(n, d, s) \
+    (((ff_alias##n*)(d))->u##n = ((const ff_alias##n*)(s))->u##n)
 
 #ifndef AV_COPY64
 #   define AV_COPY64(d, s) AV_COPY(64, d, s)
@@ -438,13 +439,17 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
     } while(0)
 #endif
 
-#define AV_SWAP(n, a, b) FFSWAP(uint##n##_t, *(uint##n##_t*)(a), *(uint##n##_t*)(b))
+#define AV_SWAP(n, a, b) FFSWAP(ff_alias##n, *(ff_alias##n*)(a), *(ff_alias##n*)(b))
 
 #ifndef AV_SWAP64
 #   define AV_SWAP64(a, b) AV_SWAP(64, a, b)
 #endif
 
-#define AV_ZERO(n, d) (*(uint##n##_t*)(d) = 0)
+#define AV_ZERO(n, d) (((ff_alias##n*)(d))->u##n = 0)
+
+#ifndef AV_ZERO32
+#   define AV_ZERO32(d) AV_ZERO(32, d)
+#endif
 
 #ifndef AV_ZERO64
 #   define AV_ZERO64(d) AV_ZERO(64, d)
-- 
1.6.6.1




More information about the ffmpeg-devel mailing list