summaryrefslogtreecommitdiff
path: root/src/third_party/s2
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2017-02-09 18:18:04 -0500
committerAndrew Morrow <acm@mongodb.com>2017-02-15 18:40:45 -0500
commit38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5 (patch)
treede472ad7aa7163f977b861525af5a852cf33f6f2 /src/third_party/s2
parent34c00f16a8890775c71c63c860e2086c6bb603aa (diff)
downloadmongo-38c0eb538d0fd390c6cb9ce9ae9894153f6e8ef5.tar.gz
SERVER-28004 Add build system support for iOS-related Darwin variants
Use a SCons invocation like the following to attach to the correct SDK and targeting options. // macOS native build: > python buildscripts/scons.py CCFLAGS="-isysroot `xcrun --sdk macosx --show-sdk-path` -mmacosx-version-min=10.10" LINKFLAGS="-Wl,-syslibroot,`xcrun --sdk macosx --show-sdk-path` -mmacosx-version-min=10.10" CC=`xcrun -f --sdk macosx clang` CXX=`xcrun -f --sdk macosx clang++`all // iOS Cross: > python buildscripts/scons.py CCFLAGS="-arch arm64 -isysroot `xcrun --sdk iphoneos --show-sdk-path` -miphoneos-version-min=10.2" LINKFLAGS="-arch arm64 -Wl,-syslibroot,`xcrun --sdk iphoneos --show-sdk-path` -miphoneos-version-min=10.2" CC=`xcrun -f --sdk iphoneos clang` CXX=`xcrun -f --sdk iphoneos clang++` TARGET_OS=iOS TARGET_ARCH=aarch64 all // iOS Simulator Cross: > python buildscripts/scons.py CCFLAGS="-isysroot `xcrun --sdk iphonesimulator --show-sdk-path` -miphoneos-version-min=10.2" LINKFLAGS="-Wl,-syslibroot,`xcrun --sdk iphonesimulator --show-sdk-path` -miphoneos-version-min=10.2" CC=`xcrun -f --sdk iphonesimulator clang` CXX=`xcrun -f --sdk iphonesimulator clang++` TARGET_OS=iOS-sim all // tvOS Cross: > python buildscripts/scons.py CCFLAGS="-arch arm64 -isysroot `xcrun --sdk appletvos --show-sdk-path` -mtvos-version-min=10.1" LINKFLAGS="-arch arm64 -Wl,-syslibroot,`xcrun --sdk appletvos --show-sdk-path` -mtvos-version-min=10.1" CC=`xcrun -f --sdk appletvos clang` CXX=`xcrun -f --sdk appletvos clang++` TARGET_OS=tvOS TARGET_ARCH=aarch64 all // tvOS Simulator Cross: > python buildscripts/scons.py CCFLAGS="-isysroot `xcrun --sdk appletvsimulator --show-sdk-path` -mtvos-version-min=10.1" LINKFLAGS="-Wl,-syslibroot,`xcrun --sdk appletvsimulator --show-sdk-path` -mtvos-version-min=10.1" CC=`xcrun -f --sdk appletvsimulator clang` CXX=`xcrun -f --sdk appletvsimulator clang++` TARGET_OS=tvOS-sim To run the resulting binaries under the simulator, boot a particular target machine with 'xcrun simctl': > xcrun simctl boot 'Apple TV 1080p' Find the ID of the instance that was booted: > xcrun simctl list | grep 'Apple TV 1080p' And then spawn the intended binary inside the simulator with that ID: > xcrun simctl spawn CEEC6346-6D21-4092-A091-E5A3862A357F build/opt/mongo/mongod --dbpath=tmp
Diffstat (limited to 'src/third_party/s2')
-rw-r--r--src/third_party/s2/base/port.h5
-rw-r--r--src/third_party/s2/s1angle.cc2
-rw-r--r--src/third_party/s2/s1interval.cc8
-rw-r--r--src/third_party/s2/s2cap.cc4
-rw-r--r--src/third_party/s2/s2cellid_test.cc4
-rw-r--r--src/third_party/s2/s2latlng.cc4
-rw-r--r--src/third_party/s2/s2latlngrect.cc2
-rw-r--r--src/third_party/s2/s2latlngrect_test.cc2
-rwxr-xr-xsrc/third_party/s2/util/math/exactfloat/exactfloat.h2
9 files changed, 17 insertions, 16 deletions
diff --git a/src/third_party/s2/base/port.h b/src/third_party/s2/base/port.h
index 25d3d2fcf3c..82e8a7dee56 100644
--- a/src/third_party/s2/base/port.h
+++ b/src/third_party/s2/base/port.h
@@ -685,8 +685,9 @@ extern inline void prefetch(const char *x) {}
#endif // !HAVE_ATTRIBUTE_SECTION
-#if defined __sun || defined _WIN32
-inline double drem(double x, double y) {
+// MongoDB modification: All of our target platforms define the C99 remainder function.
+#if 0
+inline double remainder(double x, double y) {
double quot = x/y;
int iquot;
// If quot is slightly less than 0.5, we round down explicitly. We have to
diff --git a/src/third_party/s2/s1angle.cc b/src/third_party/s2/s1angle.cc
index e299344fb59..650ce1f709c 100644
--- a/src/third_party/s2/s1angle.cc
+++ b/src/third_party/s2/s1angle.cc
@@ -25,7 +25,7 @@ S1Angle S1Angle::Normalized() const {
}
void S1Angle::Normalize() {
- radians_ = drem(radians_, 2.0 * M_PI);
+ radians_ = remainder(radians_, 2.0 * M_PI);
if (radians_ <= -M_PI) radians_ = M_PI;
}
diff --git a/src/third_party/s2/s1interval.cc b/src/third_party/s2/s1interval.cc
index bf676e96482..33af6a00f5b 100644
--- a/src/third_party/s2/s1interval.cc
+++ b/src/third_party/s2/s1interval.cc
@@ -110,7 +110,7 @@ bool S1Interval::InteriorIntersects(S1Interval const& y) const {
inline static double PositiveDistance(double a, double b) {
// Compute the distance from "a" to "b" in the range [0, 2*Pi).
- // This is equivalent to (drem(b - a - M_PI, 2 * M_PI) + M_PI),
+ // This is equivalent to (remainder(b - a - M_PI, 2 * M_PI) + M_PI),
// except that it is more numerically stable (it does not lose
// precision for very small positive distances).
double d = b - a;
@@ -180,7 +180,7 @@ S1Interval S1Interval::Expanded(double radius) const {
// for a 1-bit rounding error when computing each endpoint.
if (GetLength() + 2 * radius >= 2 * M_PI - 1e-15) return Full();
- S1Interval result(drem(lo() - radius, 2*M_PI), drem(hi() + radius, 2*M_PI));
+ S1Interval result(remainder(lo() - radius, 2*M_PI), remainder(hi() + radius, 2*M_PI));
if (result.lo() <= -M_PI) result.set_lo(M_PI);
return result;
}
@@ -245,6 +245,6 @@ S1Interval S1Interval::Intersection(S1Interval const& y) const {
bool S1Interval::ApproxEquals(S1Interval const& y, double max_error) const {
if (is_empty()) return y.GetLength() <= max_error;
if (y.is_empty()) return GetLength() <= max_error;
- return (fabs(drem(y.lo() - lo(), 2 * M_PI)) +
- fabs(drem(y.hi() - hi(), 2 * M_PI))) <= max_error;
+ return (fabs(remainder(y.lo() - lo(), 2 * M_PI)) +
+ fabs(remainder(y.hi() - hi(), 2 * M_PI))) <= max_error;
}
diff --git a/src/third_party/s2/s2cap.cc b/src/third_party/s2/s2cap.cc
index edfde6e20de..0b44cdb8d5a 100644
--- a/src/third_party/s2/s2cap.cc
+++ b/src/third_party/s2/s2cap.cc
@@ -153,8 +153,8 @@ S2LatLngRect S2Cap::GetRectBound() const {
double sin_c = cos(axis_ll.lat().radians());
if (sin_a <= sin_c) {
double angle_A = asin(sin_a / sin_c);
- lng[0] = drem(axis_ll.lng().radians() - angle_A, 2 * M_PI);
- lng[1] = drem(axis_ll.lng().radians() + angle_A, 2 * M_PI);
+ lng[0] = remainder(axis_ll.lng().radians() - angle_A, 2 * M_PI);
+ lng[1] = remainder(axis_ll.lng().radians() + angle_A, 2 * M_PI);
}
}
return S2LatLngRect(R1Interval(lat[0], lat[1]),
diff --git a/src/third_party/s2/s2cellid_test.cc b/src/third_party/s2/s2cellid_test.cc
index cd0695f904d..9f82e84035c 100644
--- a/src/third_party/s2/s2cellid_test.cc
+++ b/src/third_party/s2/s2cellid_test.cc
@@ -237,8 +237,8 @@ TEST(S2CellId, Continuity) {
double u, v;
S2::XYZtoFaceUV(id.ToPointRaw(), &u, &v);
static double const kCellSize = 1.0 / (1 << kMaxWalkLevel);
- EXPECT_NEAR(drem(S2::UVtoST(u), 0.5 * kCellSize), 0.0, 1e-15);
- EXPECT_NEAR(drem(S2::UVtoST(v), 0.5 * kCellSize), 0.0, 1e-15);
+ EXPECT_NEAR(remainder(S2::UVtoST(u), 0.5 * kCellSize), 0.0, 1e-15);
+ EXPECT_NEAR(remainder(S2::UVtoST(v), 0.5 * kCellSize), 0.0, 1e-15);
}
}
diff --git a/src/third_party/s2/s2latlng.cc b/src/third_party/s2/s2latlng.cc
index d0fab58668e..dbe3748a33b 100644
--- a/src/third_party/s2/s2latlng.cc
+++ b/src/third_party/s2/s2latlng.cc
@@ -5,10 +5,10 @@
#include "s2latlng.h"
S2LatLng S2LatLng::Normalized() const {
- // drem(x, 2 * M_PI) reduces its argument to the range [-M_PI, M_PI]
+ // remainder(x, 2 * M_PI) reduces its argument to the range [-M_PI, M_PI]
// inclusive, which is what we want here.
return S2LatLng(max(-M_PI_2, min(M_PI_2, lat().radians())),
- drem(lng().radians(), 2 * M_PI));
+ remainder(lng().radians(), 2 * M_PI));
}
S2Point S2LatLng::ToPoint() const {
diff --git a/src/third_party/s2/s2latlngrect.cc b/src/third_party/s2/s2latlngrect.cc
index 26e34bb14a8..b0c87080eab 100644
--- a/src/third_party/s2/s2latlngrect.cc
+++ b/src/third_party/s2/s2latlngrect.cc
@@ -171,7 +171,7 @@ S2Cap S2LatLngRect::GetCapBound() const {
// rectangles that are larger than 180 degrees, we punt and always return a
// bounding cap centered at one of the two poles.
double lng_span = lng_.hi() - lng_.lo();
- if (drem(lng_span, 2 * M_PI) >= 0) {
+ if (remainder(lng_span, 2 * M_PI) >= 0) {
if (lng_span < 2 * M_PI) {
S2Cap mid_cap = S2Cap::FromAxisAngle(GetCenter().ToPoint(),
S1Angle::Radians(0));
diff --git a/src/third_party/s2/s2latlngrect_test.cc b/src/third_party/s2/s2latlngrect_test.cc
index 33408944a00..f64981cf694 100644
--- a/src/third_party/s2/s2latlngrect_test.cc
+++ b/src/third_party/s2/s2latlngrect_test.cc
@@ -99,7 +99,7 @@ TEST(S2LatLngRect, GetVertex) {
double lat = M_PI_4 * (i - 2);
double lng = M_PI_2 * (i - 2) + 0.2;
S2LatLngRect r(R1Interval(lat, lat + M_PI_4),
- S1Interval(drem(lng, 2*M_PI), drem(lng + M_PI_2, 2*M_PI)));
+ S1Interval(remainder(lng, 2*M_PI), remainder(lng + M_PI_2, 2*M_PI)));
for (int k = 0; k < 4; ++k) {
EXPECT_TRUE(S2::SimpleCCW(r.GetVertex((k - 1) & 3).ToPoint(),
r.GetVertex(k).ToPoint(),
diff --git a/src/third_party/s2/util/math/exactfloat/exactfloat.h b/src/third_party/s2/util/math/exactfloat/exactfloat.h
index b6af9a89489..5e9044bcc72 100755
--- a/src/third_party/s2/util/math/exactfloat/exactfloat.h
+++ b/src/third_party/s2/util/math/exactfloat/exactfloat.h
@@ -436,7 +436,7 @@ class ExactFloat {
}
// A synonym for remainder().
- friend ExactFloat drem(const ExactFloat& a, const ExactFloat& b) {
+ friend ExactFloat remainder(const ExactFloat& a, const ExactFloat& b) {
return remainder(a, b);
}