Skip to content

Commit f80b725

Browse files
authored
Update to 2025-09-24 google3 version (#454)
* Bump required versions * abseil-cpp: LTS 20250814 * clang: 14 * CMake: 3.22 * OpenSSL: 1.1 * New functions * MutableS2ShapeIndex::Remove() * S2EdgeVectorShape::set_dimension() * S2Polygon::MakeFull() * Add tests for ExactFloat
2 parents 5b5fbc0 + 0fb80f7 commit f80b725

34 files changed

+1280
-443
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- uses: zacharyburnett/setup-abseil-cpp@713a4383f10b05948a6d9d4906056063c8da1168 # Not a release, but has #423 fix.
3636
with:
3737
cmake-build-args: "-DCMAKE_CXX_STANDARD=17 -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON -DBUILD_TESTING=off -DCMAKE_POSITION_INDEPENDENT_CODE=ON"
38-
abseil-version: "20250512.1"
38+
abseil-version: "20250814.1"
3939
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4040
- run: mkdir build
4141
- run: cmake -DCMAKE_CXX_STANDARD=17 -DCMAKE_PREFIX_PATH=/usr/local/ -DBUILD_TESTS=OFF ..

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- uses: zacharyburnett/setup-abseil-cpp@713a4383f10b05948a6d9d4906056063c8da1168 # Not a release, but has #423 fix.
3737
with:
3838
cmake-build-args: "-DCMAKE_CXX_STANDARD=17 -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON -DBUILD_TESTING=off -DCMAKE_POSITION_INDEPENDENT_CODE=ON"
39-
abseil-version: "20250512.1"
39+
abseil-version: "20250814.1"
4040
- name: retrieve googletest v${{ env.GOOGLETEST_VERSION }}
4141
run: |
4242
wget https://github.com/google/googletest/releases/download/v${{ env.GOOGLETEST_VERSION }}/googletest-${{ env.GOOGLETEST_VERSION }}.tar.gz

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,6 @@ if(S2_ENABLE_INSTALL)
443443
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/testing")
444444
install(FILES src/s2/util/bitmap/bitmap.h
445445
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/bitmap")
446-
install(FILES src/s2/util/bits/bits.h
447-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/bits")
448446
install(FILES src/s2/util/coding/coder.h
449447
src/s2/util/coding/varint.h
450448
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/coding")
@@ -455,6 +453,7 @@ if(S2_ENABLE_INSTALL)
455453
src/s2/util/gtl/dense_hash_set.h
456454
src/s2/util/gtl/densehashtable.h
457455
src/s2/util/gtl/hashtable_common.h
456+
src/s2/util/gtl/requires.h
458457
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/gtl")
459458
install(FILES src/s2/util/hash/mix.h
460459
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/hash")
@@ -622,7 +621,8 @@ if (BUILD_TESTS)
622621
src/s2/s2winding_operation_test.cc
623622
src/s2/s2wrapped_shape_test.cc
624623
src/s2/sequence_lexicon_test.cc
625-
src/s2/value_lexicon_test.cc)
624+
src/s2/value_lexicon_test.cc
625+
src/s2/util/math/exactfloat/exactfloat_test.cc)
626626

627627
enable_testing()
628628

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ This issue may require revision of boringssl or exactfloat.
5252

5353
* We aim to support all platforms supported by the
5454
[Google foundational C++ support policy](https://opensource.google/documentation/policies/cplusplus-support)
55-
* [CMake](http://www.cmake.org/) >= 3.5
55+
* [CMake](http://www.cmake.org/) >= 3.22
5656
* A C++ compiler with C++17 support, such as
5757
[g++ >= 7.5](https://gcc.gnu.org/) or
58-
[clang >= 7.0.0](https://clang.llvm.org/)
58+
[clang >= 14.0.0](https://clang.llvm.org/)
5959
* [Abseil](https://github.com/abseil/abseil-cpp) >= LTS
60-
[`20250512`](https://github.com/abseil/abseil-cpp/releases/tag/20250512.1)
60+
[`20250814`](https://github.com/abseil/abseil-cpp/releases/tag/20250814.1)
6161
(standard library extensions)
6262
* [OpenSSL](https://github.com/openssl/openssl) (for its bignum library)
6363
* [googletest testing framework >= 1.10](https://github.com/google/googletest)

src/s2/base/port.h

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// This file contains things that are not used in third_party/absl but needed by
2020
// s2geometry. It is structured into the following high-level categories:
2121
// - Utility functions
22-
// - Endianness
2322
// - Performance optimization (alignment)
2423

2524
#include <cstdint>
@@ -41,55 +40,6 @@ inline void sized_delete_array(void *ptr, size_t size) {
4140
}
4241
} // namespace base
4342

44-
// -----------------------------------------------------------------------------
45-
// Endianness
46-
// -----------------------------------------------------------------------------
47-
48-
// IS_LITTLE_ENDIAN, IS_BIG_ENDIAN
49-
#if defined(__linux__)
50-
#include <endian.h>
51-
52-
#elif defined(__APPLE__)
53-
54-
// BIG_ENDIAN
55-
#include <machine/endian.h> // NOLINT(build/include)
56-
57-
/* Let's try and follow the Linux convention */
58-
#define __BYTE_ORDER BYTE_ORDER
59-
#define __LITTLE_ENDIAN LITTLE_ENDIAN
60-
#define __BIG_ENDIAN BIG_ENDIAN
61-
62-
#endif
63-
64-
// defines __BYTE_ORDER
65-
#ifdef _WIN32
66-
#define __BYTE_ORDER __LITTLE_ENDIAN
67-
#define IS_LITTLE_ENDIAN
68-
#else // _WIN32
69-
70-
// define the macros IS_LITTLE_ENDIAN or IS_BIG_ENDIAN
71-
// using the above endian definitions from endian.h if
72-
// endian.h was included
73-
#ifdef __BYTE_ORDER
74-
#if __BYTE_ORDER == __LITTLE_ENDIAN
75-
#define IS_LITTLE_ENDIAN
76-
#endif
77-
78-
#if __BYTE_ORDER == __BIG_ENDIAN
79-
#define IS_BIG_ENDIAN
80-
#endif
81-
82-
#else // __BYTE_ORDER
83-
84-
#if defined(__LITTLE_ENDIAN__)
85-
#define IS_LITTLE_ENDIAN
86-
#elif defined(__BIG_ENDIAN__)
87-
#define IS_BIG_ENDIAN
88-
#endif
89-
90-
#endif // __BYTE_ORDER
91-
#endif // _WIN32
92-
9343
// -----------------------------------------------------------------------------
9444
// Performance Optimization
9545
// -----------------------------------------------------------------------------
@@ -100,37 +50,15 @@ inline void sized_delete_array(void *ptr, size_t size) {
10050

10151
// Portable handling of unaligned loads, stores, and copies. These are simply
10252
// constant-length memcpy calls.
103-
//
104-
// TODO(user): These APIs are forked in Abseil, see
105-
// "third_party/absl/base/internal/unaligned_access.h".
106-
//
107-
// The unaligned API is C++ only. The declarations use C++ features
108-
// (namespaces, inline) which are absent or incompatible in C.
109-
#if defined(__cplusplus)
11053

11154
namespace base {
112-
113-
// Can't use ATTRIBUTE_NO_SANITIZE_MEMORY because this file is included before
114-
// attributes.h is.
115-
#ifdef __has_attribute
116-
#if __has_attribute(no_sanitize_memory)
117-
#define NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
118-
#endif // __has_attribute(no_sanitize_memory)
119-
#endif // defined __has_attribute
120-
121-
#ifndef NO_SANITIZE_MEMORY
122-
#define NO_SANITIZE_MEMORY /**/
123-
#endif
124-
12555
template <typename T>
126-
T NO_SANITIZE_MEMORY UnalignedLoad(const void *p) {
56+
T UnalignedLoad(const void *p) {
12757
T t;
12858
memcpy(&t, p, sizeof t);
12959
return t;
13060
}
13161

132-
#undef NO_SANITIZE_MEMORY
133-
13462
template <typename T>
13563
void UnalignedStore(void *p, T t) {
13664
memcpy(p, &t, sizeof t);
@@ -161,6 +89,4 @@ inline void UNALIGNED_STORE64(void *p, uint64_t v) {
16189
base::UnalignedStore(p, v);
16290
}
16391

164-
#endif // defined(__cplusplus), end of unaligned API
165-
16692
#endif // S2_BASE_PORT_H_

src/s2/base/spinlock.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,38 @@ class ABSL_LOCKABLE ABSL_ATTRIBUTE_WARN_UNUSED SpinLock {
2727
SpinLock(SpinLock const&) = delete;
2828
SpinLock& operator=(SpinLock const&) = delete;
2929

30-
inline void Lock() ABSL_EXCLUSIVE_LOCK_FUNCTION() {
30+
inline void lock() ABSL_EXCLUSIVE_LOCK_FUNCTION() {
3131
while (locked_.exchange(true, std::memory_order_acquire)) {
3232
// Spin.
3333
continue;
3434
}
3535
}
3636

37-
inline void Unlock() ABSL_UNLOCK_FUNCTION() {
37+
inline void unlock() ABSL_UNLOCK_FUNCTION() {
3838
locked_.store(false, std::memory_order_release);
3939
}
4040

41-
ABSL_MUST_USE_RESULT inline bool IsHeld() const {
41+
[[nodiscard]] inline bool IsHeld() const {
4242
return locked_.load(std::memory_order_relaxed);
4343
}
4444

4545
private:
4646
std::atomic_bool locked_{false};
4747
};
4848

49-
class ABSL_MUST_USE_RESULT ABSL_SCOPED_LOCKABLE SpinLockHolder {
49+
class [[nodiscard]] ABSL_SCOPED_LOCKABLE SpinLockHolder {
5050
public:
51-
inline explicit SpinLockHolder(SpinLock* l) ABSL_EXCLUSIVE_LOCK_FUNCTION(l)
51+
inline explicit SpinLockHolder(SpinLock& l) ABSL_EXCLUSIVE_LOCK_FUNCTION(l)
5252
: lock_(l) {
53-
lock_->Lock();
53+
l.lock();
5454
}
55-
inline ~SpinLockHolder() ABSL_UNLOCK_FUNCTION() { lock_->Unlock(); }
55+
inline ~SpinLockHolder() ABSL_UNLOCK_FUNCTION() { lock_.unlock(); }
5656

5757
SpinLockHolder(const SpinLockHolder&) = delete;
5858
SpinLockHolder& operator=(const SpinLockHolder&) = delete;
5959

6060
private:
61-
SpinLock* lock_;
61+
SpinLock& lock_;
6262
};
6363

6464
#endif // S2_BASE_SPINLOCK_H_

src/s2/encoded_s2point_vector.cc

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ void EncodedS2PointVector::Encode(Encoder* encoder) const {
203203

204204
// Encodes a vector of points, optimizing for (encoding and decoding) speed.
205205
void EncodeS2PointVectorFast(Span<const S2Point> points, Encoder* encoder) {
206-
#ifndef IS_LITTLE_ENDIAN
207-
ABSL_LOG(FATAL) << "Not implemented on big-endian architectures";
208-
#endif
206+
if constexpr (absl::endian::native != absl::endian::little) {
207+
ABSL_LOG(FATAL) << "Not implemented on big-endian architectures";
208+
}
209209

210210
// This function always uses the UNCOMPRESSED encoding. The header consists
211211
// of a varint64 in the following format:
@@ -222,19 +222,24 @@ void EncodeS2PointVectorFast(Span<const S2Point> points, Encoder* encoder) {
222222
}
223223

224224
bool EncodedS2PointVector::InitUncompressedFormat(Decoder* decoder) {
225-
#if !defined(IS_LITTLE_ENDIAN) || defined(__arm__)
226-
// TODO(b/231674214): Make this work on platforms that don't support
227-
// unaligned 64-bit little-endian reads, e.g. by falling back to
228-
//
229-
// bit_cast<double>(little_endian::Load64()).
230-
//
231-
// Maybe the compiler is smart enough that we can do this all the time,
232-
// but more likely we will need two cases using the #ifdef above.
233-
// (Note that even ARMv7 does not support unaligned 64-bit loads.)
234-
ABSL_LOG(ERROR)
235-
<< "Needs architecture with 64-bit little-endian unaligned loads";
236-
return false;
225+
#ifdef __arm__
226+
constexpr bool kIsArm32 = true;
227+
#else
228+
constexpr bool kIsArm32 = false;
237229
#endif
230+
if constexpr (absl::endian::native != absl::endian::little || kIsArm32) {
231+
// TODO(b/231674214): Make this work on platforms that don't support
232+
// unaligned 64-bit little-endian reads, e.g. by falling back to
233+
//
234+
// bit_cast<double>(LittleEndian::Load64()).
235+
//
236+
// Maybe the compiler is smart enough that we can do this all the time,
237+
// but more likely we will need two cases using the #ifdef above.
238+
// (Note that even ARMv7 does not support unaligned 64-bit loads.)
239+
ABSL_LOG(ERROR)
240+
<< "Needs architecture with 64-bit little-endian unaligned loads";
241+
return false;
242+
}
238243

239244
uint64_t size;
240245
if (!decoder->get_varint64(&size)) return false;

src/s2/encoded_s2shape_index.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const S2ShapeIndexCell* EncodedS2ShapeIndex::GetCell(int i) const {
8181
}
8282
// Recheck cell_decoded(i) once we hold the lock in case another thread
8383
// has decoded this cell in the meantime.
84-
SpinLockHolder l(&cells_lock_);
84+
SpinLockHolder l(cells_lock_);
8585
if (cell_decoded(i)) return cells_[i];
8686

8787
// Update the cell, setting cells_[i] before cell_decoded(i).

src/s2/internal/s2index_cell_data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class S2IndexCellData {
142142
// Returns an S2Cell instance for the current cell.
143143
const S2Cell& cell() const {
144144
if (!s2cell_set_.load(std::memory_order_acquire)) {
145-
absl::MutexLock lock(&lock_);
145+
absl::MutexLock lock(lock_);
146146
if (!s2cell_set_.load(std::memory_order_relaxed)) {
147147
s2cell_ = S2Cell(cell_id_);
148148
s2cell_set_.store(true, std::memory_order_release);
@@ -156,7 +156,7 @@ class S2IndexCellData {
156156
// Returns the center point of the current cell.
157157
const S2Point& center() const {
158158
if (!center_set_.load(std::memory_order_acquire)) {
159-
absl::MutexLock lock(&lock_);
159+
absl::MutexLock lock(lock_);
160160
if (!center_set_.load(std::memory_order_relaxed)) {
161161
cell_center_ = cell_id_.ToPoint();
162162
center_set_.store(true, std::memory_order_release);

0 commit comments

Comments
 (0)