Skip to content

Commit

Permalink
Fix compilation for older GCC and Clang versions.
Browse files Browse the repository at this point in the history
Not everything defining __GNUC__ supports flag outputs
from asm statements; in particular, some Clang versions
on macOS does not. The correct test per the GCC documentation
is __GCC_ASM_FLAG_OUTPUTS__, so use that instead.

PiperOrigin-RevId: 423749308
  • Loading branch information
Snappy Team authored and pwnall committed Feb 20, 2022
1 parent 8b07ff1 commit 8dd58a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion snappy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ size_t AdvanceToNextTagX86Optimized(const uint8_t** ip_p, size_t* tag) {
size_t literal_len = *tag >> 2;
size_t tag_type = *tag;
bool is_literal;
#if defined(__GNUC__) && defined(__x86_64__)
#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__)
// TODO clang misses the fact that the (c & 3) already correctly
// sets the zero flag.
asm("and $3, %k[tag_type]\n\t"
Expand Down

0 comments on commit 8dd58a5

Please sign in to comment.