Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / detail / impl / winsock_init.ipp @ 2486

History | View | Annotate | Download (2 kB)

1 2486 sjacqu01
//
2 2486 sjacqu01
// detail/impl/winsock_init.ipp
3 2486 sjacqu01
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 2486 sjacqu01
//
5 2486 sjacqu01
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 2486 sjacqu01
//
7 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8 2486 sjacqu01
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 2486 sjacqu01
//
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_ASIO_DETAIL_IMPL_WINSOCK_INIT_IPP
12 2486 sjacqu01
#define BOOST_ASIO_DETAIL_IMPL_WINSOCK_INIT_IPP
13 2486 sjacqu01
14 2486 sjacqu01
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 2486 sjacqu01
# pragma once
16 2486 sjacqu01
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 2486 sjacqu01
18 2486 sjacqu01
#include <boost/asio/detail/config.hpp>
19 2486 sjacqu01
20 2486 sjacqu01
#if defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
21 2486 sjacqu01
22 2486 sjacqu01
#include <boost/asio/detail/socket_types.hpp>
23 2486 sjacqu01
#include <boost/asio/detail/winsock_init.hpp>
24 2486 sjacqu01
#include <boost/asio/detail/throw_error.hpp>
25 2486 sjacqu01
#include <boost/asio/error.hpp>
26 2486 sjacqu01
27 2486 sjacqu01
#include <boost/asio/detail/push_options.hpp>
28 2486 sjacqu01
29 2486 sjacqu01
namespace boost {
30 2486 sjacqu01
namespace asio {
31 2486 sjacqu01
namespace detail {
32 2486 sjacqu01
33 2486 sjacqu01
void winsock_init_base::startup(data& d,
34 2486 sjacqu01
    unsigned char major, unsigned char minor)
35 2486 sjacqu01
{
36 2486 sjacqu01
  if (::InterlockedIncrement(&d.init_count_) == 1)
37 2486 sjacqu01
  {
38 2486 sjacqu01
    WSADATA wsa_data;
39 2486 sjacqu01
    long result = ::WSAStartup(MAKEWORD(major, minor), &wsa_data);
40 2486 sjacqu01
    ::InterlockedExchange(&d.result_, result);
41 2486 sjacqu01
  }
42 2486 sjacqu01
}
43 2486 sjacqu01
44 2486 sjacqu01
void winsock_init_base::manual_startup(data& d)
45 2486 sjacqu01
{
46 2486 sjacqu01
  if (::InterlockedIncrement(&d.init_count_) == 1)
47 2486 sjacqu01
  {
48 2486 sjacqu01
    ::InterlockedExchange(&d.result_, 0);
49 2486 sjacqu01
  }
50 2486 sjacqu01
}
51 2486 sjacqu01
52 2486 sjacqu01
void winsock_init_base::cleanup(data& d)
53 2486 sjacqu01
{
54 2486 sjacqu01
  if (::InterlockedDecrement(&d.init_count_) == 0)
55 2486 sjacqu01
  {
56 2486 sjacqu01
    ::WSACleanup();
57 2486 sjacqu01
  }
58 2486 sjacqu01
}
59 2486 sjacqu01
60 2486 sjacqu01
void winsock_init_base::manual_cleanup(data& d)
61 2486 sjacqu01
{
62 2486 sjacqu01
  ::InterlockedDecrement(&d.init_count_);
63 2486 sjacqu01
}
64 2486 sjacqu01
65 2486 sjacqu01
void winsock_init_base::throw_on_error(data& d)
66 2486 sjacqu01
{
67 2486 sjacqu01
  long result = ::InterlockedExchangeAdd(&d.result_, 0);
68 2486 sjacqu01
  if (result != 0)
69 2486 sjacqu01
  {
70 2486 sjacqu01
    boost::system::error_code ec(result,
71 2486 sjacqu01
        boost::asio::error::get_system_category());
72 2486 sjacqu01
    boost::asio::detail::throw_error(ec, "winsock");
73 2486 sjacqu01
  }
74 2486 sjacqu01
}
75 2486 sjacqu01
76 2486 sjacqu01
} // namespace detail
77 2486 sjacqu01
} // namespace asio
78 2486 sjacqu01
} // namespace boost
79 2486 sjacqu01
80 2486 sjacqu01
#include <boost/asio/detail/pop_options.hpp>
81 2486 sjacqu01
82 2486 sjacqu01
#endif // defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
83 2486 sjacqu01
84 2486 sjacqu01
#endif // BOOST_ASIO_DETAIL_IMPL_WINSOCK_INIT_IPP