]> git.lyx.org Git - lyx.git/blob - boost/boost/detail/winapi.hpp
update boost
[lyx.git] / boost / boost / detail / winapi.hpp
1 #ifndef BOOST_DETAIL_WINAPI_HPP_INCLUDED
2 #define BOOST_DETAIL_WINAPI_HPP_INCLUDED
3
4 #if _MSC_VER >= 1020
5 #pragma once
6 #endif
7
8 //
9 //  boost/detail/winapi.hpp - a lightweight version of <windows.h>
10 //
11 //  Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
12 //
13 //  Permission to copy, use, modify, sell and distribute this software
14 //  is granted provided this copyright notice appears in all copies.
15 //  This software is provided "as is" without express or implied
16 //  warranty, and with no claim as to its suitability for any purpose.
17 //
18
19 namespace boost
20 {
21
22 namespace detail
23 {
24
25 namespace winapi
26 {
27
28 typedef long long_type;
29 typedef unsigned long dword_type;
30 typedef void * handle_type;
31
32 #if defined(_WIN64)
33
34 typedef __int64 int_ptr_type;
35 typedef unsigned __int64 uint_ptr_type;
36 typedef __int64 long_ptr_type;
37 typedef unsigned __int64 ulong_ptr_type;
38
39 #else
40
41 typedef int int_ptr_type;
42 typedef unsigned int uint_ptr_type;
43 typedef long long_ptr_type;
44 typedef unsigned long ulong_ptr_type;
45
46 #endif
47
48 struct critical_section
49 {
50     struct critical_section_debug * DebugInfo;
51     long_type LockCount;
52     long_type RecursionCount;
53     handle_type OwningThread;
54     handle_type LockSemaphore;
55     ulong_ptr_type SpinCount;
56 };
57
58 #if defined(_WIN64)
59
60 // Intel 6.0 on Win64 version, posted by Tim Fenders to [boost-users]
61
62 extern "C" long_type __cdecl _InterlockedIncrement(long_type volatile *);
63 extern "C" long_type __cdecl _InterlockedDecrement(long_type volatile *);
64 extern "C" long_type __cdecl _InterlockedExchange(long_type volatile *, long_type);
65
66 #pragma intrinsic(_InterlockedIncrement)
67 #pragma intrinsic(_InterlockedDecrement)
68 #pragma intrinsic(_InterlockedExchange)
69
70 inline long_type InterlockedIncrement(long_type volatile * lp)
71
72     return _InterlockedIncrement(lp);
73 }
74
75 inline long_type InterlockedDecrement(long_type volatile* lp)
76
77     return _InterlockedDecrement(lp);
78 }
79
80 inline long_type InterlockedExchange(long_type volatile* lp, long_type l)
81 {
82     return _InterlockedExchange(lp, l);
83 }
84
85 #else
86
87 extern "C" __declspec(dllimport) long_type __stdcall InterlockedIncrement(long_type volatile *);
88 extern "C" __declspec(dllimport) long_type __stdcall InterlockedDecrement(long_type volatile *);
89 extern "C" __declspec(dllimport) long_type __stdcall InterlockedExchange(long_type volatile *, long_type);
90
91 #endif
92
93 extern "C" __declspec(dllimport) void __stdcall Sleep(dword_type);
94
95 extern "C" __declspec(dllimport) void __stdcall InitializeCriticalSection(critical_section *);
96 extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(critical_section *);
97 extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(critical_section *);
98 extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(critical_section *);
99
100 } // namespace winapi
101
102 } // namespace detail
103
104 } // namespace boost
105
106 #endif // #ifndef BOOST_DETAIL_WINAPI_HPP_INCLUDED