summaryrefslogtreecommitdiff
path: root/db/geo/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'db/geo/core.h')
-rw-r--r--db/geo/core.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/db/geo/core.h b/db/geo/core.h
index 109495066c0..a3124f65158 100644
--- a/db/geo/core.h
+++ b/db/geo/core.h
@@ -421,19 +421,26 @@ namespace mongo {
// calculated imprecisely. We need to force the compiler to always evaluate it correctly,
// hence the weirdness.
//
- // On a 32-bit linux machine, removing the volatile keyword or calculating the sum inline
- // will make certain geo tests fail.
- // TODO: Fix this with compiler options or conditional paths for 32/64 bit
- volatile double sum = _y > p._y ? p._y + radius : _y + radius;
- return _y > p._y ? sum >= _y : sum >= p._y;
-
- // Original math, correct for most systems
- //return _y > p._y ? p._y + radius >= _y : _y + radius >= p._y;
+ // On some 32-bit linux machines, removing the volatile keyword or calculating the sum inline
+ // will make certain geo tests fail. Of course this check will force volatile for all 32-bit systems,
+ // not just affected systems.
+ if( sizeof(void*) <= 4 ){
+ volatile double sum = _y > p._y ? p._y + radius : _y + radius;
+ return _y > p._y ? sum >= _y : sum >= p._y;
+ }
+ else {
+ // Original math, correct for most systems
+ return _y > p._y ? p._y + radius >= _y : _y + radius >= p._y;
+ }
}
if( b == 0 ) {
- volatile double sum = _x > p._x ? p._x + radius : _x + radius;
- return _x > p._x ? sum >= _x : sum >= p._x;
- // return _x > p._x ? p._x + radius >= _x : _x + radius >= p._x;
+ if( sizeof(void*) <= 4 ){
+ volatile double sum = _x > p._x ? p._x + radius : _x + radius;
+ return _x > p._x ? sum >= _x : sum >= p._x;
+ }
+ else {
+ return _x > p._x ? p._x + radius >= _x : _x + radius >= p._x;
+ }
}
return sqrt( ( a * a ) + ( b * b ) ) <= radius;