vboxsharedrc.h revision 955c1cdb6f113d55c6516187612a87c3b05dc154
4e456e445297d61870d9301661f36e5cc946cbefvboxsync/* $Id$ */
4e456e445297d61870d9301661f36e5cc946cbefvboxsync/** @file
4e456e445297d61870d9301661f36e5cc946cbefvboxsync *
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * VBox extension to Wine D3D
4e456e445297d61870d9301661f36e5cc946cbefvboxsync *
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * Copyright (C) 2010 Oracle Corporation
4e456e445297d61870d9301661f36e5cc946cbefvboxsync *
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * available from http://www.virtualbox.org. This file is free software;
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * you can redistribute it and/or modify it under the terms of the GNU
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * General Public License (GPL) as published by the Free Software
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
4e456e445297d61870d9301661f36e5cc946cbefvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
4e456e445297d61870d9301661f36e5cc946cbefvboxsync */
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#ifndef ___vboxsharedrc_h___
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#define ___vboxsharedrc_h___
4e456e445297d61870d9301661f36e5cc946cbefvboxsync
083cbf42ea3a1b9a6ba348928eaa0d5aed761b05vboxsync#define VBOXSHRC_F_SHARED 0x00000001 /* shared rc */
083cbf42ea3a1b9a6ba348928eaa0d5aed761b05vboxsync#define VBOXSHRC_F_SHARED_OPENED 0x00000002 /* if set shared rc is opened, otherwise it is created */
083cbf42ea3a1b9a6ba348928eaa0d5aed761b05vboxsync
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#define VBOXSHRC_GET_SHAREFLAFS(_o) ((_o)->resource.sharerc_flags)
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#define VBOXSHRC_GET_SHAREHANDLE(_o) ((HANDLE)(_o)->resource.sharerc_handle)
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#define VBOXSHRC_SET_SHAREHANDLE(_o, _h) ((_o)->resource.sharerc_handle = (DWORD)(_h))
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#define VBOXSHRC_COPY_SHAREDATA(_oDst, _oSrc) do { \
083cbf42ea3a1b9a6ba348928eaa0d5aed761b05vboxsync VBOXSHRC_GET_SHAREFLAFS(_oDst) = VBOXSHRC_GET_SHAREFLAFS(_oSrc); \
954fd0302687ec32d500de0241a6693b95aad3d0vboxsync VBOXSHRC_SET_SHAREHANDLE(_oDst, VBOXSHRC_GET_SHAREFLAFS(_oSrc)); \
954fd0302687ec32d500de0241a6693b95aad3d0vboxsync } while (0)
954fd0302687ec32d500de0241a6693b95aad3d0vboxsync#define VBOXSHRC_SET_SHARED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED)
954fd0302687ec32d500de0241a6693b95aad3d0vboxsync#define VBOXSHRC_SET_SHARED_OPENED(_o) (VBOXSHRC_GET_SHAREFLAFS(_o) |= VBOXSHRC_F_SHARED_OPENED)
954fd0302687ec32d500de0241a6693b95aad3d0vboxsync#define VBOXSHRC_IS_SHARED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED))
954fd0302687ec32d500de0241a6693b95aad3d0vboxsync#define VBOXSHRC_IS_SHARED_OPENED(_o) (!!(VBOXSHRC_GET_SHAREFLAFS(_o) & VBOXSHRC_F_SHARED_OPENED))
4e456e445297d61870d9301661f36e5cc946cbefvboxsync#define VBOXSHRC_IS_SHARED_UNLOCKED(_o) (VBOXSHRC_IS_SHARED(_o) && !VBOXSHRC_IS_LOCKED(_o))
4e456e445297d61870d9301661f36e5cc946cbefvboxsync
083cbf42ea3a1b9a6ba348928eaa0d5aed761b05vboxsync#define VBOXSHRC_LOCK(_o) do{ \
4e456e445297d61870d9301661f36e5cc946cbefvboxsync Assert(VBOXSHRC_IS_SHARED(_o)); \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync ++(_o)->resource.sharerc_locks; \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync } while (0)
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync#define VBOXSHRC_UNLOCK(_o) do{ \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync Assert(VBOXSHRC_IS_SHARED(_o)); \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync --(_o)->resource.sharerc_locks; \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync Assert((_o)->resource.sharerc_locks < UINT32_MAX/2); \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync } while (0)
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync#define VBOXSHRC_IS_LOCKED(_o) ( \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync !!((_o)->resource.sharerc_locks) \
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync )
845d0e4d3aefdc097ff0b3f1b1808f4b72e0a7d0vboxsync#ifdef VBOX_WINE_WITH_IPRT
4e456e445297d61870d9301661f36e5cc946cbefvboxsync# include <iprt/assert.h>
#else
# define AssertBreakpoint() do { } while (0)
# define Assert(_expr) do { } while (0)
#endif
#endif /* #ifndef ___vboxsharedrc_h___ */