diff options
author | gregs <greg@10gen.com> | 2011-05-06 17:40:28 -0400 |
---|---|---|
committer | gregs <greg@10gen.com> | 2011-05-06 17:42:00 -0400 |
commit | 9c79d5735da100a25aed37c3a1339b69e8883c07 (patch) | |
tree | 367f6aef81e2773d191c88db87d1532ee5a8b2a2 /db/geo | |
parent | 2ac6dbcf63547fd90609e3812e4c99e835ed0082 (diff) | |
download | mongo-9c79d5735da100a25aed37c3a1339b69e8883c07.tar.gz |
no volatile reqd for 64-bit systems SERVER-2940
Diffstat (limited to 'db/geo')
-rw-r--r-- | db/geo/core.h | 29 |
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; |