Commit 9e3dd671 authored by Lynn Garren's avatar Lynn Garren
Browse files

Merge branch 'release/CLHEP_2_3_4_5'

parents 9bb586c9 c5e201b7
...@@ -31,7 +31,7 @@ clhep_ensure_out_of_source_build() ...@@ -31,7 +31,7 @@ clhep_ensure_out_of_source_build()
# use cmake 3.2 or later # use cmake 3.2 or later
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.2)
# Project setup # Project setup
project(CLHEP VERSION 2.3.4.4) project(CLHEP VERSION 2.3.4.5)
# - needed for (temporary) back compatibility # - needed for (temporary) back compatibility
set(VERSION ${PROJECT_VERSION}) set(VERSION ${PROJECT_VERSION})
......
==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
2017-09-18 Lynn Garren <garren@fnal.gov>
* support c++17 and c++1z (see CLHEP-144)
code contributed by Chris Green
============================== ==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
...@@ -97,8 +97,8 @@ void seed_vielbein(rng_state_t* X, unsigned int i); // seeds with the i-th unit ...@@ -97,8 +97,8 @@ void seed_vielbein(rng_state_t* X, unsigned int i); // seeds with the i-th unit
// FUNCTIONS FOR GETTING RANDOM NUMBERS // FUNCTIONS FOR GETTING RANDOM NUMBERS
#ifdef __MIXMAX_C #ifdef __MIXMAX_C
myuint get_next(rng_state_t* X); // returns 64-bit int, which is between 1 and 2^61-1 inclusive myuint clhep_get_next(rng_state_t* X); // returns 64-bit int, which is between 1 and 2^61-1 inclusive
double get_next_float(rng_state_t* X); // returns double precision floating point number in (0,1] double clhep_get_next_float(rng_state_t* X); // returns double precision floating point number in (0,1]
#endif //__MIXMAX_C #endif //__MIXMAX_C
void fill_array(rng_state_t* X, unsigned int n, double *array); // fastest method: set n to a multiple of N (e.g. n=256) void fill_array(rng_state_t* X, unsigned int n, double *array); // fastest method: set n to a multiple of N (e.g. n=256)
...@@ -166,8 +166,8 @@ void branch_inplace( rng_state_t* Xin, myID_t* ID ); // almost the same as apply ...@@ -166,8 +166,8 @@ void branch_inplace( rng_state_t* Xin, myID_t* ID ); // almost the same as apply
#ifndef __MIXMAX_C // c++ can put code into header files, why cant we? (with the inline declaration, should be safe from duplicate-symbol error) #ifndef __MIXMAX_C // c++ can put code into header files, why cant we? (with the inline declaration, should be safe from duplicate-symbol error)
#define get_next(X) GET_BY_MACRO(X) #define clhep_get_next(X) GET_BY_MACRO(X)
#define get_next_float(X) get_next_float_BY_MACRO(X) #define clhep_get_next_float(X) clhep_get_next_float_BY_MACRO(X)
#endif // __MIXMAX_C #endif // __MIXMAX_C
...@@ -186,8 +186,8 @@ inline myuint GET_BY_MACRO(rng_state_t* X) { ...@@ -186,8 +186,8 @@ inline myuint GET_BY_MACRO(rng_state_t* X) {
} }
inline double get_next_float_BY_MACRO(rng_state_t* X){ inline double clhep_get_next_float_BY_MACRO(rng_state_t* X){
int64_t Z=(int64_t)get_next(X); int64_t Z=(int64_t)clhep_get_next(X);
#if defined(__x86_64__) && defined(__SSE__) && defined(__AVX__) && defined(USE_INLINE_ASM) #if defined(__x86_64__) && defined(__SSE__) && defined(__AVX__) && defined(USE_INLINE_ASM)
double F; double F;
__asm__ __volatile__( "pxor %0, %0;" __asm__ __volatile__( "pxor %0, %0;"
...@@ -236,12 +236,12 @@ static const gsl_rng_type mixmax_type = ...@@ -236,12 +236,12 @@ static const gsl_rng_type mixmax_type =
unsigned long gsl_get_next(void *vstate) { unsigned long gsl_get_next(void *vstate) {
rng_state_t* X= (rng_state_t*)vstate; rng_state_t* X= (rng_state_t*)vstate;
return (unsigned long)get_next(X); return (unsigned long)clhep_get_next(X);
} }
double gsl_get_next_float(void *vstate) { double gsl_get_next_float(void *vstate) {
rng_state_t* X= (rng_state_t*)vstate; rng_state_t* X= (rng_state_t*)vstate;
return ( (double)get_next(X)) * INV_MERSBASE; return ( (double)clhep_get_next(X)) * INV_MERSBASE;
} }
void seed_for_gsl(void *vstate, unsigned long seed){ void seed_for_gsl(void *vstate, unsigned long seed){
......
...@@ -180,7 +180,7 @@ void MixMaxRng::setSeeds(const long* Seeds, int seedNum) ...@@ -180,7 +180,7 @@ void MixMaxRng::setSeeds(const long* Seeds, int seedNum)
double MixMaxRng::flat() double MixMaxRng::flat()
{ {
return get_next_float(fRngState); return clhep_get_next_float(fRngState);
} }
void MixMaxRng::flatArray(const int size, double* vect ) void MixMaxRng::flatArray(const int size, double* vect )
...@@ -191,8 +191,8 @@ void MixMaxRng::flatArray(const int size, double* vect ) ...@@ -191,8 +191,8 @@ void MixMaxRng::flatArray(const int size, double* vect )
MixMaxRng::operator unsigned int() MixMaxRng::operator unsigned int()
{ {
return static_cast<unsigned int>(get_next(fRngState)); return static_cast<unsigned int>(clhep_get_next(fRngState));
// get_next returns a 64-bit integer, of which the lower 61 bits // clhep_get_next returns a 64-bit integer, of which the lower 61 bits
// are random and upper 3 bits are zero // are random and upper 3 bits are zero
} }
......
...@@ -79,12 +79,12 @@ myuint iterate_raw_vec(myuint* Y, myuint sumtotOld){ ...@@ -79,12 +79,12 @@ myuint iterate_raw_vec(myuint* Y, myuint sumtotOld){
return MOD_MERSENNE(MOD_MERSENNE(sumtot) + (ovflow <<3 )); return MOD_MERSENNE(MOD_MERSENNE(sumtot) + (ovflow <<3 ));
} }
myuint get_next(rng_state_t* X) { myuint clhep_get_next(rng_state_t* X) {
return GET_BY_MACRO(X); return GET_BY_MACRO(X);
} }
double get_next_float(rng_state_t* X){ double clhep_get_next_float(rng_state_t* X){
return get_next_float_BY_MACRO(X); return clhep_get_next_float_BY_MACRO(X);
} }
void fill_array(rng_state_t* X, unsigned int n, double *array) void fill_array(rng_state_t* X, unsigned int n, double *array)
...@@ -167,7 +167,7 @@ rng_state_t* rng_copy(myuint *Y) ...@@ -167,7 +167,7 @@ rng_state_t* rng_copy(myuint *Y)
/* copy the vector stored at Y, and return pointer to the newly allocated and initialized state. /* copy the vector stored at Y, and return pointer to the newly allocated and initialized state.
It is the user's responsibility to make sure that Y is properly allocated with rng_alloc, It is the user's responsibility to make sure that Y is properly allocated with rng_alloc,
then pass Y->V or it can also be an array -- such as myuint Y[N+1] and Y[1]...Y[N] have been set to legal values [0 .. MERSBASE-1] then pass Y->V or it can also be an array -- such as myuint Y[N+1] and Y[1]...Y[N] have been set to legal values [0 .. MERSBASE-1]
Partial sums on this new state are recalculated, and counter set to zero, so that when get_next is called, Partial sums on this new state are recalculated, and counter set to zero, so that when clhep_get_next is called,
it will output the initial vector before any new numbers are produced, call iterate(X) if you want to advance right away */ it will output the initial vector before any new numbers are produced, call iterate(X) if you want to advance right away */
rng_state_t* X = rng_alloc(); rng_state_t* X = rng_alloc();
myuint sumtot=0,ovflow=0; myuint sumtot=0,ovflow=0;
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
============================== ==============================
......
==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
2017-09-18 Lynn Garren <garren@fnal.gov>
* test: remove unused test .cc files to avoid confusion
============================== ==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
......
This diff is collapsed.
// ======================================================================
//
// Test compilability and basic functionality of Utility/memory.h
//
// Author: W. E. Brown, 2010-03-19, adapted from the boost library's
// shared_ptr and related functionality whose internal attributions bear
// the following various notices:
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//
// ======================================================================
#include "CLHEP/Utility/noncopyable.h"
#include "CLHEP/Utility/memory.h"
#include <cassert>
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
using namespace CLHEP;
using CLHEP::shared_ptr;
int cnt = 0;
struct X : public noncopyable {
X() { ++cnt; }
~X() { --cnt; } // virtual destructor deliberately omitted
virtual int id() const { return 1; }
}; // X
struct Y: public X
{
Y() { ++cnt; }
~Y() { --cnt; }
virtual int id() const { return 2; }
}; // Y
int * get_object()
{ return &++cnt; }
// don't generate warnings about unused parameter inside assert
void release_object(int * p)
{
assert(p == &cnt);
--cnt;
}
template< class T >
void test_is_X(shared_ptr<T> const & p)
{
assert(p->id() == 1);
assert((*p).id() == 1);
}
template< class T >
void test_is_X(weak_ptr<T> const & p)
{
assert(p.get() != 0);
assert(p.get()->id() == 1);
}
// don't generate warnings about unused parameter inside assert
template< class T >
void test_is_Y(shared_ptr<T> const & p)
{
assert(p->id() == 2);
assert((*p).id() == 2);
}
template< class T >
void test_is_Y(weak_ptr<T> const & p)
{
shared_ptr<T> q = p.lock();
assert(q.get() != 0);
assert(q->id() == 2);
}
// don't generate warnings about unused parameter inside assert
template< class T >
void test_eq(T const & a, T const & b)
{
assert(a == b);
assert(!(a != b));
assert(!(a < b));
assert(!(b < a));
}
template< class T >
void test_ne(T const & a, T const & b)
{
assert(!(a == b));
assert(a != b);
assert(a < b || b < a);
assert(!(a < b && b < a));
}
template< class T, class U >
void test_shared(weak_ptr<T> const & a, weak_ptr<U> const & b)
{
assert(!(a < b));
assert(!(b < a));
}
template< class T, class U >
void test_nonshared(weak_ptr<T> const & a, weak_ptr<U> const & b)
{
assert(a < b || b < a);
assert(!(a < b && b < a));
}
template< class T, class U >
void test_eq2(T const & a, U const & b)
{
assert(a == b);
assert(!(a != b));
}
template< class T, class U >
void test_ne2(T const & a, U const & b)
{
assert(!(a == b));
assert(a != b);
}
template< class T >
void test_is_zero(shared_ptr<T> const & p)
{
assert(!p);
assert(p.get() == 0);
}
template< class T >
void test_is_nonzero(shared_ptr<T> const & p)
{
// p? true: false is used to test p in a boolean context.
// assert(p) is not guaranteed to test the conversion,
// as the macro might test !!p instead.
assert(p? true: false);
assert(p.get() != 0);
}
// don't generate warnings about unused variable inside assert
int main()
{
{
shared_ptr<X> p(new Y);
shared_ptr<X> p2(new X);
test_is_nonzero(p);
test_is_nonzero(p2);
test_is_Y(p);
test_is_X(p2);
test_ne(p, p2);
{
shared_ptr<X> q(p);
test_eq(p, q);
}
shared_ptr<Y> p3 = dynamic_pointer_cast<Y>(p);
shared_ptr<Y> p4 = dynamic_pointer_cast<Y>(p2);
test_is_nonzero(p3);
test_is_zero(p4);
assert(p.use_count() == 2);
assert(p2.use_count() == 1);
assert(p3.use_count() == 2);
test_is_Y(p3);
test_eq2(p, p3);
test_ne2(p2, p4);
shared_ptr<void> p5(p);
test_is_nonzero(p5);
test_eq2(p, p5);
weak_ptr<X> wp1(p2);
assert(!wp1.expired());
assert(wp1.use_count() != 0);
p.reset();
p2.reset();
p3.reset();
p4.reset();
test_is_zero(p);
test_is_zero(p2);
test_is_zero(p3);
test_is_zero(p4);
assert(p5.use_count() == 1);
assert(wp1.expired());
assert(wp1.use_count() == 0);
try
{
shared_ptr<X> sp1(wp1);
throw "shared_ptr<X> sp1(wp1) failed to throw";
}
catch(bad_weak_ptr const &)
{
}
test_is_zero(wp1.lock());
weak_ptr<X> wp2 = static_pointer_cast<X>(p5);
assert(wp2.use_count() == 1);
test_is_Y(wp2);
test_nonshared(wp1, wp2);
// Scoped to not affect the subsequent use_count() tests.
{
shared_ptr<X> sp2(wp2);
test_is_nonzero(wp2.lock());
}
weak_ptr<Y> wp3 = dynamic_pointer_cast<Y>(wp2.lock());
assert(wp3.use_count() == 1);
test_shared(wp2, wp3);
weak_ptr<X> wp4(wp3);
assert(wp4.use_count() == 1);
test_shared(wp2, wp4);
wp1 = p2;
test_is_zero(wp1.lock());
wp1 = p4;
wp1 = wp3;
wp1 = wp2;
assert(wp1.use_count() == 1);
test_shared(wp1, wp2);
weak_ptr<X> wp5;
bool b1 = wp1 < wp5;
bool b2 = wp5 < wp1;
p5.reset();
assert(wp1.use_count() == 0);
assert(wp2.use_count() == 0);
assert(wp3.use_count() == 0);
// Test operator< stability for std::set< weak_ptr<> >
// Thanks to Joe Gottman for pointing this out
assert(b1 == (wp1 < wp5));
assert(b2 == (wp5 < wp1));
{
// note that both get_object and release_object deal with int*
shared_ptr<void> p6(get_object(), release_object);
}
}
assert(cnt == 0);
return 0;
} // main()
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
#pragma GCC diagnostic pop
#elif __clang__
#pragma clang diagnostic pop
#endif
This diff is collapsed.
============================== ==============================
18.09.17 Release CLHEP-2.3.4.5
==============================
==============================
21.03.17 Release CLHEP-2.3.4.4 21.03.17 Release CLHEP-2.3.4.4
============================== ==============================
......
...@@ -184,6 +184,66 @@ macro( _clhep_verify_cxx14 ) ...@@ -184,6 +184,66 @@ macro( _clhep_verify_cxx14 )
endif() endif()
endmacro( _clhep_verify_cxx14 ) endmacro( _clhep_verify_cxx14 )
macro( _clhep_verify_cxx1z )
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0 )
message( FATAL_ERROR "c++1z extension is not available for ${CMAKE_CXX_COMPILER_ID}${CMAKE_CXX_COMPILER_VERSION}")
else()
set( HAVE_STDCXX true )
endif()
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0 )
message( FATAL_ERROR "c++1z extension is not available for ${CMAKE_CXX_COMPILER_ID}${CMAKE_CXX_COMPILER_VERSION}")
else()
set( HAVE_STDCXX true )
endif()
elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel" )
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
message( FATAL_ERROR "c++1z extension is not available for ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
else()
set( HAVE_STDCXX true )
endif()
elseif(CMAKE_COMPILER_IS_GNUCXX)
if( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 )
message( FATAL_ERROR "c++1z extension is not available for ${CMAKE_CXX_COMPILER}")
else()
set( HAVE_STDCXX true )
endif()
else()