Skip to content

Commit bd26b76

Browse files
authored
Update to 2025-07-09 google3 version
* Require C++17 * Require abseil-cpp LTS 20250512 * Fix S2ShapeNestingQuery when two chains share a vertex * Fix S2Polygon bug when intersecting polyline * Add S2ClosestEdgeQuery::VisitClosestShapes * Delete deprecated S2Error::text(); use message() instead * Ensure _fp_contract_off.h is included everywhere * Add thread annotations to SpinLock * Convert many const vector<>&s to Span<>s * Add noexcept to move operators * Make some comparisons stable for sorting * Guard against overflow in Decode functions
2 parents 398fe4e + 87bc966 commit bd26b76

File tree

237 files changed

+1338
-1158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+1338
-1158
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ endif()
1919
# s2geometry needs to use the same C++ standard that absl used to avoid
2020
# undefined symbol errors since ABSL_HAVE_STD_STRING_VIEW etc will
2121
# end up defined differently. There is probably a better way to achieve
22-
# this than assuming what absl used. We default to c++17, but support
23-
# c++14 (like abseil).
22+
# this than assuming what absl used. We require at least C++17.
2423
# Using CACHE allows the user to override the default.
2524
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to build with")
2625
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -232,6 +231,7 @@ endif()
232231
target_link_libraries(
233232
s2
234233
${OPENSSL_LIBRARIES}
234+
absl::absl_vlog_is_on
235235
absl::base
236236
absl::btree
237237
absl::check
@@ -438,7 +438,6 @@ if(S2_ENABLE_INSTALL)
438438
src/s2/base/malloc_extension.h
439439
src/s2/base/port.h
440440
src/s2/base/spinlock.h
441-
src/s2/base/types.h
442441
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/base")
443442
install(FILES src/s2/testing/gtest_prod.h
444443
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/testing")

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ S2 documentation can be found on [s2geometry.io](http://s2geometry.io).
1818

1919
Note that all [releases](https://github.com/google/s2geometry/releases) are
2020
version 0.x, so there are
21-
[no API or ABI stability guarantees](https://semver.org/#spec-item-4).
22-
Starting with 1.0 we will adhere to [SemVer](https://semver.org/).
21+
[no API or ABI stability guarantees](https://semver.org/#spec-item-4). Starting
22+
with 1.0 we will adhere to [SemVer](https://semver.org/) and follow the
23+
[Google OSS breaking change policy](https://opensource.google/documentation/policies/library-breaking-change)
2324

2425
The Python API is particularly unstable, and it is planned that the SWIGged
2526
API will be replaced by a pybind11 version with more Pythonic names and more
@@ -49,8 +50,12 @@ This issue may require revision of boringssl or exactfloat.
4950

5051
## Requirements for End Users using CMake
5152

53+
* We aim to support all platforms supported by the
54+
[Google foundational C++ support policy](https://opensource.google/documentation/policies/cplusplus-support)
5255
* [CMake](http://www.cmake.org/) >= 3.5
53-
* A C++ compiler with C++14 support, such as [g++ >= 5](https://gcc.gnu.org/)
56+
* A C++ compiler with C++17 support, such as
57+
[g++ >= 7.5](https://gcc.gnu.org/) or
58+
[clang >= 7.0.0](https://clang.llvm.org/)
5459
* [Abseil](https://github.com/abseil/abseil-cpp) >= LTS
5560
[`20240722`](https://github.com/abseil/abseil-cpp/releases/tag/20240722.0)
5661
(standard library extensions)
@@ -83,8 +88,6 @@ cmake -DGOOGLETEST_ROOT=/opt/local/src -DCMAKE_PREFIX_PATH=/opt/local ..
8388

8489
in the build instructions below.
8590

86-
Thorough testing has only been done on Ubuntu 14.04.3 and macOS 10.13.
87-
8891
## Build and Install
8992

9093
You may either download the source as a ZIP archive, or [clone the git

src/python/s2_common.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public:
119119

120120
%typemap(argout) S2Error * {
121121
if(!$1->ok())
122-
SWIG_exception(SWIG_ValueError, $1->text().c_str());
122+
SWIG_exception(SWIG_ValueError, std::string($1->message()).c_str());
123123
}
124124

125125
// This overload shadows the one the takes vector<uint64_t>&, and it

src/s2/_fp_contract_off.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@
3434
// but it is not implemented in GCC because the standard pragma allows control
3535
// at the level of compound statements rather than entire functions.
3636
//
37+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20785
38+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37845
39+
//
3740
// This file may be included with other files in any order, as long as it
3841
// appears before the first non-inline function definition. It is
3942
// named with an underscore so that it is included first among the S2 headers.
4043

41-
#if defined(__clang__)
42-
// Clang supports the standard C++ pragma for turning off this optimization.
44+
// Assume all compilers support or ignore the standard pragma.
4345
#pragma STDC FP_CONTRACT OFF
4446

45-
#elif defined(__GNUC__)
47+
#if defined(__GNUC__) && !defined(__clang__)
4648
// GCC defines its own pragma that operates at the function level rather than
4749
// the statement level.
4850
#pragma GCC optimize("fp-contract=off")

src/s2/base/commandlineflags.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "absl/flags/flag.h"
2323

2424
#include "s2/base/commandlineflags_declare.h"
25-
#include "s2/base/types.h"
2625

2726
#define S2_DEFINE_bool(name, default_value, description) \
2827
ABSL_FLAG(bool, name, default_value, description)

src/s2/base/commandlineflags_declare.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
#include "absl/flags/declare.h"
2323

24-
#include "s2/base/types.h"
2524

2625
#define S2_DECLARE_bool(name) ABSL_DECLARE_FLAG(bool, name)
2726

src/s2/base/port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <cstdint>
2626
#include <cstring>
27+
#include <new>
2728

2829
// -----------------------------------------------------------------------------
2930
// Utility Functions
@@ -45,7 +46,7 @@ inline void sized_delete_array(void *ptr, size_t size) {
4546
// -----------------------------------------------------------------------------
4647

4748
// IS_LITTLE_ENDIAN, IS_BIG_ENDIAN
48-
#if defined(__linux__) || defined(__ANDROID__)
49+
#if defined(__linux__)
4950
#include <endian.h>
5051

5152
#elif defined(__APPLE__)

src/s2/base/spinlock.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
#ifndef S2_BASE_SPINLOCK_H_
1717
#define S2_BASE_SPINLOCK_H_
1818

19-
#include <absl/base/thread_annotations.h>
20-
2119
#include <atomic>
2220

23-
class ABSL_LOCKABLE SpinLock {
21+
#include <absl/base/thread_annotations.h>
22+
23+
class ABSL_LOCKABLE ABSL_ATTRIBUTE_WARN_UNUSED SpinLock {
2424
public:
2525
SpinLock() = default;
2626
~SpinLock() = default;
@@ -38,13 +38,15 @@ class ABSL_LOCKABLE SpinLock {
3838
locked_.store(false, std::memory_order_release);
3939
}
4040

41-
inline bool IsHeld() const { return locked_.load(std::memory_order_relaxed); }
41+
ABSL_MUST_USE_RESULT inline bool IsHeld() const {
42+
return locked_.load(std::memory_order_relaxed);
43+
}
4244

4345
private:
4446
std::atomic_bool locked_{false};
4547
};
4648

47-
class ABSL_SCOPED_LOCKABLE SpinLockHolder {
49+
class ABSL_MUST_USE_RESULT ABSL_SCOPED_LOCKABLE SpinLockHolder {
4850
public:
4951
inline explicit SpinLockHolder(SpinLock* l) ABSL_EXCLUSIVE_LOCK_FUNCTION(l)
5052
: lock_(l) {

src/s2/base/types.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/s2/encoded_s2cell_id_vector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "absl/types/span.h"
2626
#include "s2/util/coding/coder.h"
27+
#include "s2/_fp_contract_off.h" // IWYU pragma: keep
2728
#include "s2/encoded_uint_vector.h"
2829
#include "s2/s2cell_id.h"
2930

0 commit comments

Comments
 (0)