Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:44:34

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_DETAIL_GLOBAL_STATIC_HPP
0012 #define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC_HPP
0013 
0014 #include <boost/compute/config.hpp>
0015 
0016 #ifdef BOOST_COMPUTE_THREAD_SAFE
0017 #  ifdef BOOST_COMPUTE_HAVE_THREAD_LOCAL
0018      // use c++11 thread local storage
0019 #    define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(type, name, ctor) \
0020        thread_local type name ctor;
0021 #  else
0022       // use thread_specific_ptr from boost.thread
0023 #     include <boost/thread/tss.hpp>
0024 #     define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(type, name, ctor) \
0025         static ::boost::thread_specific_ptr< type > BOOST_PP_CAT(name, _tls_ptr_); \
0026         if(!BOOST_PP_CAT(name, _tls_ptr_).get()){ \
0027             BOOST_PP_CAT(name, _tls_ptr_).reset(new type ctor); \
0028         } \
0029         static type &name = *BOOST_PP_CAT(name, _tls_ptr_);
0030 #  endif
0031 #else
0032    // no thread-safety, just use static
0033 #  define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(type, name, ctor) \
0034      static type name ctor;
0035 #endif
0036 
0037 #endif // BOOST_COMPUTE_DETAIL_GLOBAL_STATIC_HPP