Selaa lähdekoodia

leveldb: Fix alignment code in SSE4.2-optimized CRC32C.

When faced with a pointer that is misaligned by K bytes (pointer % 8 ==
K), the code previously moved forward by K bytes. In order to end up
with an aligned pointer, the code must move by 8 - K bytes.

This lands https://github.com/google/leveldb/pull/488

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166295921
main
costan 7 vuotta sitten
committed by Victor Costan
vanhempi
commit
2964b803b8
1 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  1. +6
    -2
      port/port_posix_sse.cc

+ 6
- 2
port/port_posix_sse.cc Näytä tiedosto

@ -92,8 +92,12 @@ uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size) {
} while (0) } while (0)
if (size > 16) { if (size > 16) {
// Process unaligned bytes
for (unsigned int i = reinterpret_cast<uintptr_t>(p) % 8; i; --i) {
// Point x at first 8-byte aligned byte in string. This must be inside the
// string, due to the size check above.
const uintptr_t pval = reinterpret_cast<uintptr_t>(p);
const uint8_t* x = reinterpret_cast<const uint8_t*>(((pval + 7) >> 3) << 3);
// Process bytes until p is 8-byte aligned.
while (p != x) {
STEP1; STEP1;
} }

Ladataan…
Peruuta
Tallenna