]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/smart_ptr/detail/lwm_win32_cs.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / smart_ptr / detail / lwm_win32_cs.hpp
CommitLineData
7c673cae
FG
1#ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
2#define BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED
3
4// MS compatible compilers support #pragma once
5
6#if defined(_MSC_VER) && (_MSC_VER >= 1020)
7# pragma once
8#endif
9
10//
11// boost/detail/lwm_win32_cs.hpp
12//
13// Copyright (c) 2002, 2003 Peter Dimov
7c673cae
FG
14//
15// Distributed under the Boost Software License, Version 1.0. (See
16// accompanying file LICENSE_1_0.txt or copy at
17// http://www.boost.org/LICENSE_1_0.txt)
18//
19
7c673cae 20#ifdef BOOST_USE_WINDOWS_H
b32b8144
FG
21
22#include <windows.h>
23
24#else
25
26struct _RTL_CRITICAL_SECTION;
27
7c673cae
FG
28#endif
29
30namespace boost
31{
32
33namespace detail
34{
35
36#ifndef BOOST_USE_WINDOWS_H
37
38struct critical_section
39{
40 struct critical_section_debug * DebugInfo;
41 long LockCount;
42 long RecursionCount;
43 void * OwningThread;
44 void * LockSemaphore;
45#if defined(_WIN64)
46 unsigned __int64 SpinCount;
47#else
48 unsigned long SpinCount;
49#endif
50};
51
b32b8144 52extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(::_RTL_CRITICAL_SECTION *);
b32b8144
FG
53extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRITICAL_SECTION *);
54extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *);
55extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *);
7c673cae 56
92f5a8d4
TL
57typedef ::_RTL_CRITICAL_SECTION rtl_critical_section;
58
59#else // #ifndef BOOST_USE_WINDOWS_H
7c673cae
FG
60
61typedef ::CRITICAL_SECTION critical_section;
62
b32b8144 63using ::InitializeCriticalSection;
b32b8144
FG
64using ::EnterCriticalSection;
65using ::LeaveCriticalSection;
66using ::DeleteCriticalSection;
67
92f5a8d4
TL
68typedef ::CRITICAL_SECTION rtl_critical_section;
69
7c673cae
FG
70#endif // #ifndef BOOST_USE_WINDOWS_H
71
72class lightweight_mutex
73{
74private:
75
76 critical_section cs_;
77
78 lightweight_mutex(lightweight_mutex const &);
79 lightweight_mutex & operator=(lightweight_mutex const &);
80
81public:
82
83 lightweight_mutex()
84 {
92f5a8d4 85 boost::detail::InitializeCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
7c673cae
FG
86 }
87
88 ~lightweight_mutex()
89 {
92f5a8d4 90 boost::detail::DeleteCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
7c673cae
FG
91 }
92
93 class scoped_lock;
94 friend class scoped_lock;
95
96 class scoped_lock
97 {
98 private:
99
100 lightweight_mutex & m_;
101
102 scoped_lock(scoped_lock const &);
103 scoped_lock & operator=(scoped_lock const &);
104
105 public:
106
107 explicit scoped_lock(lightweight_mutex & m): m_(m)
108 {
92f5a8d4 109 boost::detail::EnterCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
7c673cae
FG
110 }
111
112 ~scoped_lock()
113 {
92f5a8d4 114 boost::detail::LeaveCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
7c673cae
FG
115 }
116 };
117};
118
119} // namespace detail
120
121} // namespace boost
122
123#endif // #ifndef BOOST_SMART_PTR_DETAIL_LWM_WIN32_CS_HPP_INCLUDED