]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/detail/global_static.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / detail / global_static.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #ifndef BOOST_COMPUTE_DETAIL_GLOBAL_STATIC_HPP
12 #define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC_HPP
13
14 #include <boost/compute/config.hpp>
15
16 #ifdef BOOST_COMPUTE_THREAD_SAFE
17 # ifdef BOOST_COMPUTE_HAVE_THREAD_LOCAL
18 // use c++11 thread local storage
19 # define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(type, name, ctor) \
20 thread_local type name ctor;
21 # else
22 // use thread_specific_ptr from boost.thread
23 # include <boost/thread/tss.hpp>
24 # define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(type, name, ctor) \
25 static ::boost::thread_specific_ptr< type > BOOST_PP_CAT(name, _tls_ptr_); \
26 if(!BOOST_PP_CAT(name, _tls_ptr_).get()){ \
27 BOOST_PP_CAT(name, _tls_ptr_).reset(new type ctor); \
28 } \
29 static type &name = *BOOST_PP_CAT(name, _tls_ptr_);
30 # endif
31 #else
32 // no thread-safety, just use static
33 # define BOOST_COMPUTE_DETAIL_GLOBAL_STATIC(type, name, ctor) \
34 static type name ctor;
35 #endif
36
37 #endif // BOOST_COMPUTE_DETAIL_GLOBAL_STATIC_HPP