@sentryware/s2-node 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +45 -0
- package/.dockerignore +1 -0
- package/.gitmodules +3 -0
- package/CHANGELOG.md +33 -0
- package/LICENSE +201 -0
- package/README.md +147 -0
- package/binding.gyp +170 -0
- package/docker/Dockerfile.node20.test +8 -0
- package/docker/Dockerfile.node22.test +8 -0
- package/docker/Dockerfile.node24.test +8 -0
- package/index.d.ts +117 -0
- package/index.js +6 -0
- package/jest.config.js +184 -0
- package/package.json +43 -0
- package/publish-linux.sh +18 -0
- package/publish-osx.sh +19 -0
- package/src/builder.cc +84 -0
- package/src/builder.h +29 -0
- package/src/cell.cc +71 -0
- package/src/cell.h +26 -0
- package/src/cell_id.cc +210 -0
- package/src/cell_id.h +44 -0
- package/src/cell_union.cc +237 -0
- package/src/cell_union.h +34 -0
- package/src/earth.cc +185 -0
- package/src/earth.h +33 -0
- package/src/latlng.cc +132 -0
- package/src/latlng.h +28 -0
- package/src/loop.cc +51 -0
- package/src/loop.h +21 -0
- package/src/point.cc +69 -0
- package/src/point.h +23 -0
- package/src/polygon.cc +36 -0
- package/src/polygon.h +20 -0
- package/src/polyline.cc +186 -0
- package/src/polyline.h +34 -0
- package/src/region_coverer.cc +450 -0
- package/src/region_coverer.h +56 -0
- package/src/s2.cc +27 -0
- package/test/Cell.test.js +37 -0
- package/test/CellId.test.js +135 -0
- package/test/CellUnion.test.js +150 -0
- package/test/Earth.test.js +62 -0
- package/test/LatLng.test.js +45 -0
- package/test/Point.test.js +14 -0
- package/test/Polyline.test.js +78 -0
- package/test/RegionCoverer.test.js +301 -0
- package/test.sh +16 -0
- package/third_party/s2geometry/.travis.yml +163 -0
- package/third_party/s2geometry/AUTHORS +13 -0
- package/third_party/s2geometry/CONTRIBUTING.md +65 -0
- package/third_party/s2geometry/CONTRIBUTORS +30 -0
- package/third_party/s2geometry/LICENSE +202 -0
- package/third_party/s2geometry/NOTICE +5 -0
- package/third_party/s2geometry/README.md +127 -0
- package/third_party/s2geometry/doc/examples/point_index.cc +44 -0
- package/third_party/s2geometry/doc/examples/term_index.cc +99 -0
- package/third_party/s2geometry/doc/examples/term_index.py +101 -0
- package/third_party/s2geometry/src/python/coder.i +125 -0
- package/third_party/s2geometry/src/python/pywraps2_test.py +786 -0
- package/third_party/s2geometry/src/python/s2.i +37 -0
- package/third_party/s2geometry/src/python/s2_common.i +756 -0
- package/third_party/s2geometry/src/s2/_fp_contract_off.h +60 -0
- package/third_party/s2geometry/src/s2/base/casts.h +318 -0
- package/third_party/s2geometry/src/s2/base/commandlineflags.h +67 -0
- package/third_party/s2geometry/src/s2/base/integral_types.h +31 -0
- package/third_party/s2geometry/src/s2/base/log_severity.h +40 -0
- package/third_party/s2geometry/src/s2/base/logging.h +173 -0
- package/third_party/s2geometry/src/s2/base/mutex.h +61 -0
- package/third_party/s2geometry/src/s2/base/port.h +999 -0
- package/third_party/s2geometry/src/s2/base/spinlock.h +60 -0
- package/third_party/s2geometry/src/s2/base/stringprintf.cc +107 -0
- package/third_party/s2geometry/src/s2/base/stringprintf.h +53 -0
- package/third_party/s2geometry/src/s2/base/strtoint.cc +65 -0
- package/third_party/s2geometry/src/s2/base/strtoint.h +106 -0
- package/third_party/s2geometry/src/s2/base/timer.h +50 -0
- package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.cc +164 -0
- package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.h +110 -0
- package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector_test.cc +232 -0
- package/third_party/s2geometry/src/s2/encoded_s2point_vector.cc +838 -0
- package/third_party/s2geometry/src/s2/encoded_s2point_vector.h +140 -0
- package/third_party/s2geometry/src/s2/encoded_s2point_vector_test.cc +344 -0
- package/third_party/s2geometry/src/s2/encoded_s2shape_index.cc +181 -0
- package/third_party/s2geometry/src/s2/encoded_s2shape_index.h +276 -0
- package/third_party/s2geometry/src/s2/encoded_s2shape_index_test.cc +244 -0
- package/third_party/s2geometry/src/s2/encoded_string_vector.cc +66 -0
- package/third_party/s2geometry/src/s2/encoded_string_vector.h +164 -0
- package/third_party/s2geometry/src/s2/encoded_string_vector_test.cc +69 -0
- package/third_party/s2geometry/src/s2/encoded_uint_vector.h +299 -0
- package/third_party/s2geometry/src/s2/encoded_uint_vector_test.cc +124 -0
- package/third_party/s2geometry/src/s2/id_set_lexicon.cc +81 -0
- package/third_party/s2geometry/src/s2/id_set_lexicon.h +199 -0
- package/third_party/s2geometry/src/s2/id_set_lexicon_test.cc +70 -0
- package/third_party/s2geometry/src/s2/mutable_s2shape_index.cc +1585 -0
- package/third_party/s2geometry/src/s2/mutable_s2shape_index.h +600 -0
- package/third_party/s2geometry/src/s2/mutable_s2shape_index_test.cc +589 -0
- package/third_party/s2geometry/src/s2/r1interval.h +220 -0
- package/third_party/s2geometry/src/s2/r1interval_test.cc +185 -0
- package/third_party/s2geometry/src/s2/r2.h +26 -0
- package/third_party/s2geometry/src/s2/r2rect.cc +93 -0
- package/third_party/s2geometry/src/s2/r2rect.h +234 -0
- package/third_party/s2geometry/src/s2/r2rect_test.cc +228 -0
- package/third_party/s2geometry/src/s2/s1angle.cc +54 -0
- package/third_party/s2geometry/src/s2/s1angle.h +336 -0
- package/third_party/s2geometry/src/s2/s1angle_test.cc +185 -0
- package/third_party/s2geometry/src/s2/s1chord_angle.cc +159 -0
- package/third_party/s2geometry/src/s2/s1chord_angle.h +369 -0
- package/third_party/s2geometry/src/s2/s1chord_angle_test.cc +207 -0
- package/third_party/s2geometry/src/s2/s1interval.cc +296 -0
- package/third_party/s2geometry/src/s2/s1interval.h +266 -0
- package/third_party/s2geometry/src/s2/s1interval_test.cc +469 -0
- package/third_party/s2geometry/src/s2/s2boolean_operation.cc +2391 -0
- package/third_party/s2geometry/src/s2/s2boolean_operation.h +501 -0
- package/third_party/s2geometry/src/s2/s2boolean_operation_test.cc +1400 -0
- package/third_party/s2geometry/src/s2/s2builder.cc +1828 -0
- package/third_party/s2geometry/src/s2/s2builder.h +1057 -0
- package/third_party/s2geometry/src/s2/s2builder_graph.cc +1084 -0
- package/third_party/s2geometry/src/s2/s2builder_graph.h +799 -0
- package/third_party/s2geometry/src/s2/s2builder_graph_test.cc +462 -0
- package/third_party/s2geometry/src/s2/s2builder_layer.h +50 -0
- package/third_party/s2geometry/src/s2/s2builder_test.cc +1329 -0
- package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.cc +313 -0
- package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.h +221 -0
- package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer_test.cc +261 -0
- package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.cc +392 -0
- package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.h +86 -0
- package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies_test.cc +182 -0
- package/third_party/s2geometry/src/s2/s2builderutil_graph_shape.h +57 -0
- package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.cc +212 -0
- package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.h +218 -0
- package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer_test.cc +367 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.cc +74 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.h +122 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer_test.cc +167 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.cc +191 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.h +211 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer_test.cc +312 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.cc +105 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.h +174 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer_test.cc +220 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.cc +98 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.h +292 -0
- package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer_test.cc +233 -0
- package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.cc +354 -0
- package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.h +239 -0
- package/third_party/s2geometry/src/s2/s2builderutil_snap_functions_test.cc +716 -0
- package/third_party/s2geometry/src/s2/s2builderutil_testing.cc +37 -0
- package/third_party/s2geometry/src/s2/s2builderutil_testing.h +100 -0
- package/third_party/s2geometry/src/s2/s2builderutil_testing_test.cc +85 -0
- package/third_party/s2geometry/src/s2/s2cap.cc +347 -0
- package/third_party/s2geometry/src/s2/s2cap.h +286 -0
- package/third_party/s2geometry/src/s2/s2cap_test.cc +379 -0
- package/third_party/s2geometry/src/s2/s2cell.cc +552 -0
- package/third_party/s2geometry/src/s2/s2cell.h +249 -0
- package/third_party/s2geometry/src/s2/s2cell_id.cc +619 -0
- package/third_party/s2geometry/src/s2/s2cell_id.h +705 -0
- package/third_party/s2geometry/src/s2/s2cell_id_test.cc +633 -0
- package/third_party/s2geometry/src/s2/s2cell_index.cc +149 -0
- package/third_party/s2geometry/src/s2/s2cell_index.h +660 -0
- package/third_party/s2geometry/src/s2/s2cell_index_test.cc +411 -0
- package/third_party/s2geometry/src/s2/s2cell_test.cc +687 -0
- package/third_party/s2geometry/src/s2/s2cell_union.cc +515 -0
- package/third_party/s2geometry/src/s2/s2cell_union.h +399 -0
- package/third_party/s2geometry/src/s2/s2cell_union_test.cc +598 -0
- package/third_party/s2geometry/src/s2/s2centroids.cc +84 -0
- package/third_party/s2geometry/src/s2/s2centroids.h +87 -0
- package/third_party/s2geometry/src/s2/s2centroids_test.cc +82 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query.cc +123 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query.h +385 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query_base.h +841 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query_base_test.cc +63 -0
- package/third_party/s2geometry/src/s2/s2closest_cell_query_test.cc +412 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query.cc +106 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query.h +421 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_base.h +946 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_base_test.cc +59 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_test.cc +505 -0
- package/third_party/s2geometry/src/s2/s2closest_edge_query_testing.h +91 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query.cc +66 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query.h +465 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query_base.h +767 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query_base_test.cc +63 -0
- package/third_party/s2geometry/src/s2/s2closest_point_query_test.cc +312 -0
- package/third_party/s2geometry/src/s2/s2contains_point_query.h +328 -0
- package/third_party/s2geometry/src/s2/s2contains_point_query_test.cc +159 -0
- package/third_party/s2geometry/src/s2/s2contains_vertex_query.cc +39 -0
- package/third_party/s2geometry/src/s2/s2contains_vertex_query.h +66 -0
- package/third_party/s2geometry/src/s2/s2contains_vertex_query_test.cc +67 -0
- package/third_party/s2geometry/src/s2/s2convex_hull_query.cc +198 -0
- package/third_party/s2geometry/src/s2/s2convex_hull_query.h +110 -0
- package/third_party/s2geometry/src/s2/s2convex_hull_query_test.cc +208 -0
- package/third_party/s2geometry/src/s2/s2coords.cc +146 -0
- package/third_party/s2geometry/src/s2/s2coords.h +459 -0
- package/third_party/s2geometry/src/s2/s2coords_internal.h +71 -0
- package/third_party/s2geometry/src/s2/s2coords_test.cc +218 -0
- package/third_party/s2geometry/src/s2/s2crossing_edge_query.cc +380 -0
- package/third_party/s2geometry/src/s2/s2crossing_edge_query.h +220 -0
- package/third_party/s2geometry/src/s2/s2crossing_edge_query_test.cc +382 -0
- package/third_party/s2geometry/src/s2/s2debug.cc +23 -0
- package/third_party/s2geometry/src/s2/s2debug.h +69 -0
- package/third_party/s2geometry/src/s2/s2distance_target.h +165 -0
- package/third_party/s2geometry/src/s2/s2earth.cc +52 -0
- package/third_party/s2geometry/src/s2/s2earth.h +268 -0
- package/third_party/s2geometry/src/s2/s2earth_test.cc +146 -0
- package/third_party/s2geometry/src/s2/s2edge_clipping.cc +462 -0
- package/third_party/s2geometry/src/s2/s2edge_clipping.h +183 -0
- package/third_party/s2geometry/src/s2/s2edge_clipping_test.cc +335 -0
- package/third_party/s2geometry/src/s2/s2edge_crosser.cc +85 -0
- package/third_party/s2geometry/src/s2/s2edge_crosser.h +343 -0
- package/third_party/s2geometry/src/s2/s2edge_crosser_test.cc +264 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings.cc +515 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings.h +138 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings_internal.h +59 -0
- package/third_party/s2geometry/src/s2/s2edge_crossings_test.cc +246 -0
- package/third_party/s2geometry/src/s2/s2edge_distances.cc +419 -0
- package/third_party/s2geometry/src/s2/s2edge_distances.h +192 -0
- package/third_party/s2geometry/src/s2/s2edge_distances_test.cc +539 -0
- package/third_party/s2geometry/src/s2/s2edge_tessellator.cc +276 -0
- package/third_party/s2geometry/src/s2/s2edge_tessellator.h +101 -0
- package/third_party/s2geometry/src/s2/s2edge_tessellator_test.cc +492 -0
- package/third_party/s2geometry/src/s2/s2edge_vector_shape.h +85 -0
- package/third_party/s2geometry/src/s2/s2edge_vector_shape_test.cc +66 -0
- package/third_party/s2geometry/src/s2/s2error.cc +29 -0
- package/third_party/s2geometry/src/s2/s2error.h +147 -0
- package/third_party/s2geometry/src/s2/s2error_test.cc +31 -0
- package/third_party/s2geometry/src/s2/s2furthest_edge_query.cc +117 -0
- package/third_party/s2geometry/src/s2/s2furthest_edge_query.h +439 -0
- package/third_party/s2geometry/src/s2/s2furthest_edge_query_test.cc +487 -0
- package/third_party/s2geometry/src/s2/s2latlng.cc +90 -0
- package/third_party/s2geometry/src/s2/s2latlng.h +234 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect.cc +727 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect.h +434 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.cc +344 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.h +89 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_bounder_test.cc +306 -0
- package/third_party/s2geometry/src/s2/s2latlng_rect_test.cc +1030 -0
- package/third_party/s2geometry/src/s2/s2latlng_test.cc +165 -0
- package/third_party/s2geometry/src/s2/s2lax_loop_shape.cc +104 -0
- package/third_party/s2geometry/src/s2/s2lax_loop_shape.h +153 -0
- package/third_party/s2geometry/src/s2/s2lax_loop_shape_test.cc +101 -0
- package/third_party/s2geometry/src/s2/s2lax_polygon_shape.cc +348 -0
- package/third_party/s2geometry/src/s2/s2lax_polygon_shape.h +183 -0
- package/third_party/s2geometry/src/s2/s2lax_polygon_shape_test.cc +234 -0
- package/third_party/s2geometry/src/s2/s2lax_polyline_shape.cc +118 -0
- package/third_party/s2geometry/src/s2/s2lax_polyline_shape.h +124 -0
- package/third_party/s2geometry/src/s2/s2lax_polyline_shape_test.cc +62 -0
- package/third_party/s2geometry/src/s2/s2loop.cc +1509 -0
- package/third_party/s2geometry/src/s2/s2loop.h +711 -0
- package/third_party/s2geometry/src/s2/s2loop_measures.cc +313 -0
- package/third_party/s2geometry/src/s2/s2loop_measures.h +280 -0
- package/third_party/s2geometry/src/s2/s2loop_measures_test.cc +367 -0
- package/third_party/s2geometry/src/s2/s2loop_test.cc +1371 -0
- package/third_party/s2geometry/src/s2/s2max_distance_targets.cc +265 -0
- package/third_party/s2geometry/src/s2/s2max_distance_targets.h +241 -0
- package/third_party/s2geometry/src/s2/s2max_distance_targets_test.cc +367 -0
- package/third_party/s2geometry/src/s2/s2measures.cc +128 -0
- package/third_party/s2geometry/src/s2/s2measures.h +78 -0
- package/third_party/s2geometry/src/s2/s2measures_test.cc +135 -0
- package/third_party/s2geometry/src/s2/s2metrics.cc +122 -0
- package/third_party/s2geometry/src/s2/s2metrics.h +199 -0
- package/third_party/s2geometry/src/s2/s2metrics_test.cc +127 -0
- package/third_party/s2geometry/src/s2/s2min_distance_targets.cc +295 -0
- package/third_party/s2geometry/src/s2/s2min_distance_targets.h +273 -0
- package/third_party/s2geometry/src/s2/s2min_distance_targets_test.cc +239 -0
- package/third_party/s2geometry/src/s2/s2padded_cell.cc +162 -0
- package/third_party/s2geometry/src/s2/s2padded_cell.h +108 -0
- package/third_party/s2geometry/src/s2/s2padded_cell_test.cc +138 -0
- package/third_party/s2geometry/src/s2/s2point.h +38 -0
- package/third_party/s2geometry/src/s2/s2point_compression.cc +388 -0
- package/third_party/s2geometry/src/s2/s2point_compression.h +78 -0
- package/third_party/s2geometry/src/s2/s2point_compression_test.cc +305 -0
- package/third_party/s2geometry/src/s2/s2point_index.h +345 -0
- package/third_party/s2geometry/src/s2/s2point_index_test.cc +147 -0
- package/third_party/s2geometry/src/s2/s2point_region.cc +72 -0
- package/third_party/s2geometry/src/s2/s2point_region.h +76 -0
- package/third_party/s2geometry/src/s2/s2point_region_test.cc +100 -0
- package/third_party/s2geometry/src/s2/s2point_span.h +57 -0
- package/third_party/s2geometry/src/s2/s2point_test.cc +47 -0
- package/third_party/s2geometry/src/s2/s2point_vector_shape.h +127 -0
- package/third_party/s2geometry/src/s2/s2point_vector_shape_test.cc +59 -0
- package/third_party/s2geometry/src/s2/s2pointutil.cc +131 -0
- package/third_party/s2geometry/src/s2/s2pointutil.h +138 -0
- package/third_party/s2geometry/src/s2/s2pointutil_test.cc +157 -0
- package/third_party/s2geometry/src/s2/s2polygon.cc +1569 -0
- package/third_party/s2geometry/src/s2/s2polygon.h +934 -0
- package/third_party/s2geometry/src/s2/s2polygon_test.cc +3025 -0
- package/third_party/s2geometry/src/s2/s2polyline.cc +645 -0
- package/third_party/s2geometry/src/s2/s2polyline.h +379 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment.cc +414 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment.h +245 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment_internal.h +158 -0
- package/third_party/s2geometry/src/s2/s2polyline_alignment_test.cc +610 -0
- package/third_party/s2geometry/src/s2/s2polyline_measures.cc +42 -0
- package/third_party/s2geometry/src/s2/s2polyline_measures.h +53 -0
- package/third_party/s2geometry/src/s2/s2polyline_measures_test.cc +57 -0
- package/third_party/s2geometry/src/s2/s2polyline_simplifier.cc +187 -0
- package/third_party/s2geometry/src/s2/s2polyline_simplifier.h +109 -0
- package/third_party/s2geometry/src/s2/s2polyline_simplifier_test.cc +165 -0
- package/third_party/s2geometry/src/s2/s2polyline_test.cc +554 -0
- package/third_party/s2geometry/src/s2/s2predicates.cc +1486 -0
- package/third_party/s2geometry/src/s2/s2predicates.h +282 -0
- package/third_party/s2geometry/src/s2/s2predicates_internal.h +135 -0
- package/third_party/s2geometry/src/s2/s2predicates_test.cc +1427 -0
- package/third_party/s2geometry/src/s2/s2projections.cc +109 -0
- package/third_party/s2geometry/src/s2/s2projections.h +161 -0
- package/third_party/s2geometry/src/s2/s2projections_test.cc +78 -0
- package/third_party/s2geometry/src/s2/s2r2rect.cc +88 -0
- package/third_party/s2geometry/src/s2/s2r2rect.h +292 -0
- package/third_party/s2geometry/src/s2/s2r2rect_test.cc +312 -0
- package/third_party/s2geometry/src/s2/s2region.cc +26 -0
- package/third_party/s2geometry/src/s2/s2region.h +142 -0
- package/third_party/s2geometry/src/s2/s2region_coverer.cc +514 -0
- package/third_party/s2geometry/src/s2/s2region_coverer.h +356 -0
- package/third_party/s2geometry/src/s2/s2region_coverer_test.cc +509 -0
- package/third_party/s2geometry/src/s2/s2region_intersection.cc +84 -0
- package/third_party/s2geometry/src/s2/s2region_intersection.h +79 -0
- package/third_party/s2geometry/src/s2/s2region_term_indexer.cc +270 -0
- package/third_party/s2geometry/src/s2/s2region_term_indexer.h +299 -0
- package/third_party/s2geometry/src/s2/s2region_term_indexer_test.cc +209 -0
- package/third_party/s2geometry/src/s2/s2region_test.cc +370 -0
- package/third_party/s2geometry/src/s2/s2region_union.cc +90 -0
- package/third_party/s2geometry/src/s2/s2region_union.h +83 -0
- package/third_party/s2geometry/src/s2/s2region_union_test.cc +89 -0
- package/third_party/s2geometry/src/s2/s2shape.h +283 -0
- package/third_party/s2geometry/src/s2/s2shape_index.cc +321 -0
- package/third_party/s2geometry/src/s2/s2shape_index.h +781 -0
- package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.cc +113 -0
- package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.h +135 -0
- package/third_party/s2geometry/src/s2/s2shape_index_buffered_region_test.cc +162 -0
- package/third_party/s2geometry/src/s2/s2shape_index_measures.cc +92 -0
- package/third_party/s2geometry/src/s2/s2shape_index_measures.h +100 -0
- package/third_party/s2geometry/src/s2/s2shape_index_measures_test.cc +136 -0
- package/third_party/s2geometry/src/s2/s2shape_index_region.h +350 -0
- package/third_party/s2geometry/src/s2/s2shape_index_region_test.cc +161 -0
- package/third_party/s2geometry/src/s2/s2shape_index_test.cc +24 -0
- package/third_party/s2geometry/src/s2/s2shape_measures.cc +138 -0
- package/third_party/s2geometry/src/s2/s2shape_measures.h +95 -0
- package/third_party/s2geometry/src/s2/s2shape_measures_test.cc +139 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.cc +120 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.h +66 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries_test.cc +170 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_coding.cc +253 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_coding.h +283 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_coding_test.cc +54 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.cc +40 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.h +41 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force_test.cc +55 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_count_edges.h +57 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_count_edges_test.cc +43 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.cc +45 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.h +72 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator_test.cc +116 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.cc +107 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.h +48 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point_test.cc +104 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.cc +58 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.h +65 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator_test.cc +61 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge.h +58 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge_id.h +97 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_testing.cc +104 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_testing.h +36 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.cc +440 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.h +72 -0
- package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs_test.cc +184 -0
- package/third_party/s2geometry/src/s2/s2testing.cc +464 -0
- package/third_party/s2geometry/src/s2/s2testing.h +385 -0
- package/third_party/s2geometry/src/s2/s2testing_test.cc +166 -0
- package/third_party/s2geometry/src/s2/s2text_format.cc +506 -0
- package/third_party/s2geometry/src/s2/s2text_format.h +289 -0
- package/third_party/s2geometry/src/s2/s2text_format_test.cc +417 -0
- package/third_party/s2geometry/src/s2/s2wedge_relations.cc +80 -0
- package/third_party/s2geometry/src/s2/s2wedge_relations.h +64 -0
- package/third_party/s2geometry/src/s2/s2wedge_relations_test.cc +89 -0
- package/third_party/s2geometry/src/s2/sequence_lexicon.h +296 -0
- package/third_party/s2geometry/src/s2/sequence_lexicon_test.cc +113 -0
- package/third_party/s2geometry/src/s2/strings/ostringstream.cc +35 -0
- package/third_party/s2geometry/src/s2/strings/ostringstream.h +105 -0
- package/third_party/s2geometry/src/s2/strings/serialize.cc +46 -0
- package/third_party/s2geometry/src/s2/strings/serialize.h +40 -0
- package/third_party/s2geometry/src/s2/third_party/absl/algorithm/algorithm.h +187 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/attributes.h +666 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/casts.h +189 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/config.h +462 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.cc +129 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.h +394 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/atomic_hook.h +168 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/identity.h +33 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/inline_variable.h +117 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/invoke.h +188 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.cc +254 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.h +205 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.cc +106 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.h +71 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/internal/unaligned_access.h +322 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/log_severity.h +77 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/macros.h +236 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/optimization.h +177 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/policy_checks.h +124 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/port.h +97 -0
- package/third_party/s2geometry/src/s2/third_party/absl/base/thread_annotations.h +277 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/fixed_array.h +523 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/inlined_vector.h +1453 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/internal/compressed_tuple.h +191 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/internal/container_memory.h +424 -0
- package/third_party/s2geometry/src/s2/third_party/absl/container/internal/layout.h +739 -0
- package/third_party/s2geometry/src/s2/third_party/absl/memory/memory.h +755 -0
- package/third_party/s2geometry/src/s2/third_party/absl/meta/type_traits.h +436 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.cc +232 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.h +656 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_have_intrinsic.inc +3 -0
- package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_no_intrinsic.inc +3 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.cc +198 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.h +239 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii_ctype.h +66 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/bits.h +53 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.cc +110 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.h +146 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/resize_uninitialized.h +72 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/match.cc +38 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/match.h +89 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.cc +909 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.h +187 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.cc +240 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.h +398 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_join.h +22 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.cc +47 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.h +43 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.cc +245 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.h +602 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.cc +42 -0
- package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.h +130 -0
- package/third_party/s2geometry/src/s2/third_party/absl/types/span.h +793 -0
- package/third_party/s2geometry/src/s2/third_party/absl/utility/utility.h +299 -0
- package/third_party/s2geometry/src/s2/util/bits/bit-interleave.cc +274 -0
- package/third_party/s2geometry/src/s2/util/bits/bit-interleave.h +53 -0
- package/third_party/s2geometry/src/s2/util/bits/bits.cc +155 -0
- package/third_party/s2geometry/src/s2/util/bits/bits.h +745 -0
- package/third_party/s2geometry/src/s2/util/coding/coder.cc +83 -0
- package/third_party/s2geometry/src/s2/util/coding/coder.h +553 -0
- package/third_party/s2geometry/src/s2/util/coding/nth-derivative.h +134 -0
- package/third_party/s2geometry/src/s2/util/coding/transforms.h +62 -0
- package/third_party/s2geometry/src/s2/util/coding/varint.cc +289 -0
- package/third_party/s2geometry/src/s2/util/coding/varint.h +476 -0
- package/third_party/s2geometry/src/s2/util/endian/endian.h +859 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree.h +2471 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree_container.h +411 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree_map.h +79 -0
- package/third_party/s2geometry/src/s2/util/gtl/btree_set.h +73 -0
- package/third_party/s2geometry/src/s2/util/gtl/compact_array.h +653 -0
- package/third_party/s2geometry/src/s2/util/gtl/container_logging.h +291 -0
- package/third_party/s2geometry/src/s2/util/gtl/dense_hash_set.h +358 -0
- package/third_party/s2geometry/src/s2/util/gtl/densehashtable.h +1493 -0
- package/third_party/s2geometry/src/s2/util/gtl/hashtable_common.h +253 -0
- package/third_party/s2geometry/src/s2/util/gtl/layout.h +28 -0
- package/third_party/s2geometry/src/s2/util/gtl/legacy_random_shuffle.h +77 -0
- package/third_party/s2geometry/src/s2/util/hash/mix.h +76 -0
- package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.cc +832 -0
- package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.h +646 -0
- package/third_party/s2geometry/src/s2/util/math/mathutil.cc +75 -0
- package/third_party/s2geometry/src/s2/util/math/mathutil.h +189 -0
- package/third_party/s2geometry/src/s2/util/math/matrix3x3.h +574 -0
- package/third_party/s2geometry/src/s2/util/math/vector.h +569 -0
- package/third_party/s2geometry/src/s2/util/math/vector3_hash.h +54 -0
- package/third_party/s2geometry/src/s2/util/units/length-units.cc +21 -0
- package/third_party/s2geometry/src/s2/util/units/length-units.h +135 -0
- package/third_party/s2geometry/src/s2/util/units/physical-units.h +313 -0
- package/third_party/s2geometry/src/s2/value_lexicon.h +234 -0
- package/third_party/s2geometry/src/s2/value_lexicon_test.cc +121 -0
- package/third_party/s2geometry/third_party/cmake/FindGFlags.cmake +48 -0
- package/third_party/s2geometry/third_party/cmake/FindGlog.cmake +48 -0
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2017 The Abseil Authors.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
//
|
|
16
|
+
// -----------------------------------------------------------------------------
|
|
17
|
+
// File: int128.h
|
|
18
|
+
// -----------------------------------------------------------------------------
|
|
19
|
+
//
|
|
20
|
+
// This header file defines 128-bit integer types.
|
|
21
|
+
//
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
|
|
25
|
+
#ifndef S2_THIRD_PARTY_ABSL_NUMERIC_INT128_H_
|
|
26
|
+
#define S2_THIRD_PARTY_ABSL_NUMERIC_INT128_H_
|
|
27
|
+
|
|
28
|
+
#include <cassert>
|
|
29
|
+
#include <cmath>
|
|
30
|
+
#include <cstdint>
|
|
31
|
+
#include <cstring>
|
|
32
|
+
#include <iosfwd>
|
|
33
|
+
#include <limits>
|
|
34
|
+
|
|
35
|
+
#include "s2/third_party/absl/base/config.h"
|
|
36
|
+
#include "s2/third_party/absl/base/macros.h"
|
|
37
|
+
#include "s2/third_party/absl/base/port.h"
|
|
38
|
+
|
|
39
|
+
namespace absl {
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// uint128
|
|
43
|
+
//
|
|
44
|
+
// An unsigned 128-bit integer type. The API is meant to mimic an intrinsic type
|
|
45
|
+
// as closely as is practical, including exhibiting undefined behavior in
|
|
46
|
+
// analogous cases (e.g. division by zero). This type is intended to be a
|
|
47
|
+
// drop-in replacement once C++ supports an intrinsic `uint128_t` type; when
|
|
48
|
+
// that occurs, existing well-behaved uses of `uint128` will continue to work
|
|
49
|
+
// using that new type.
|
|
50
|
+
//
|
|
51
|
+
// Note: code written with this type will continue to compile once `uint128_t`
|
|
52
|
+
// is introduced, provided the replacement helper functions
|
|
53
|
+
// `Uint128(Low|High)64()` and `MakeUint128()` are made.
|
|
54
|
+
//
|
|
55
|
+
// A `uint128` supports the following:
|
|
56
|
+
//
|
|
57
|
+
// * Implicit construction from integral types
|
|
58
|
+
// * Explicit conversion to integral types
|
|
59
|
+
//
|
|
60
|
+
// Additionally, if your compiler supports `__int128`, `uint128` is
|
|
61
|
+
// interoperable with that type. (Abseil checks for this compatibility through
|
|
62
|
+
// the `ABSL_HAVE_INTRINSIC_INT128` macro.)
|
|
63
|
+
//
|
|
64
|
+
// However, a `uint128` differs from intrinsic integral types in the following
|
|
65
|
+
// ways:
|
|
66
|
+
//
|
|
67
|
+
// * Errors on implicit conversions that do not preserve value (such as
|
|
68
|
+
// loss of precision when converting to float values).
|
|
69
|
+
// * Requires explicit construction from and conversion to floating point
|
|
70
|
+
// types.
|
|
71
|
+
// * Conversion to integral types requires an explicit static_cast() to
|
|
72
|
+
// mimic use of the `-Wnarrowing` compiler flag.
|
|
73
|
+
// * The alignment requirement of `uint128` may differ from that of an
|
|
74
|
+
// intrinsic 128-bit integer type depending on platform and build
|
|
75
|
+
// configuration.
|
|
76
|
+
//
|
|
77
|
+
// Example:
|
|
78
|
+
//
|
|
79
|
+
// float y = absl::Uint128Max(); // Error. uint128 cannot be implicitly
|
|
80
|
+
// // converted to float.
|
|
81
|
+
//
|
|
82
|
+
// absl::uint128 v;
|
|
83
|
+
// uint64_t i = v; // Error
|
|
84
|
+
// uint64_t i = static_cast<uint64_t>(v); // OK
|
|
85
|
+
//
|
|
86
|
+
class alignas(16) uint128 {
|
|
87
|
+
public:
|
|
88
|
+
uint128() = default;
|
|
89
|
+
|
|
90
|
+
// Constructors from arithmetic types
|
|
91
|
+
constexpr uint128(int v); // NOLINT(runtime/explicit)
|
|
92
|
+
constexpr uint128(unsigned int v); // NOLINT(runtime/explicit)
|
|
93
|
+
constexpr uint128(long v); // NOLINT(runtime/int)
|
|
94
|
+
constexpr uint128(unsigned long v); // NOLINT(runtime/int)
|
|
95
|
+
constexpr uint128(long long v); // NOLINT(runtime/int)
|
|
96
|
+
constexpr uint128(unsigned long long v); // NOLINT(runtime/int)
|
|
97
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
98
|
+
constexpr uint128(__int128 v); // NOLINT(runtime/explicit)
|
|
99
|
+
constexpr uint128(unsigned __int128 v); // NOLINT(runtime/explicit)
|
|
100
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
101
|
+
explicit uint128(float v);
|
|
102
|
+
explicit uint128(double v);
|
|
103
|
+
explicit uint128(long double v);
|
|
104
|
+
|
|
105
|
+
// Assignment operators from arithmetic types
|
|
106
|
+
uint128& operator=(int v);
|
|
107
|
+
uint128& operator=(unsigned int v);
|
|
108
|
+
uint128& operator=(long v); // NOLINT(runtime/int)
|
|
109
|
+
uint128& operator=(unsigned long v); // NOLINT(runtime/int)
|
|
110
|
+
uint128& operator=(long long v); // NOLINT(runtime/int)
|
|
111
|
+
uint128& operator=(unsigned long long v); // NOLINT(runtime/int)
|
|
112
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
113
|
+
uint128& operator=(__int128 v);
|
|
114
|
+
uint128& operator=(unsigned __int128 v);
|
|
115
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
116
|
+
|
|
117
|
+
// Conversion operators to other arithmetic types
|
|
118
|
+
constexpr explicit operator bool() const;
|
|
119
|
+
constexpr explicit operator char() const;
|
|
120
|
+
constexpr explicit operator signed char() const;
|
|
121
|
+
constexpr explicit operator unsigned char() const;
|
|
122
|
+
constexpr explicit operator char16_t() const;
|
|
123
|
+
constexpr explicit operator char32_t() const;
|
|
124
|
+
constexpr explicit operator wchar_t() const;
|
|
125
|
+
constexpr explicit operator short() const; // NOLINT(runtime/int)
|
|
126
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
127
|
+
constexpr explicit operator unsigned short() const;
|
|
128
|
+
constexpr explicit operator int() const;
|
|
129
|
+
constexpr explicit operator unsigned int() const;
|
|
130
|
+
constexpr explicit operator long() const; // NOLINT(runtime/int)
|
|
131
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
132
|
+
constexpr explicit operator unsigned long() const;
|
|
133
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
134
|
+
constexpr explicit operator long long() const;
|
|
135
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
136
|
+
constexpr explicit operator unsigned long long() const;
|
|
137
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
138
|
+
constexpr explicit operator __int128() const;
|
|
139
|
+
constexpr explicit operator unsigned __int128() const;
|
|
140
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
141
|
+
explicit operator float() const;
|
|
142
|
+
explicit operator double() const;
|
|
143
|
+
explicit operator long double() const;
|
|
144
|
+
|
|
145
|
+
// Trivial copy constructor, assignment operator and destructor.
|
|
146
|
+
|
|
147
|
+
// Arithmetic operators.
|
|
148
|
+
uint128& operator+=(uint128 other);
|
|
149
|
+
uint128& operator-=(uint128 other);
|
|
150
|
+
uint128& operator*=(uint128 other);
|
|
151
|
+
// Long division/modulo for uint128.
|
|
152
|
+
uint128& operator/=(uint128 other);
|
|
153
|
+
uint128& operator%=(uint128 other);
|
|
154
|
+
uint128 operator++(int);
|
|
155
|
+
uint128 operator--(int);
|
|
156
|
+
uint128& operator<<=(int);
|
|
157
|
+
uint128& operator>>=(int);
|
|
158
|
+
uint128& operator&=(uint128 other);
|
|
159
|
+
uint128& operator|=(uint128 other);
|
|
160
|
+
uint128& operator^=(uint128 other);
|
|
161
|
+
uint128& operator++();
|
|
162
|
+
uint128& operator--();
|
|
163
|
+
|
|
164
|
+
// Uint128Low64()
|
|
165
|
+
//
|
|
166
|
+
// Returns the lower 64-bit value of a `uint128` value.
|
|
167
|
+
friend constexpr uint64_t Uint128Low64(uint128 v);
|
|
168
|
+
|
|
169
|
+
// Uint128High64()
|
|
170
|
+
//
|
|
171
|
+
// Returns the higher 64-bit value of a `uint128` value.
|
|
172
|
+
friend constexpr uint64_t Uint128High64(uint128 v);
|
|
173
|
+
|
|
174
|
+
// MakeUInt128()
|
|
175
|
+
//
|
|
176
|
+
// Constructs a `uint128` numeric value from two 64-bit unsigned integers.
|
|
177
|
+
// Note that this factory function is the only way to construct a `uint128`
|
|
178
|
+
// from integer values greater than 2^64.
|
|
179
|
+
//
|
|
180
|
+
// Example:
|
|
181
|
+
//
|
|
182
|
+
// absl::uint128 big = absl::MakeUint128(1, 0);
|
|
183
|
+
friend constexpr uint128 MakeUint128(uint64_t high, uint64_t low);
|
|
184
|
+
|
|
185
|
+
// Uint128Max()
|
|
186
|
+
//
|
|
187
|
+
// Returns the highest value for a 128-bit unsigned integer.
|
|
188
|
+
friend constexpr uint128 Uint128Max();
|
|
189
|
+
|
|
190
|
+
private:
|
|
191
|
+
constexpr uint128(uint64_t high, uint64_t low);
|
|
192
|
+
|
|
193
|
+
// TODO(user) Update implementation to use __int128 once all users of
|
|
194
|
+
// uint128 are fixed to not depend on alignof(uint128) == 8. Also add
|
|
195
|
+
// alignas(16) to class definition to keep alignment consistent across
|
|
196
|
+
// platforms.
|
|
197
|
+
#if defined(ABSL_IS_LITTLE_ENDIAN)
|
|
198
|
+
uint64_t lo_;
|
|
199
|
+
uint64_t hi_;
|
|
200
|
+
#elif defined(ABSL_IS_BIG_ENDIAN)
|
|
201
|
+
uint64_t hi_;
|
|
202
|
+
uint64_t lo_;
|
|
203
|
+
#else // byte order
|
|
204
|
+
#error "Unsupported byte order: must be little-endian or big-endian."
|
|
205
|
+
#endif // byte order
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
// allow uint128 to be logged
|
|
210
|
+
std::ostream& operator<<(std::ostream& os, uint128 v);
|
|
211
|
+
|
|
212
|
+
// TODO(user) add operator>>(std::istream&, uint128)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
// --------------------------------------------------------------------------
|
|
216
|
+
// Implementation details follow
|
|
217
|
+
// --------------------------------------------------------------------------
|
|
218
|
+
|
|
219
|
+
constexpr uint128 MakeUint128(uint64_t high, uint64_t low) {
|
|
220
|
+
return uint128(high, low);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
constexpr uint128 Uint128Max() {
|
|
224
|
+
return uint128(std::numeric_limits<uint64_t>::max(),
|
|
225
|
+
std::numeric_limits<uint64_t>::max());
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Assignment from integer types.
|
|
229
|
+
|
|
230
|
+
inline uint128& uint128::operator=(int v) { return *this = uint128(v); }
|
|
231
|
+
|
|
232
|
+
inline uint128& uint128::operator=(unsigned int v) {
|
|
233
|
+
return *this = uint128(v);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
inline uint128& uint128::operator=(long v) { // NOLINT(runtime/int)
|
|
237
|
+
return *this = uint128(v);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
241
|
+
inline uint128& uint128::operator=(unsigned long v) {
|
|
242
|
+
return *this = uint128(v);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
246
|
+
inline uint128& uint128::operator=(long long v) {
|
|
247
|
+
return *this = uint128(v);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
251
|
+
inline uint128& uint128::operator=(unsigned long long v) {
|
|
252
|
+
return *this = uint128(v);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
256
|
+
inline uint128& uint128::operator=(__int128 v) {
|
|
257
|
+
return *this = uint128(v);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
inline uint128& uint128::operator=(unsigned __int128 v) {
|
|
261
|
+
return *this = uint128(v);
|
|
262
|
+
}
|
|
263
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
// Arithmetic operators.
|
|
267
|
+
|
|
268
|
+
uint128 operator<<(uint128 lhs, int amount);
|
|
269
|
+
uint128 operator>>(uint128 lhs, int amount);
|
|
270
|
+
uint128 operator+(uint128 lhs, uint128 rhs);
|
|
271
|
+
uint128 operator-(uint128 lhs, uint128 rhs);
|
|
272
|
+
uint128 operator*(uint128 lhs, uint128 rhs);
|
|
273
|
+
uint128 operator/(uint128 lhs, uint128 rhs);
|
|
274
|
+
uint128 operator%(uint128 lhs, uint128 rhs);
|
|
275
|
+
|
|
276
|
+
inline uint128& uint128::operator<<=(int amount) {
|
|
277
|
+
*this = *this << amount;
|
|
278
|
+
return *this;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
inline uint128& uint128::operator>>=(int amount) {
|
|
282
|
+
*this = *this >> amount;
|
|
283
|
+
return *this;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
inline uint128& uint128::operator+=(uint128 other) {
|
|
287
|
+
*this = *this + other;
|
|
288
|
+
return *this;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
inline uint128& uint128::operator-=(uint128 other) {
|
|
292
|
+
*this = *this - other;
|
|
293
|
+
return *this;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
inline uint128& uint128::operator*=(uint128 other) {
|
|
297
|
+
*this = *this * other;
|
|
298
|
+
return *this;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
inline uint128& uint128::operator/=(uint128 other) {
|
|
302
|
+
*this = *this / other;
|
|
303
|
+
return *this;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
inline uint128& uint128::operator%=(uint128 other) {
|
|
307
|
+
*this = *this % other;
|
|
308
|
+
return *this;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
constexpr uint64_t Uint128Low64(uint128 v) { return v.lo_; }
|
|
312
|
+
|
|
313
|
+
constexpr uint64_t Uint128High64(uint128 v) { return v.hi_; }
|
|
314
|
+
|
|
315
|
+
// Constructors from integer types.
|
|
316
|
+
|
|
317
|
+
#if defined(ABSL_IS_LITTLE_ENDIAN)
|
|
318
|
+
|
|
319
|
+
constexpr uint128::uint128(uint64_t high, uint64_t low)
|
|
320
|
+
: lo_{low}, hi_{high} {}
|
|
321
|
+
|
|
322
|
+
constexpr uint128::uint128(int v)
|
|
323
|
+
: lo_{static_cast<uint64_t>(v)},
|
|
324
|
+
hi_{v < 0 ? std::numeric_limits<uint64_t>::max() : 0} {}
|
|
325
|
+
constexpr uint128::uint128(long v) // NOLINT(runtime/int)
|
|
326
|
+
: lo_{static_cast<uint64_t>(v)},
|
|
327
|
+
hi_{v < 0 ? std::numeric_limits<uint64_t>::max() : 0} {}
|
|
328
|
+
constexpr uint128::uint128(long long v) // NOLINT(runtime/int)
|
|
329
|
+
: lo_{static_cast<uint64_t>(v)},
|
|
330
|
+
hi_{v < 0 ? std::numeric_limits<uint64_t>::max() : 0} {}
|
|
331
|
+
|
|
332
|
+
constexpr uint128::uint128(unsigned int v) : lo_{v}, hi_{0} {}
|
|
333
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
334
|
+
constexpr uint128::uint128(unsigned long v) : lo_{v}, hi_{0} {}
|
|
335
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
336
|
+
constexpr uint128::uint128(unsigned long long v) : lo_{v}, hi_{0} {}
|
|
337
|
+
|
|
338
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
339
|
+
constexpr uint128::uint128(__int128 v)
|
|
340
|
+
: lo_{static_cast<uint64_t>(v & ~uint64_t{0})},
|
|
341
|
+
hi_{static_cast<uint64_t>(static_cast<unsigned __int128>(v) >> 64)} {}
|
|
342
|
+
constexpr uint128::uint128(unsigned __int128 v)
|
|
343
|
+
: lo_{static_cast<uint64_t>(v & ~uint64_t{0})},
|
|
344
|
+
hi_{static_cast<uint64_t>(v >> 64)} {}
|
|
345
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
#elif defined(ABSL_IS_BIG_ENDIAN)
|
|
349
|
+
|
|
350
|
+
constexpr uint128::uint128(uint64_t high, uint64_t low)
|
|
351
|
+
: hi_{high}, lo_{low} {}
|
|
352
|
+
|
|
353
|
+
constexpr uint128::uint128(int v)
|
|
354
|
+
: hi_{v < 0 ? std::numeric_limits<uint64_t>::max() : 0},
|
|
355
|
+
lo_{static_cast<uint64_t>(v)} {}
|
|
356
|
+
constexpr uint128::uint128(long v) // NOLINT(runtime/int)
|
|
357
|
+
: hi_{v < 0 ? std::numeric_limits<uint64_t>::max() : 0},
|
|
358
|
+
lo_{static_cast<uint64_t>(v)} {}
|
|
359
|
+
constexpr uint128::uint128(long long v) // NOLINT(runtime/int)
|
|
360
|
+
: hi_{v < 0 ? std::numeric_limits<uint64_t>::max() : 0},
|
|
361
|
+
lo_{static_cast<uint64_t>(v)} {}
|
|
362
|
+
|
|
363
|
+
constexpr uint128::uint128(unsigned int v) : hi_{0}, lo_{v} {}
|
|
364
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
365
|
+
constexpr uint128::uint128(unsigned long v) : hi_{0}, lo_{v} {}
|
|
366
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
367
|
+
constexpr uint128::uint128(unsigned long long v) : hi_{0}, lo_{v} {}
|
|
368
|
+
|
|
369
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
370
|
+
constexpr uint128::uint128(__int128 v)
|
|
371
|
+
: hi_{static_cast<uint64_t>(static_cast<unsigned __int128>(v) >> 64)},
|
|
372
|
+
lo_{static_cast<uint64_t>(v & ~uint64_t{0})} {}
|
|
373
|
+
constexpr uint128::uint128(unsigned __int128 v)
|
|
374
|
+
: hi_{static_cast<uint64_t>(v >> 64)},
|
|
375
|
+
lo_{static_cast<uint64_t>(v & ~uint64_t{0})} {}
|
|
376
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
#else // byte order
|
|
380
|
+
#error "Unsupported byte order: must be little-endian or big-endian."
|
|
381
|
+
#endif // byte order
|
|
382
|
+
|
|
383
|
+
// Conversion operators to integer types.
|
|
384
|
+
|
|
385
|
+
constexpr uint128::operator bool() const { return lo_ || hi_; }
|
|
386
|
+
|
|
387
|
+
constexpr uint128::operator char() const { return static_cast<char>(lo_); }
|
|
388
|
+
|
|
389
|
+
constexpr uint128::operator signed char() const {
|
|
390
|
+
return static_cast<signed char>(lo_);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
constexpr uint128::operator unsigned char() const {
|
|
394
|
+
return static_cast<unsigned char>(lo_);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
constexpr uint128::operator char16_t() const {
|
|
398
|
+
return static_cast<char16_t>(lo_);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
constexpr uint128::operator char32_t() const {
|
|
402
|
+
return static_cast<char32_t>(lo_);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
constexpr uint128::operator wchar_t() const {
|
|
406
|
+
return static_cast<wchar_t>(lo_);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
410
|
+
constexpr uint128::operator short() const { return static_cast<short>(lo_); }
|
|
411
|
+
|
|
412
|
+
constexpr uint128::operator unsigned short() const { // NOLINT(runtime/int)
|
|
413
|
+
return static_cast<unsigned short>(lo_); // NOLINT(runtime/int)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
constexpr uint128::operator int() const { return static_cast<int>(lo_); }
|
|
417
|
+
|
|
418
|
+
constexpr uint128::operator unsigned int() const {
|
|
419
|
+
return static_cast<unsigned int>(lo_);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// NOLINTNEXTLINE(runtime/int)
|
|
423
|
+
constexpr uint128::operator long() const { return static_cast<long>(lo_); }
|
|
424
|
+
|
|
425
|
+
constexpr uint128::operator unsigned long() const { // NOLINT(runtime/int)
|
|
426
|
+
return static_cast<unsigned long>(lo_); // NOLINT(runtime/int)
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
constexpr uint128::operator long long() const { // NOLINT(runtime/int)
|
|
430
|
+
return static_cast<long long>(lo_); // NOLINT(runtime/int)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
constexpr uint128::operator unsigned long long() const { // NOLINT(runtime/int)
|
|
434
|
+
return static_cast<unsigned long long>(lo_); // NOLINT(runtime/int)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
#ifdef ABSL_HAVE_INTRINSIC_INT128
|
|
438
|
+
constexpr uint128::operator __int128() const {
|
|
439
|
+
return (static_cast<__int128>(hi_) << 64) + lo_;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
constexpr uint128::operator unsigned __int128() const {
|
|
443
|
+
return (static_cast<unsigned __int128>(hi_) << 64) + lo_;
|
|
444
|
+
}
|
|
445
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
446
|
+
|
|
447
|
+
// Conversion operators to floating point types.
|
|
448
|
+
|
|
449
|
+
inline uint128::operator float() const {
|
|
450
|
+
return static_cast<float>(lo_) + std::ldexp(static_cast<float>(hi_), 64);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
inline uint128::operator double() const {
|
|
454
|
+
return static_cast<double>(lo_) + std::ldexp(static_cast<double>(hi_), 64);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
inline uint128::operator long double() const {
|
|
458
|
+
return static_cast<long double>(lo_) +
|
|
459
|
+
std::ldexp(static_cast<long double>(hi_), 64);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// Comparison operators.
|
|
463
|
+
|
|
464
|
+
inline bool operator==(uint128 lhs, uint128 rhs) {
|
|
465
|
+
return (Uint128Low64(lhs) == Uint128Low64(rhs) &&
|
|
466
|
+
Uint128High64(lhs) == Uint128High64(rhs));
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
inline bool operator!=(uint128 lhs, uint128 rhs) {
|
|
470
|
+
return !(lhs == rhs);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
inline bool operator<(uint128 lhs, uint128 rhs) {
|
|
474
|
+
return (Uint128High64(lhs) == Uint128High64(rhs))
|
|
475
|
+
? (Uint128Low64(lhs) < Uint128Low64(rhs))
|
|
476
|
+
: (Uint128High64(lhs) < Uint128High64(rhs));
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
inline bool operator>(uint128 lhs, uint128 rhs) {
|
|
480
|
+
return (Uint128High64(lhs) == Uint128High64(rhs))
|
|
481
|
+
? (Uint128Low64(lhs) > Uint128Low64(rhs))
|
|
482
|
+
: (Uint128High64(lhs) > Uint128High64(rhs));
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
inline bool operator<=(uint128 lhs, uint128 rhs) {
|
|
486
|
+
return (Uint128High64(lhs) == Uint128High64(rhs))
|
|
487
|
+
? (Uint128Low64(lhs) <= Uint128Low64(rhs))
|
|
488
|
+
: (Uint128High64(lhs) <= Uint128High64(rhs));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
inline bool operator>=(uint128 lhs, uint128 rhs) {
|
|
492
|
+
return (Uint128High64(lhs) == Uint128High64(rhs))
|
|
493
|
+
? (Uint128Low64(lhs) >= Uint128Low64(rhs))
|
|
494
|
+
: (Uint128High64(lhs) >= Uint128High64(rhs));
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// Unary operators.
|
|
498
|
+
|
|
499
|
+
inline uint128 operator-(uint128 val) {
|
|
500
|
+
uint64_t hi = ~Uint128High64(val);
|
|
501
|
+
uint64_t lo = ~Uint128Low64(val) + 1;
|
|
502
|
+
if (lo == 0) ++hi; // carry
|
|
503
|
+
return MakeUint128(hi, lo);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
inline bool operator!(uint128 val) {
|
|
507
|
+
return !Uint128High64(val) && !Uint128Low64(val);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Logical operators.
|
|
511
|
+
|
|
512
|
+
inline uint128 operator~(uint128 val) {
|
|
513
|
+
return MakeUint128(~Uint128High64(val), ~Uint128Low64(val));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
inline uint128 operator|(uint128 lhs, uint128 rhs) {
|
|
517
|
+
return MakeUint128(Uint128High64(lhs) | Uint128High64(rhs),
|
|
518
|
+
Uint128Low64(lhs) | Uint128Low64(rhs));
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
inline uint128 operator&(uint128 lhs, uint128 rhs) {
|
|
522
|
+
return MakeUint128(Uint128High64(lhs) & Uint128High64(rhs),
|
|
523
|
+
Uint128Low64(lhs) & Uint128Low64(rhs));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
inline uint128 operator^(uint128 lhs, uint128 rhs) {
|
|
527
|
+
return MakeUint128(Uint128High64(lhs) ^ Uint128High64(rhs),
|
|
528
|
+
Uint128Low64(lhs) ^ Uint128Low64(rhs));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
inline uint128& uint128::operator|=(uint128 other) {
|
|
532
|
+
hi_ |= other.hi_;
|
|
533
|
+
lo_ |= other.lo_;
|
|
534
|
+
return *this;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
inline uint128& uint128::operator&=(uint128 other) {
|
|
538
|
+
hi_ &= other.hi_;
|
|
539
|
+
lo_ &= other.lo_;
|
|
540
|
+
return *this;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
inline uint128& uint128::operator^=(uint128 other) {
|
|
544
|
+
hi_ ^= other.hi_;
|
|
545
|
+
lo_ ^= other.lo_;
|
|
546
|
+
return *this;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Arithmetic operators.
|
|
550
|
+
|
|
551
|
+
inline uint128 operator<<(uint128 lhs, int amount) {
|
|
552
|
+
// uint64_t shifts of >= 64 are undefined, so we will need some
|
|
553
|
+
// special-casing.
|
|
554
|
+
if (amount < 64) {
|
|
555
|
+
if (amount != 0) {
|
|
556
|
+
return MakeUint128(
|
|
557
|
+
(Uint128High64(lhs) << amount) | (Uint128Low64(lhs) >> (64 - amount)),
|
|
558
|
+
Uint128Low64(lhs) << amount);
|
|
559
|
+
}
|
|
560
|
+
return lhs;
|
|
561
|
+
}
|
|
562
|
+
return MakeUint128(Uint128Low64(lhs) << (amount - 64), 0);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
inline uint128 operator>>(uint128 lhs, int amount) {
|
|
566
|
+
// uint64_t shifts of >= 64 are undefined, so we will need some
|
|
567
|
+
// special-casing.
|
|
568
|
+
if (amount < 64) {
|
|
569
|
+
if (amount != 0) {
|
|
570
|
+
return MakeUint128(Uint128High64(lhs) >> amount,
|
|
571
|
+
(Uint128Low64(lhs) >> amount) |
|
|
572
|
+
(Uint128High64(lhs) << (64 - amount)));
|
|
573
|
+
}
|
|
574
|
+
return lhs;
|
|
575
|
+
}
|
|
576
|
+
return MakeUint128(0, Uint128High64(lhs) >> (amount - 64));
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
inline uint128 operator+(uint128 lhs, uint128 rhs) {
|
|
580
|
+
uint128 result = MakeUint128(Uint128High64(lhs) + Uint128High64(rhs),
|
|
581
|
+
Uint128Low64(lhs) + Uint128Low64(rhs));
|
|
582
|
+
if (Uint128Low64(result) < Uint128Low64(lhs)) { // check for carry
|
|
583
|
+
return MakeUint128(Uint128High64(result) + 1, Uint128Low64(result));
|
|
584
|
+
}
|
|
585
|
+
return result;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
inline uint128 operator-(uint128 lhs, uint128 rhs) {
|
|
589
|
+
uint128 result = MakeUint128(Uint128High64(lhs) - Uint128High64(rhs),
|
|
590
|
+
Uint128Low64(lhs) - Uint128Low64(rhs));
|
|
591
|
+
if (Uint128Low64(lhs) < Uint128Low64(rhs)) { // check for carry
|
|
592
|
+
return MakeUint128(Uint128High64(result) - 1, Uint128Low64(result));
|
|
593
|
+
}
|
|
594
|
+
return result;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
inline uint128 operator*(uint128 lhs, uint128 rhs) {
|
|
598
|
+
#if defined(ABSL_HAVE_INTRINSIC_INT128)
|
|
599
|
+
// TODO(user) Remove once alignment issues are resolved and unsigned __int128
|
|
600
|
+
// can be used for uint128 storage.
|
|
601
|
+
return static_cast<unsigned __int128>(lhs) *
|
|
602
|
+
static_cast<unsigned __int128>(rhs);
|
|
603
|
+
#else // ABSL_HAVE_INTRINSIC128
|
|
604
|
+
uint64_t a32 = Uint128Low64(lhs) >> 32;
|
|
605
|
+
uint64_t a00 = Uint128Low64(lhs) & 0xffffffff;
|
|
606
|
+
uint64_t b32 = Uint128Low64(rhs) >> 32;
|
|
607
|
+
uint64_t b00 = Uint128Low64(rhs) & 0xffffffff;
|
|
608
|
+
uint128 result =
|
|
609
|
+
MakeUint128(Uint128High64(lhs) * Uint128Low64(rhs) +
|
|
610
|
+
Uint128Low64(lhs) * Uint128High64(rhs) + a32 * b32,
|
|
611
|
+
a00 * b00);
|
|
612
|
+
result += uint128(a32 * b00) << 32;
|
|
613
|
+
result += uint128(a00 * b32) << 32;
|
|
614
|
+
return result;
|
|
615
|
+
#endif // ABSL_HAVE_INTRINSIC128
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// Increment/decrement operators.
|
|
619
|
+
|
|
620
|
+
inline uint128 uint128::operator++(int) {
|
|
621
|
+
uint128 tmp(*this);
|
|
622
|
+
*this += 1;
|
|
623
|
+
return tmp;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
inline uint128 uint128::operator--(int) {
|
|
627
|
+
uint128 tmp(*this);
|
|
628
|
+
*this -= 1;
|
|
629
|
+
return tmp;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
inline uint128& uint128::operator++() {
|
|
633
|
+
*this += 1;
|
|
634
|
+
return *this;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
inline uint128& uint128::operator--() {
|
|
638
|
+
*this -= 1;
|
|
639
|
+
return *this;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
#if defined(ABSL_HAVE_INTRINSIC_INT128)
|
|
646
|
+
#include "s2/third_party/absl/numeric/int128_have_intrinsic.inc"
|
|
647
|
+
#else // ABSL_HAVE_INTRINSIC_INT128
|
|
648
|
+
#include "s2/third_party/absl/numeric/int128_no_intrinsic.inc"
|
|
649
|
+
#endif // ABSL_HAVE_INTRINSIC_INT128
|
|
650
|
+
|
|
651
|
+
} // namespace absl
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
#endif // S2_THIRD_PARTY_ABSL_NUMERIC_INT128_H_
|