PageRenderTime 231ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 215ms

/Src/Dependencies/Boost/boost/asio/detail/impl/win_tss_ptr.ipp

http://hadesmem.googlecode.com/
C++ Header | 59 lines | 37 code | 13 blank | 9 comment | 3 complexity | 43675fed4eaecc94a36798e2e7ae95ab MD5 | raw file
 1//
 2// detail/impl/win_tss_ptr.ipp
 3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4//
 5// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 6//
 7// Distributed under the Boost Software License, Version 1.0. (See accompanying
 8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 9//
10
11#ifndef BOOST_ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP
12#define BOOST_ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19
20#if defined(BOOST_WINDOWS)
21
22#include <boost/asio/detail/throw_error.hpp>
23#include <boost/asio/detail/win_tss_ptr.hpp>
24#include <boost/asio/error.hpp>
25
26#include <boost/asio/detail/push_options.hpp>
27
28namespace boost {
29namespace asio {
30namespace detail {
31
32DWORD win_tss_ptr_create()
33{
34#if defined(UNDER_CE)
35  enum { out_of_indexes = 0xFFFFFFFF };
36#else
37  enum { out_of_indexes = TLS_OUT_OF_INDEXES };
38#endif
39
40  DWORD tss_key = ::TlsAlloc();
41  if (tss_key == out_of_indexes)
42  {
43    DWORD last_error = ::GetLastError();
44    boost::system::error_code ec(last_error,
45        boost::asio::error::get_system_category());
46    boost::asio::detail::throw_error(ec, "tss");
47  }
48  return tss_key;
49}
50
51} // namespace detail
52} // namespace asio
53} // namespace boost
54
55#include <boost/asio/detail/pop_options.hpp>
56
57#endif // defined(BOOST_WINDOWS)
58
59#endif // BOOST_ASIO_DETAIL_IMPL_WIN_TSS_PTR_IPP