1 | /* $Id: vboxsharedrc.h 46521 2013-06-13 10:44:58Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox extension to Wine D3D - shared resource
|
---|
5 | *
|
---|
6 | * Copyright (C) 2010 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 | #ifndef ___vboxsharedrc_h___
|
---|
17 | #define ___vboxsharedrc_h___
|
---|
18 |
|
---|
19 | #define VBOXSHRC_F_SHARED 0x00000001 /* shared rc */
|
---|
20 | #define VBOXSHRC_F_SHARED_OPENED 0x00000002 /* if set shared rc is opened, otherwise it is created */
|
---|
21 |
|
---|
22 | #define VBOXSHRC_GET_SHAREFLAFS(_o) ((_o)->resource.sharerc_flags)
|
---|
23 | #define VBOXSHRC_GET_SHAREHANDLE(_o) ((HANDLE)(_o)->resource.sharerc_handle)
|
---|
24 | #define VBOXSHRC_SET_SHAREHANDLE(_o, _h) ((_o)->resource.sharerc_handle = (DWORD)(_h))
|
---|
25 | #define VBOXSHRC_COPY_SHAREDATA(_oDst, _oSrc) do { \
|
---|
26 | VBOXSHRC_GET_SHAREFLAFS(_oDst) = VBOXSHRC_GET_SHAREFLAFS(_oSrc); \
|
---|
27 | VBOXSHRC_SET_SHAREHANDLE(_oDst, VBOXSHRC_GET_SHAREHANDLE(_oSrc)); \
|
---|
28 | } while (0)
|
---|
29 | #define VBOXSHRC_SET_SHARED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED)
|
---|
30 | #define VBOXSHRC_SET_SHARED_OPENED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED_OPENED)
|
---|
31 |
|
---|
32 | #define VBOXSHRC_IS_SHARED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED))
|
---|
33 | #define VBOXSHRC_IS_SHARED_OPENED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED_OPENED))
|
---|
34 | #define VBOXSHRC_IS_SHARED_UNLOCKED(_o) (VBOXSHRC_IS_SHARED(_o) && !VBOXSHRC_IS_LOCKED(_o))
|
---|
35 |
|
---|
36 | #define VBOXSHRC_LOCK(_o) do{ \
|
---|
37 | Assert(VBOXSHRC_IS_SHARED(_o)); \
|
---|
38 | ++(_o)->resource.sharerc_locks; \
|
---|
39 | } while (0)
|
---|
40 | #define VBOXSHRC_UNLOCK(_o) do{ \
|
---|
41 | Assert(VBOXSHRC_IS_SHARED(_o)); \
|
---|
42 | --(_o)->resource.sharerc_locks; \
|
---|
43 | Assert((_o)->resource.sharerc_locks < UINT32_MAX/2); \
|
---|
44 | } while (0)
|
---|
45 | #define VBOXSHRC_IS_LOCKED(_o) ( \
|
---|
46 | !!((_o)->resource.sharerc_locks) \
|
---|
47 | )
|
---|
48 |
|
---|
49 | #endif /* #ifndef ___vboxsharedrc_h___ */
|
---|