Skip to content

Commit 26b6046

Browse files
pps83copybara-github
authored andcommitted
PR #1833: Make ABSL_INTERNAL_STEP_n macros consistent in crc code
Imported from GitHub PR #1833 `ABSL_INTERNAL_STEP1`, `ABSL_INTERNAL_STEP2`, `ABSL_INTERNAL_STEP4` assumed that `p` exists where these were used. All while similar macro `ABSL_INTERNAL_STEP8` correctly passed `p` as a macro arg. This PR updates all of them to take extra param instead of relying p's existence. Also, renamed `data` to `p` for `ABSL_INTERNAL_STEP8` to be consistent with others Merge 9a89bb0 into e3183f1 Merging this change closes #1833 COPYBARA_INTEGRATE_REVIEW=#1833 from pps83:master-macrofix 9a89bb0 PiperOrigin-RevId: 728751982 Change-Id: I48c3635f8d22848115744f6e9869717136385154
1 parent 767f7a1 commit 26b6046

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

absl/crc/internal/crc_x86_arm_combined.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,27 @@ class CRC32AcceleratedX86ARMCombined : public CRC32 {
6464
constexpr size_t kSmallCutoff = 256;
6565
constexpr size_t kMediumCutoff = 2048;
6666

67-
#define ABSL_INTERNAL_STEP1(crc) \
67+
#define ABSL_INTERNAL_STEP1(crc, p) \
6868
do { \
6969
crc = CRC32_u8(static_cast<uint32_t>(crc), *p++); \
7070
} while (0)
71-
#define ABSL_INTERNAL_STEP2(crc) \
71+
#define ABSL_INTERNAL_STEP2(crc, p) \
7272
do { \
7373
crc = \
7474
CRC32_u16(static_cast<uint32_t>(crc), absl::little_endian::Load16(p)); \
7575
p += 2; \
7676
} while (0)
77-
#define ABSL_INTERNAL_STEP4(crc) \
77+
#define ABSL_INTERNAL_STEP4(crc, p) \
7878
do { \
7979
crc = \
8080
CRC32_u32(static_cast<uint32_t>(crc), absl::little_endian::Load32(p)); \
8181
p += 4; \
8282
} while (0)
83-
#define ABSL_INTERNAL_STEP8(crc, data) \
84-
do { \
85-
crc = CRC32_u64(static_cast<uint32_t>(crc), \
86-
absl::little_endian::Load64(data)); \
87-
data += 8; \
83+
#define ABSL_INTERNAL_STEP8(crc, p) \
84+
do { \
85+
crc = \
86+
CRC32_u64(static_cast<uint32_t>(crc), absl::little_endian::Load64(p)); \
87+
p += 8; \
8888
} while (0)
8989
#define ABSL_INTERNAL_STEP8BY2(crc0, crc1, p0, p1) \
9090
do { \
@@ -384,15 +384,15 @@ class CRC32AcceleratedX86ARMCombinedMultipleStreams
384384
length &= ~size_t{8};
385385
}
386386
if (length & 4) {
387-
ABSL_INTERNAL_STEP4(l);
387+
ABSL_INTERNAL_STEP4(l, p);
388388
length &= ~size_t{4};
389389
}
390390
if (length & 2) {
391-
ABSL_INTERNAL_STEP2(l);
391+
ABSL_INTERNAL_STEP2(l, p);
392392
length &= ~size_t{2};
393393
}
394394
if (length & 1) {
395-
ABSL_INTERNAL_STEP1(l);
395+
ABSL_INTERNAL_STEP1(l, p);
396396
length &= ~size_t{1};
397397
}
398398
if (length == 0) {
@@ -478,7 +478,7 @@ class CRC32AcceleratedX86ARMCombinedMultipleStreams
478478
const uint8_t* x = RoundUp<8>(p);
479479
// Process bytes until p is 8-byte aligned, if that isn't past the end.
480480
while (p != x) {
481-
ABSL_INTERNAL_STEP1(l);
481+
ABSL_INTERNAL_STEP1(l, p);
482482
}
483483

484484
size_t bs = static_cast<size_t>(e - p) /
@@ -597,7 +597,7 @@ class CRC32AcceleratedX86ARMCombinedMultipleStreams
597597
}
598598
// Process the last few bytes
599599
while (p != e) {
600-
ABSL_INTERNAL_STEP1(l);
600+
ABSL_INTERNAL_STEP1(l, p);
601601
}
602602

603603
#undef ABSL_INTERNAL_STEP8BY3

0 commit comments

Comments
 (0)