Browse Source

libavutil: Use an intermediate variable in AV_COPY*U

If AV_RN and AV_WN are macros with multiple individual reads and
writes, the previous version of the AV_COPYU macro would fail if
the reads and writes overlap.

This should not be any less efficient in any case, given a
sensibly optimizing compiler.

Signed-off-by: Martin Storsjö <martin@martin.st>
tags/n3.3
Martin Storsjö 8 years ago
parent
commit
014773b66b
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      libavutil/intreadwrite.h

+ 5
- 1
libavutil/intreadwrite.h View File

@@ -467,7 +467,11 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
* memory locations.
*/

#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
#define AV_COPYU(n, d, s) \
do { \
uint##n##_t val = AV_RN##n(s); \
AV_WN##n(d, val); \
} while (0)

#ifndef AV_COPY16U
# define AV_COPY16U(d, s) AV_COPYU(16, d, s)


Loading…
Cancel
Save