Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
CLHEP
CLHEP
Commits
f804e982
Commit
f804e982
authored
Jul 17, 2008
by
Lynn Garren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes for gcc 4.3 and VC8/9
parent
f27b20ea
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
83 additions
and
88 deletions
+83
-88
ChangeLog
ChangeLog
+12
-0
Evaluator/ChangeLog
Evaluator/ChangeLog
+5
-0
Evaluator/src/Evaluator.cc
Evaluator/src/Evaluator.cc
+17
-9
Random/ChangeLog
Random/ChangeLog
+20
-0
Random/src/DRand48Engine.cc
Random/src/DRand48Engine.cc
+1
-24
Random/src/JamesRandom.cc
Random/src/JamesRandom.cc
+3
-3
Random/src/RandEngine.cc
Random/src/RandEngine.cc
+6
-27
Random/src/drand48.src
Random/src/drand48.src
+8
-18
Random/test/testAnonymousEngineRestore.cc
Random/test/testAnonymousEngineRestore.cc
+4
-2
Random/test/testRandDists.cc
Random/test/testRandDists.cc
+4
-3
Random/test/testRandom.cc
Random/test/testRandom.cc
+2
-1
Random/test/testStaticStreamSave.cc
Random/test/testStaticStreamSave.cc
+1
-1
No files found.
ChangeLog
View file @
f804e982
2008-07-17 Lynn Garren <garren@fnal.gov>
* various changes in Random to keep gcc 4.3 happy
2008-07-16 Lynn Garren <garren@fnal.gov>
* Matrix/src/SymMatrix.cc, Matrix.cc, DiagMatrix.cc, MatrixLinear.cc:
Iterators were set to a nonexistent memory location in many places.
Even though the iterators were not used, this operation is not allowed
and causes problems with the newer VC++ compilers.
In some cases, a more efficient rewrite was possible.
==============================
01.05.08 Release CLHEP-2.0.3.3
==============================
...
...
Evaluator/ChangeLog
View file @
f804e982
2008-07-16 Lynn Garren <garren@fnal.gov>
* src/Evaluator.cc: Fix non ISO C++ compliant cast from pointer to
function to void*, which is a pointer to an object.
==============================
01.05.08 Release CLHEP-2.0.3.3
==============================
...
...
Evaluator/src/Evaluator.cc
View file @
f804e982
// -*- C++ -*-
// $Id: Evaluator.cc,v 1.2 200
3
/0
8
/1
3 20
:00:
10
garren Exp $
// $Id: Evaluator.cc,v 1.2
.4.1
200
8
/0
7
/1
7 19
:00:
45
garren Exp $
// ---------------------------------------------------------------------------
#include "CLHEP/Evaluator/defs.h"
...
...
@@ -16,16 +16,22 @@
#include <stdlib.h> // for strtod()
//---------------------------------------------------------------------------
// Fix non ISO C++ compliant cast from pointer to function
// to void*, which is a pointer to an object
typedef
void
(
*
voidfuncptr
)();
struct
Item
{
enum
{
UNKNOWN
,
VARIABLE
,
EXPRESSION
,
FUNCTION
}
what
;
double
variable
;
string
expression
;
void
*
function
;
// Fix non ISO C++ compliant cast from pointer to function
// to void*, which is a pointer to an object
//void *function;
voidfuncptr
function
;
Item
()
:
what
(
UNKNOWN
),
variable
(
0
),
expression
(),
function
(
0
)
{}
Item
(
double
x
)
:
what
(
VARIABLE
),
variable
(
x
),
expression
(),
function
(
0
)
{}
Item
(
string
x
)
:
what
(
EXPRESSION
),
variable
(
0
),
expression
(
x
),
function
(
0
)
{}
Item
(
void
*
x
)
:
what
(
FUNCTION
),
variable
(
0
),
expression
(),
function
(
x
)
{}
Item
(
void
funcptr
x
)
:
what
(
FUNCTION
),
variable
(
0
),
expression
(),
function
(
x
)
{}
};
typedef
char
*
pchar
;
...
...
@@ -646,29 +652,31 @@ void Evaluator::setVariable(const char * name, const char * expression)
{
setItem
(
""
,
name
,
Item
(
expression
),
(
Struct
*
)
p
);
}
//---------------------------------------------------------------------------
// Fix non ISO C++ compliant cast from pointer to function
// to void*, which is a pointer to an object
void
Evaluator
::
setFunction
(
const
char
*
name
,
double
(
*
fun
)())
{
setItem
(
"0"
,
name
,
Item
(
(
void
*
)
fun
),
(
Struct
*
)
p
);
}
{
setItem
(
"0"
,
name
,
Item
(
reinterpret_cast
<
voidfuncptr
>
(
fun
)
)
,
(
Struct
*
)
p
);
}
void
Evaluator
::
setFunction
(
const
char
*
name
,
double
(
*
fun
)(
double
))
{
setItem
(
"1"
,
name
,
Item
(
(
void
*
)
fun
),
(
Struct
*
)
p
);
}
{
setItem
(
"1"
,
name
,
Item
(
reinterpret_cast
<
voidfuncptr
>
(
fun
)
)
,
(
Struct
*
)
p
);
}
void
Evaluator
::
setFunction
(
const
char
*
name
,
double
(
*
fun
)(
double
,
double
))
{
setItem
(
"2"
,
name
,
Item
(
(
void
*
)
fun
),
(
Struct
*
)
p
);
}
{
setItem
(
"2"
,
name
,
Item
(
reinterpret_cast
<
voidfuncptr
>
(
fun
)
)
,
(
Struct
*
)
p
);
}
void
Evaluator
::
setFunction
(
const
char
*
name
,
double
(
*
fun
)(
double
,
double
,
double
))
{
setItem
(
"3"
,
name
,
Item
(
(
void
*
)
fun
),
(
Struct
*
)
p
);
}
{
setItem
(
"3"
,
name
,
Item
(
reinterpret_cast
<
voidfuncptr
>
(
fun
)
)
,
(
Struct
*
)
p
);
}
void
Evaluator
::
setFunction
(
const
char
*
name
,
double
(
*
fun
)(
double
,
double
,
double
,
double
))
{
setItem
(
"4"
,
name
,
Item
(
(
void
*
)
fun
),
(
Struct
*
)
p
);
}
{
setItem
(
"4"
,
name
,
Item
(
reinterpret_cast
<
voidfuncptr
>
(
fun
)
)
,
(
Struct
*
)
p
);
}
void
Evaluator
::
setFunction
(
const
char
*
name
,
double
(
*
fun
)(
double
,
double
,
double
,
double
,
double
))
{
setItem
(
"5"
,
name
,
Item
(
(
void
*
)
fun
),
(
Struct
*
)
p
);
}
{
setItem
(
"5"
,
name
,
Item
(
reinterpret_cast
<
voidfuncptr
>
(
fun
)
)
,
(
Struct
*
)
p
);
}
//---------------------------------------------------------------------------
bool
Evaluator
::
findVariable
(
const
char
*
name
)
const
{
...
...
Random/ChangeLog
View file @
f804e982
2008-07-17 Lynn Garren <garren@fnal.gov>
* add explicit parentheses in various places to keep gcc 4.3 happy
* src/RandEngine.cc: change how the compiler decides how to implement flat()
* test/testRandDists.cc: force variables to be in memory so
testRandGeneral() behaves the same with both gcc 4.3 and 3.4.
* Random/src/DRand48Engine.cc,RandEngine.cc:
Remove (incorrect) implementation of private, unused, copy constructor
and operator=.
* Random/src/drand48.src:
The implementaton of the drand48_iterate method contained a problematic
"if (sizeof (unsigned short int) == 2) { } else {}" structure.
Code contained in the else portion had unintended side effects.
We have retained only the code in the if portion, which should work
on all machines.
==============================
01.05.08 Release CLHEP-2.0.3.3
==============================
...
...
Random/src/DRand48Engine.cc
View file @
f804e982
// -*- C++ -*-
// $Id: DRand48Engine.cc,v 1.4.4.
2
200
5
/0
4
/1
5
1
6:32:53
garren Exp $
// $Id: DRand48Engine.cc,v 1.4.4.
3
200
8
/0
7
/1
7
1
9:00:45
garren Exp $
// -----------------------------------------------------------------------
// HEP Random
// --- DRand48Engine ---
...
...
@@ -94,29 +94,6 @@ DRand48Engine::DRand48Engine(std::istream& is)
DRand48Engine
::~
DRand48Engine
()
{}
DRand48Engine
::
DRand48Engine
(
const
DRand48Engine
&
p
)
{
// Assignment and copy of DRand48Engine objects may provoke
// undesired behavior in a single thread environment.
std
::
cerr
<<
"!!! WARNING !!! - Illegal operation."
<<
std
::
endl
;
std
::
cerr
<<
"- Copy constructor and operator= are NOT allowed on "
<<
"DRand48Engine objects -"
<<
std
::
endl
;
*
this
=
p
;
}
DRand48Engine
&
DRand48Engine
::
operator
=
(
const
DRand48Engine
&
p
)
{
// Assignment and copy of DRand48Engine objects may provoke
// undesired behavior in a single thread environment.
std
::
cerr
<<
"!!! WARNING !!! - Illegal operation."
<<
std
::
endl
;
std
::
cerr
<<
"- Copy constructor and operator= are NOT allowed on "
<<
"DRand48Engine objects -"
<<
std
::
endl
;
*
this
=
p
;
return
*
this
;
}
void
DRand48Engine
::
setSeed
(
long
seed
,
int
)
{
srand48
(
seed
);
...
...
Random/src/JamesRandom.cc
View file @
f804e982
// $Id: JamesRandom.cc,v 1.4.4.
2
200
5
/0
4
/1
5
1
6:32:53
garren Exp $
// $Id: JamesRandom.cc,v 1.4.4.
3
200
8
/0
7
/1
7
1
9:00:45
garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
...
...
@@ -320,8 +320,8 @@ void HepJamesRandom::flatArray(const int size, double* vect)
}
HepJamesRandom
::
operator
unsigned
int
()
{
return
(
unsigned
int
)(
flat
()
*
exponent_bit_32
)
&
0xffffffff
|
((
unsigned
int
)(
u
[
i97
]
*
exponent_bit_32
)
>>
16
)
&
0xff
;
return
(
(
unsigned
int
)(
flat
()
*
exponent_bit_32
)
&
0xffffffff
)
|
((
(
unsigned
int
)(
u
[
i97
]
*
exponent_bit_32
)
>>
16
)
&
0xff
)
;
}
std
::
ostream
&
HepJamesRandom
::
put
(
std
::
ostream
&
os
)
const
{
...
...
Random/src/RandEngine.cc
View file @
f804e982
// $Id: RandEngine.cc,v 1.4.4.
4
200
5
/0
4
/1
5
1
6:32:53
garren Exp $
// $Id: RandEngine.cc,v 1.4.4.
5
200
8
/0
7
/1
7
1
9:00:45
garren Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
...
...
@@ -124,30 +124,6 @@ RandEngine::RandEngine(std::istream& is)
RandEngine
::~
RandEngine
()
{}
RandEngine
::
RandEngine
(
const
RandEngine
&
p
)
:
mantissa_bit_32
(
pow
(
0.5
,
32.
)
)
{
// Assignment and copy of RandEngine objects may provoke
// undesired behavior in a single thread environment.
std
::
cerr
<<
"!!! WARNING !!! - Illegal operation."
<<
std
::
endl
;
std
::
cerr
<<
"- Copy constructor and operator= are NOT allowed on "
<<
"RandEngine objects -"
<<
std
::
endl
;
*
this
=
p
;
}
RandEngine
&
RandEngine
::
operator
=
(
const
RandEngine
&
p
)
{
// Assignment and copy of RandEngine objects may provoke
// undesired behavior in a single thread environment.
std
::
cerr
<<
"!!! WARNING !!! - Illegal operation."
<<
std
::
endl
;
std
::
cerr
<<
"- Copy constructor and operator= are NOT allowed on "
<<
"RandEngine objects -"
<<
std
::
endl
;
*
this
=
p
;
return
*
this
;
}
void
RandEngine
::
setSeed
(
long
seed
,
int
)
{
theSeed
=
seed
;
...
...
@@ -281,8 +257,11 @@ void RandEngine::showStatus() const
iS
=
RAND_MAX
+
1
;
iK
=
1
;
// int StoK = S;
int
StoK
=
iS
;
if
(
(
RAND_MAX
>>
32
)
==
0
)
{
int
StoK
=
iS
;
// The two statements below are equivalent, but some compilers
// are getting too smart and complain about the first statement.
//if ( (RAND_MAX >> 32) == 0) {
if
(
(
unsigned
long
)
(
RAND_MAX
)
<=
((
(
1uL
)
<<
31
)
-
1
)
)
{
iK
=
2
;
// StoK = S*S;
StoK
=
iS
*
iS
;
...
...
Random/src/drand48.src
View file @
f804e982
// -*- C++ -*-
// $Id: drand48.src,v 1.1.1.1.4.
1
200
4
/0
4/29 00:20:37
garren Exp $
// $Id: drand48.src,v 1.1.1.1.4.
2
200
8
/0
7/17 19:00:45
garren Exp $
// ---------------------------------------------------------------------------
//
// This code is based on a code extracted from GNU C Library 2.1.3 with
...
...
@@ -145,25 +145,15 @@ int drand48_iterate (unsigned short int xsubi[3], drand48_data *buffer)
48 bits. Because we compute the modulus it does not care how
many bits really are computed. */
if (sizeof (unsigned short int) == 2) {
X = (u_int64_t)xsubi[2] << 32 | (u_int64_t)xsubi[1] << 16 | xsubi[0];
a = ((u_int64_t)buffer->a[2] << 32 | (u_int64_t)buffer->a[1] << 16
| buffer->a[0]);
X = (u_int64_t)xsubi[2] << 32 | (u_int64_t)xsubi[1] << 16 | xsubi[0];
a = ((u_int64_t)buffer->a[2] << 32 | (u_int64_t)buffer->a[1] << 16
| buffer->a[0]);
result = X * a + buffer->c;
result = X * a + buffer->c;
xsubi[0] = result & 0xffff;
xsubi[1] = (result >> 16) & 0xffff;
xsubi[2] = (result >> 32) & 0xffff;
}else{
X = (u_int64_t)xsubi[2] << 16 | xsubi[1] >> 16;
a = (u_int64_t)buffer->a[2] << 16 | buffer->a[1] >> 16;
result = X * a + buffer->c;
xsubi[0] = result >> 16 & 0xffffffffl;
xsubi[1] = result << 16 & 0xffff0000l;
}
xsubi[0] = result & 0xffff;
xsubi[1] = (result >> 16) & 0xffff;
xsubi[2] = (result >> 32) & 0xffff;
return 0;
}
...
...
Random/test/testAnonymousEngineRestore.cc
View file @
f804e982
...
...
@@ -26,6 +26,8 @@
using
namespace
CLHEP
;
template
<
class
E1
,
class
E2
>
int
anonymousRestoreStatics
();
// Absolutely Safe Equals Without Registers Screwing Us Up
bool
equals01
(
const
std
::
vector
<
double
>
&
ab
)
{
...
...
@@ -214,7 +216,7 @@ int anonymousRestoreStatics1() {
stat
|=
131072
;
}
}
if
(
stat
&
131072
==
0
)
{
if
(
(
stat
&
131072
)
==
0
)
{
output
<<
"All captured output agrees with earlier values
\n
"
;
}
return
stat
;
...
...
@@ -274,7 +276,7 @@ int anonymousRestoreStatics() {
stat
|=
524288
;
}
}
if
(
stat
&
524288
==
0
)
{
if
(
(
stat
&
524288
)
==
0
)
{
output
<<
"All captured output agrees with earlier values
\n
"
;
}
double
k1
=
e2
->
flat
();
...
...
Random/test/testRandDists.cc
View file @
f804e982
// -*- C++ -*-
// $Id: testRandDists.cc,v 1.5.4.
2
200
5
/0
4
/1
5
1
6:32:53
garren Exp $
// $Id: testRandDists.cc,v 1.5.4.
3
200
8
/0
7
/1
7
1
9:00:45
garren Exp $
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
...
...
@@ -203,8 +203,9 @@ bool gaussianTest ( HepRandom & dist, double mu,
ncounts
[
ciu
]
=
0
;
}
double
x
;
double
u
;
// hack so that gcc 4.3 puts x and u into memory instead of a register
volatile
double
x
;
volatile
double
u
;
int
ipr
=
nNumbers
/
10
+
1
;
for
(
int
ifire
=
0
;
ifire
<
nNumbers
;
ifire
++
)
{
x
=
dist
();
// We avoid fire() because that is not virtual
...
...
Random/test/testRandom.cc
View file @
f804e982
// -*- C++ -*-
// $Id: testRandom.cc,v 1.1 200
3
/07/17 19:
2
0:
29
garren Exp $
// $Id: testRandom.cc,v 1.1
.4.1
200
8
/07/17 19:
0
0:
45
garren Exp $
// ----------------------------------------------------------------------
#include "CLHEP/Random/Randomize.h"
#include <iostream>
#include <cstdlib> // for exit()
using
std
::
cout
;
using
std
::
endl
;
...
...
Random/test/testStaticStreamSave.cc
View file @
f804e982
...
...
@@ -360,7 +360,7 @@ int main() {
stat
|=
131072
;
}
}
if
(
stat
&
131072
==
0
)
{
if
(
(
stat
&
131072
)
==
0
)
{
output
<<
"All captured output agrees with earlier values
\n
"
;
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment