Browse code

Use alias-safe types in AV_COPY/SWAP/ZERO macros

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

Måns Rullgård authored on 2010/02/18 22:40:24
Showing 1 changed files
... ...
@@ -428,7 +428,8 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
428 428
  * afterwards.
429 429
  */
430 430
 
431
-#define AV_COPY(n, d, s) (*(uint##n##_t*)(d) = *(const uint##n##_t*)(s))
431
+#define AV_COPY(n, d, s) \
432
+    (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
432 433
 
433 434
 #ifndef AV_COPY32
434 435
 #   define AV_COPY32(d, s) AV_COPY(32, d, s)
... ...
@@ -446,13 +447,17 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
446 446
     } while(0)
447 447
 #endif
448 448
 
449
-#define AV_SWAP(n, a, b) FFSWAP(uint##n##_t, *(uint##n##_t*)(a), *(uint##n##_t*)(b))
449
+#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
450 450
 
451 451
 #ifndef AV_SWAP64
452 452
 #   define AV_SWAP64(a, b) AV_SWAP(64, a, b)
453 453
 #endif
454 454
 
455
-#define AV_ZERO(n, d) (*(uint##n##_t*)(d) = 0)
455
+#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
456
+
457
+#ifndef AV_ZERO32
458
+#   define AV_ZERO32(d) AV_ZERO(32, d)
459
+#endif
456 460
 
457 461
 #ifndef AV_ZERO64
458 462
 #   define AV_ZERO64(d) AV_ZERO(64, d)