Browse code

Use alias-safe types in AV_[RW] macros

Originally committed as revision 21878 to svn://svn.ffmpeg.org/ffmpeg/trunk

Måns Rullgård authored on 2010/02/18 22:40:21
Showing 1 changed files
... ...
@@ -177,12 +177,12 @@ typedef union {
177 177
 
178 178
 #if   HAVE_ATTRIBUTE_PACKED
179 179
 
180
-struct unaligned_64 { uint64_t l; } __attribute__((packed));
181
-struct unaligned_32 { uint32_t l; } __attribute__((packed));
182
-struct unaligned_16 { uint16_t l; } __attribute__((packed));
180
+union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
181
+union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
182
+union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
183 183
 
184
-#   define AV_RN(s, p) (((const struct unaligned_##s *) (p))->l)
185
-#   define AV_WN(s, p, v) ((((struct unaligned_##s *) (p))->l) = (v))
184
+#   define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
185
+#   define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
186 186
 
187 187
 #elif defined(__DECC)
188 188
 
... ...
@@ -191,8 +191,8 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
191 191
 
192 192
 #elif HAVE_FAST_UNALIGNED
193 193
 
194
-#   define AV_RN(s, p) (*((const uint##s##_t*)(p)))
195
-#   define AV_WN(s, p, v) (*((uint##s##_t*)(p)) = (v))
194
+#   define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
195
+#   define AV_WN(s, p, v) (((uint##s##_t*)(p))->u##s = (v))
196 196
 
197 197
 #else
198 198