Changeset 3591
- Timestamp:
- Jan 20, 2017, 3:19:49 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r3581 r3591 95 95 # if CXX11 is wanted look for rvalue support 96 96 yat_have_rvalue=no 97 yat_have_atomic=no 97 98 AS_VAR_IF([with_cxx11], [no], [], [ 98 99 YAT_CXX_RVALUE([yat_have_rvalue=yes 99 100 AC_DEFINE([YAT_HAVE_RVALUE], [1], 100 101 [Define if compiler support rvalues])]) 102 YAT_CXX_ATOMIC([yat_have_atomic=yes 103 AC_DEFINE([YAT_HAVE_ATOMIC], [1], 104 [Define if compiler support std::atomic])]) 101 105 ]) 102 106 … … 655 659 With Bam Support: $with_htslib 656 660 With Rvalue Support: $yat_have_rvalue 661 With atomic Support: $yat_have_atomic 657 662 658 663 Options used to compile and link: -
trunk/m4/yat_cxx11.m4
r3590 r3591 7 7 # SYNOPSIS 8 8 # 9 # YAT_CXX_ATOMIC([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 9 10 # YAT_CXX_RVALUE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 10 11 # … … 37 38 # 38 39 40 # YAT_CXX_ATOMIC([action-if-found], [action-if-not-found]) 41 # 42 # Test whether $CXX supports std::atomic. If not, try turning on 43 # support with a number of different switches. If a successful switch 44 # is found invoke shell action-if-found; else issue 45 # action-if-not-found. 46 AC_DEFUN([YAT_CXX_ATOMIC], 47 [ 48 YAT_CXX_TRY_CXX11([atomic], 49 [@%:@include <atomic>], 50 [std::atomic<bool> ready(false);], 51 [$1], [$2]) 52 ]) 53 54 55 # YAT_CXX_RVALUE([action-if-found], [action-if-not-found]) 56 # 57 # Test whether $CXX supports rvalue. If not, try turning on support 58 # with a number of different switches. If a successful switch is found 59 # invoke shell action-if-found; else issue action-if-not-found. 39 60 AC_DEFUN([YAT_CXX_RVALUE], 40 [AC_MSG_CHECKING([for $CXX option to enable rvalue]) 41 AC_CACHE_VAL([yat_cv_cxx_rvalue], 42 [yat_cv_cxx_rvalue=no 43 yat_cxx_rvalue_save_CXX=$CXX 61 [ 62 YAT_CXX_TRY_CXX11([rvalue], [ dnl header 63 @%:@include <utility> 64 65 class MyClass 66 { 67 public: 68 MyClass(void); 69 MyClass(const MyClass&); // copy constructor 70 MyClass(MyClass&&); // move constructor 71 MyClass& operator=(const MyClass&); // copy assignment 72 MyClass& operator=(MyClass&&); // move assignment 73 }; 74 ],[ dnl body 75 MyClass mc; 76 MyClass mc2 = std::move(mc); 77 ], [# action 78 $1 79 ], [ # action if not found 80 $2 81 ]) 82 ]) # YAT_CXX_RVALUE 83 84 # YAT_CXX_TRY_CXX11([feature], [header], [body], [action-if-found], 85 # [action-if-not-found]) 86 # 87 AC_DEFUN([YAT_CXX_TRY_CXX11], 88 [AS_VAR_PUSHDEF([my_CACHE], [yat_cv_cxx_$1])dnl 89 AC_CACHE_CHECK([for $CXX option to enable $1], 90 [my_CACHE], 91 [my_CACHE=no 92 AS_VAR_PUSHDEF([my_save_CXX], [yat_cxx_$1_save_CXX])dnl 93 my_save_CXX="$CXX" 44 94 # From autoconf 'c.m4' we have 45 95 # GCC -std=c++11 -std=c++0x … … 52 102 # but first we try with empty string, hoping compiler is modern. 53 103 for yat_arg in '' -std=c++11 -std=c++0x -qlanglvl=stdcxx11 -AA +std=c++11 "-h std=c++11" ; do 54 CXX="$yat_cxx_rvalue_save_CXX $yat_arg" 55 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([YAT_CXX_RVALUE_HEADER], 56 [YAT_CXX_RVALUE_BODY])], 57 [yat_cv_cxx_rvalue="$yat_arg"], 104 CXX="$my_save_CXX $yat_arg" 105 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$2], [$3])], 106 [my_CACHE="$yat_arg"], 58 107 []) 59 AS_ IF([test x"$yat_cv_cxx_rvalue" != x"no"], [break])108 AS_VAR_IF([my_CACHE], [no], [], [break]) 60 109 done 61 CXX="$yat_cxx_rvalue_save_CXX" 110 # restore CXX 111 CXX="$my_save_CXX" 112 113 AS_CASE([x"$my_CACHE"], 114 [x], [my_CACHE="none needed"], 115 [x"no"], [my_CACHE=unsupported]) 116 117 AS_VAR_POPDEF([my_save_CXX]) 62 118 ]) 63 119 64 AS_CASE([ x"$yat_cv_cxx_rvalue"],65 [ x], [AC_MSG_RESULT([none needed])],66 [ x"no"], [AC_MSG_RESULT([unsupported])],67 [CXX="$CXX $ yat_cv_cxx_rvalue"68 AC_MSG_RESULT([$yat_cv_cxx_rvalue])])69 AS_VAR_ IF([yat_cv_cxx_rvalue], [no], [$2], [$1])120 AS_CASE([$my_CACHE], 121 ["none needed"], [$4], 122 [unsupported], [$5], 123 [CXX="$CXX $my_CACHE" 124 $4]) 125 AS_VAR_POPDEF([my_CACHE]) 70 126 ]) 71 72 73 AC_DEFUN([YAT_CXX_RVALUE_HEADER],74 [75 @%:@include <utility>76 77 class MyClass78 {79 public:80 MyClass(void);81 MyClass(const MyClass&); // copy constructor82 MyClass(MyClass&&); // move constructor83 MyClass& operator=(const MyClass&); // copy assignment84 MyClass& operator=(MyClass&&); // move assignment85 };86 ])87 88 89 AC_DEFUN([YAT_CXX_RVALUE_BODY],90 [91 MyClass mc;92 MyClass mc2 = std::move(mc);93 ]) -
trunk/yat/random/random.cc
r3579 r3591 30 30 31 31 #include <cassert> 32 #include <cstddef> 32 33 #include <cstring> 33 34 #include <fstream> … … 38 39 namespace random { 39 40 41 #ifdef YAT_HAVE_ATOMIC 42 std::atomic<RNG*> RNG::instance_ { nullptr }; 43 #else 40 44 RNG* RNG::instance_=NULL; 45 #endif 41 46 boost::mutex RNG::init_mutex_; 42 47 -
trunk/yat/random/random.h
r3579 r3591 24 24 */ 25 25 26 #include "yat/utility/config_public.h" 27 26 28 #include "yat/statistics/Histogram.h" 27 29 #include "yat/utility/deprecate.h" … … 39 41 40 42 #include <algorithm> 43 #ifdef YAT_HAVE_ATOMIC 44 #include <atomic> 45 #endif 41 46 #include <string> 42 47 #include <vector> … … 193 198 void rng_alloc(void) const; 194 199 200 #ifdef YAT_HAVE_ATOMIC 201 static std::atomic<RNG*> instance_; 202 #else 195 203 static RNG* instance_; 204 #endif 196 205 // holds one gsl_rng per thread. Access through rng(void) so a 197 206 // gsl_rng is allocated if necessary. -
trunk/yat/utility/config_public.h.in
r3581 r3591 58 58 /// Don't turn on cxx11 features if user explicitely turned off cxx11. 59 59 #ifndef YAT_WITHOUT_CXX11 60 /// Define if compiler support rvalues */60 /// Define if compiler supports rvalues */ 61 61 #undef YAT_HAVE_RVALUE 62 /// Define if compiler supports atomic */ 63 #undef YAT_HAVE_ATOMIC 62 64 #endif 63 65
Note: See TracChangeset
for help on using the changeset viewer.