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