mirror of
https://github.com/google/brotli.git
synced 2024-11-22 19:50:06 +00:00
Make memmove16 safe.
This commit is contained in:
parent
058d7498a1
commit
02c606d444
16
dec/decode.c
16
dec/decode.c
@ -129,22 +129,12 @@ static uint32_t DecodeWindowBits(BrotliBitReader* br) {
|
||||
|
||||
static BROTLI_INLINE BROTLI_NO_ASAN void memmove16(
|
||||
uint8_t* dst, uint8_t* src) {
|
||||
#if BROTLI_SAFE_MEMMOVE
|
||||
/* For x86 this compiles to the same binary as signle memcpy.
|
||||
On ARM memcpy is not inlined, so it works slower.
|
||||
This implementation makes decompression 1% slower than regular one,
|
||||
and 2% slower than NEON implementation.
|
||||
*/
|
||||
#if defined(__ARM_NEON__)
|
||||
vst1q_u8(dst, vld1q_u8(src));
|
||||
#else
|
||||
uint32_t buffer[4];
|
||||
memcpy(buffer, src, 16);
|
||||
memcpy(dst, buffer, 16);
|
||||
#elif defined(__ARM_NEON__)
|
||||
vst1q_u8(dst, vld1q_u8(src));
|
||||
#else
|
||||
/* memcpy is unsafe for overlapping regions and ASAN detects this.
|
||||
But, because of optimizations, it works exactly as memmove:
|
||||
copies data to registers first, and then stores them to dst. */
|
||||
memcpy(dst, src, 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user