Skip to content

Commit c5055c0

Browse files
authored
Fix error: use of undeclared identifier 'ABSL_INTERNAL_ASSUME' (#238)
`ABSL_INTERNAL_ASSUME` was replaced by `ABSL_ASSUME` in abseil/abseil-cpp@231c393. Define `S2_ASSUME` to either `ABSL_ASSUME` or `ABSL_INTERNAL_ASSUME`, depending on what's available. The latest LTS release does not yet have `S2_ASSUME`. Fixes #237
1 parent f3ed5e0 commit c5055c0

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
Dan Larkin-York <dan@arangodb.com>
1212
Google Inc.
1313
Koordinates Limited
14+
Tiago Brito <tiago.brito@90poe.io>

CONTRIBUTORS

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ Jesse Rosenstock <jmr@google.com>
2828
Julien Basch <julienbasch@google.com>
2929
Phil Elson <pelson.pub@gmail.com>
3030
Robert Coup <robert.coup@koordinates.com>
31+
Tiago Brito <tiago.brito@90poe.io>

src/s2/util/bits/bits.h

+13-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@
5959
#include <intrin.h>
6060
#endif
6161

62+
// TODO: Remove this and just use ABSL_ASSUME when it is in an LTS release.
63+
#if defined(ABSL_ASSUME)
64+
#define S2_ASSUME(cond) ABSL_ASSUME(cond)
65+
#elif defined(ABSL_INTERNAL_ASSUME)
66+
#define S2_ASSUME(cond) ABSL_INTERNAL_ASSUME(cond)
67+
#else
68+
#error "abseil-cpp must provide ABSL_ASSUME or ABSL_INTERNAL_ASSUME, what version are you using?"
69+
#endif
70+
6271
#include <type_traits>
6372

6473
#include "s2/base/integral_types.h"
@@ -362,7 +371,7 @@ inline int Bits::Log2Floor(T &&n) {
362371
}
363372

364373
inline int Bits::Log2FloorNonZero(uint32 n) {
365-
ABSL_INTERNAL_ASSUME(n != 0);
374+
S2_ASSUME(n != 0);
366375
return absl::bit_width(n) - 1;
367376
}
368377

@@ -384,17 +393,17 @@ inline int Bits::Log2Floor64(T &&n) {
384393
}
385394

386395
inline int Bits::Log2FloorNonZero64(uint64 n) {
387-
ABSL_INTERNAL_ASSUME(n != 0);
396+
S2_ASSUME(n != 0);
388397
return absl::bit_width(n) - 1;
389398
}
390399

391400
inline int Bits::FindLSBSetNonZero(uint32 n) {
392-
ABSL_INTERNAL_ASSUME(n != 0);
401+
S2_ASSUME(n != 0);
393402
return absl::countr_zero(n);
394403
}
395404

396405
inline int Bits::FindLSBSetNonZero64(uint64 n) {
397-
ABSL_INTERNAL_ASSUME(n != 0);
406+
S2_ASSUME(n != 0);
398407
return absl::countr_zero(n);
399408
}
400409

0 commit comments

Comments
 (0)