Commit 1630ee64 authored by Lynn Garren's avatar Lynn Garren
Browse files

fix for 64bit bug

parent 441e1997
2008-11-13 Mark Fischler <mf@fnal.gov>
* src/engineIDulong.cc: fix a problem for 64bit machines
* src/*Engine.cc: protection against the 64bit problem for states
that may have been previously saved
==============================
04.11.08 Release CLHEP-2.0.4.1
==============================
......
// -*- C++ -*-
// $Id: DRand48Engine.cc,v 1.4.4.3 2008/07/17 19:00:45 garren Exp $
// $Id: DRand48Engine.cc,v 1.4.4.3.2.1 2008/11/13 21:35:23 garren Exp $
// -----------------------------------------------------------------------
// HEP Random
// --- DRand48Engine ---
......@@ -325,7 +325,7 @@ std::istream & DRand48Engine::getState ( std::istream& is )
}
bool DRand48Engine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<DRand48Engine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<DRand48Engine>()) {
std::cerr <<
"\nDRand48Engine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: DualRand.cc,v 1.3.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: DualRand.cc,v 1.3.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -330,7 +330,7 @@ std::istream & DualRand::getState ( std::istream & is ) {
}
bool DualRand::get(const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<DualRand>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<DualRand>()) {
std::cerr <<
"\nDualRand get:state vector has wrong ID word - state unchanged\n";
return false;
......
......@@ -47,7 +47,7 @@ makeAnEngine (const std::string & tag,
template<class E>
static HepRandomEngine*
makeAnEngine (const std::vector<unsigned long> & v) {
if ( v[0] != engineIDulong<E>() ) return 0;
if ( (v[0] & 0xffffffffUL) != engineIDulong<E>() ) return 0;
HepRandomEngine* eptr = new E;
bool success = eptr->getState(v);
if (!success) return 0;
......
// $Id: Hurd160Engine.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: Hurd160Engine.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -367,7 +367,7 @@ std::istream& Hurd160Engine::getState(std::istream& is) {
bool Hurd160Engine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<Hurd160Engine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<Hurd160Engine>()) {
std::cerr <<
"\nHurd160Engine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: Hurd288Engine.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: Hurd288Engine.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -385,7 +385,7 @@ std::istream& Hurd288Engine::getState(std::istream& is) {
}
bool Hurd288Engine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<Hurd288Engine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<Hurd288Engine>()) {
std::cerr <<
"\nHurd288Engine get:state vector has wrong ID word - state unchanged\n";
std::cerr << "The correct ID would be " << engineIDulong<Hurd288Engine>()
......
// $Id: JamesRandom.cc,v 1.4.4.3 2008/07/17 19:00:45 garren Exp $
// $Id: JamesRandom.cc,v 1.4.4.3.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -436,7 +436,7 @@ std::istream & HepJamesRandom::getState ( std::istream& is) {
}
bool HepJamesRandom::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<HepJamesRandom>()) {
if ( (v[0] & 0xffffffffUL) != engineIDulong<HepJamesRandom>()) {
std::cerr <<
"\nHepJamesRandom get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: MTwistEngine.cc,v 1.4.4.3 2006/11/15 17:23:01 garren Exp $
// $Id: MTwistEngine.cc,v 1.4.4.3.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -375,7 +375,7 @@ std::istream & MTwistEngine::getState ( std::istream& is )
}
bool MTwistEngine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<MTwistEngine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<MTwistEngine>()) {
std::cerr <<
"\nMTwistEngine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: NonRandomEngine.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: NonRandomEngine.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -228,7 +228,7 @@ std::istream & NonRandomEngine::getState (std::istream & is) {
}
bool NonRandomEngine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<NonRandomEngine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<NonRandomEngine>()) {
std::cerr <<
"\nNonRandomEngine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: RandEngine.cc,v 1.4.4.5 2008/07/17 19:00:45 garren Exp $
// $Id: RandEngine.cc,v 1.4.4.5.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -455,7 +455,7 @@ std::istream & RandEngine::getState ( std::istream& is )
}
bool RandEngine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<RandEngine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<RandEngine>()) {
std::cerr <<
"\nRandEngine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: RanecuEngine.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: RanecuEngine.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -400,7 +400,7 @@ std::istream & RanecuEngine::getState ( std::istream& is )
}
bool RanecuEngine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<RanecuEngine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<RanecuEngine>()) {
std::cerr <<
"\nRanecuEngine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: Ranlux64Engine.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: Ranlux64Engine.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -629,7 +629,7 @@ std::istream & Ranlux64Engine::getState ( std::istream& is )
}
bool Ranlux64Engine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<Ranlux64Engine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<Ranlux64Engine>()) {
std::cerr <<
"\nRanlux64Engine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: RanluxEngine.cc,v 1.4.4.2.2.1 2008/08/05 18:55:22 garren Exp $
// $Id: RanluxEngine.cc,v 1.4.4.2.2.2 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -660,7 +660,7 @@ std::istream & RanluxEngine::getState ( std::istream& is )
}
bool RanluxEngine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<RanluxEngine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<RanluxEngine>()) {
std::cerr <<
"\nRanluxEngine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: RanshiEngine.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: RanshiEngine.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -373,7 +373,7 @@ std::istream& RanshiEngine::getState (std::istream& is) {
}
bool RanshiEngine::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<RanshiEngine>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<RanshiEngine>()) {
std::cerr <<
"\nRanshiEngine get:state vector has wrong ID word - state unchanged\n";
return false;
......
// $Id: TripleRand.cc,v 1.4.4.2 2005/04/15 16:32:53 garren Exp $
// $Id: TripleRand.cc,v 1.4.4.2.2.1 2008/11/13 21:35:23 garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
......@@ -331,7 +331,7 @@ std::istream & TripleRand::getState (std::istream & is) {
}
bool TripleRand::get (const std::vector<unsigned long> & v) {
if (v[0] != engineIDulong<TripleRand>()) {
if ((v[0] & 0xffffffffUL) != engineIDulong<TripleRand>()) {
std::cerr <<
"\nTripleRand get:state vector has wrong ID word - state unchanged\n";
return false;
......
......@@ -24,9 +24,9 @@ static std::vector<unsigned long> gen_crc_table() {
unsigned long crc = i << 24;
for ( int j = 0; j < 8; j++ ) {
if ( crc & 0x80000000UL ) {
crc = ( crc << 1 ) ^ POLYNOMIAL;
crc = ( ( crc << 1 ) ^ POLYNOMIAL ) & 0xffffffffUL;
} else {
crc = crc << 1;
crc = ( crc << 1 ) & 0xffffffffUL;
}
}
crc_table.push_back(crc);
......@@ -40,7 +40,7 @@ unsigned long crc32ul(const std::string & s) {
int end = s.length();
for (int j = 0; j != end; ++j) {
int i = ( (int) ( crc >> 24) ^ s[j] ) & 0xff;
crc = ( crc << 8 ) ^ crc_table[i];
crc = ( ( crc << 8 ) ^ crc_table[i] ) & 0xffffffffUL;
}
return crc;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment