lockvalidator.h revision cb5363b6fa48f10b080cb6195f56c0823f7c0b0f
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** @file
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * IPRT - Lock Validator.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * available from http://www.virtualbox.org. This file is free software;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * you can redistribute it and/or modify it under the terms of the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * General Public License (GPL) as published by the Free Software
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file may alternatively be used under the terms
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * of the Common Development and Distribution License Version 1.0
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * VirtualBox OSE distribution, in which case the provisions of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL are applicable instead of those of the GPL.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You may elect to license modified versions of this file under the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * terms and conditions of either the GPL or the CDDL or both.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * additional information or have any questions.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ifndef ___iprt_lockvalidator_h
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define ___iprt_lockvalidator_h
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/cdefs.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/types.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/assert.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <iprt/thread.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** @defgroup grp_ldr RTLockValidator - Lock Validator
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * @ingroup grp_rt
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * @{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncRT_C_DECLS_BEGIN
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct RTLOCKVALIDATORSRCPOS
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The file where the lock was taken. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync R3R0PTRTYPE(const char * volatile) pszFile;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The function where the lock was taken. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync R3R0PTRTYPE(const char * volatile) pszFunction;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Some ID indicating where the lock was taken, typically an address. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTHCUINTPTR volatile uId;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The line number in the file. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t volatile uLine;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#if HC_ARCH_BITS == 64
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t u32Padding; /**< Alignment padding. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} RTLOCKVALIDATORSRCPOS;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncAssertCompileSize(RTLOCKVALIDATORSRCPOS, HC_ARCH_BITS == 32 ? 16 : 32);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/* The pointer types are defined in iprt/types.h. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** @def RTLOCKVALIDATORSRCPOS_INIT
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Initializer for a RTLOCKVALIDATORSRCPOS variable.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * @param pszFile The file name. Optional (NULL).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * @param uLine The line number in that file. Optional (0).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * @param pszFunction The function. Optional (NULL).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * @param uId Some location ID, normally the return address.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Optional (NULL).
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#if HC_ARCH_BITS == 64
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# define RTLOCKVALIDATORSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync { (pszFile), (pszFunction), (uId), (uLine), 0 }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#else
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# define RTLOCKVALIDATORSRCPOS_INIT(pszFile, uLine, pszFunction, uId) \
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync { (pszFile), (pszFunction), (uId), (uLine) }
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** @def RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Initializer for a RTLOCKVALIDATORSRCPOS variable in a typicial debug API
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * variant. Assumes RT_SRC_POS_DECL and RTHCUINTPTR uId as arguments.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API() \
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTLOCKVALIDATORSRCPOS_INIT(pszFile, iLine, pszFunction, uId)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/** @def RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Initializer for a RTLOCKVALIDATORSRCPOS variable in a normal API
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * variant. Assumes iprt/asm.h is included.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API() \
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTLOCKVALIDATORSRCPOS_INIT(__FILE__, __LINE__, __PRETTY_FUNCTION__, (uintptr_t)ASMReturnAddress())
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/**
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Record recording the ownership of a lock.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * This is typically part of the per-lock data structure when compiling with
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * the lock validator.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct RTLOCKVALIDATORREC
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Magic value (RTLOCKVALIDATORREC_MAGIC). */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t u32Magic;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Reserved. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t u32Reserved;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Source position where the lock was taken. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTLOCKVALIDATORSRCPOS SrcPos;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The current owner thread. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTTHREAD volatile hThread;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Pointer to the lock record below us. Only accessed by the owner. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync R3R0PTRTYPE(PRTLOCKVALIDATORREC) pDown;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** Recursion count */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t cRecursion;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The lock sub-class. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t volatile uSubClass;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /** The lock class. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync RTLOCKVALIDATORCLASS hClass;
/** Pointer to the lock. */
RTHCPTR hLock;
/** The lock name. */
R3R0PTRTYPE(const char *) pszName;
/** Reserved. */
RTHCPTR pvReserved;
} RTLOCKVALIDATORREC;
AssertCompileSize(RTLOCKVALIDATORREC, HC_ARCH_BITS == 32 ? 8 + 16 + 32 : 8 + 32 + 56);
/* The pointer type is defined in iprt/types.h. */
/** Pointer to a record of one ownership share. */
typedef struct RTLOCKVALIDATORSHAREDREC *PRTLOCKVALIDATORSHAREDREC;
/**
* For recording the one ownership share.
*/
typedef struct RTLOCKVALIDATORSHAREDONE
{
/** Magic value (RTLOCKVALIDATORSHAREDONE_MAGIC). */
uint32_t u32Magic;
/** Recursion count */
uint32_t cRecursion;
/** The current owner thread. */
RTTHREAD volatile hThread;
/** Pointer to the lock record below us. Only accessed by the owner. */
R3R0PTRTYPE(PRTLOCKVALIDATORREC) pDown;
/** Pointer back to the shared record. */
R3R0PTRTYPE(PRTLOCKVALIDATORSHAREDREC) pSharedRec;
#if HC_ARCH_BITS == 32
/** Reserved. */
RTHCPTR pvReserved;
#endif
/** Source position where the lock was taken. */
RTLOCKVALIDATORSRCPOS SrcPos;
} RTLOCKVALIDATORSHAREDONE;
AssertCompileSize(RTLOCKVALIDATORSHAREDONE, HC_ARCH_BITS == 32 ? 24 + 16 : 32 + 32);
/** Pointer to a RTLOCKVALIDATORSHAREDONE. */
typedef RTLOCKVALIDATORSHAREDONE *PRTLOCKVALIDATORSHAREDONE;
/**
* Record recording the shared ownership of a lock.
*
* This is typically part of the per-lock data structure when compiling with
* the lock validator.
*/
typedef struct RTLOCKVALIDATORSHARED
{
/** Magic value (RTLOCKVALIDATORSHARED_MAGIC). */
uint32_t u32Magic;
/** The lock sub-class. */
uint32_t volatile uSubClass;
/** The lock class. */
RTLOCKVALIDATORCLASS hClass;
/** Pointer to the lock. */
RTHCPTR hLock;
/** The lock name. */
R3R0PTRTYPE(const char *) pszName;
/** The number of entries in the table.
* Updated before inserting and after removal. */
uint32_t volatile cEntries;
/** The index of the last entry (approximately). */
uint32_t volatile iLastEntry;
/** The max table size. */
uint32_t volatile cAllocated;
/** Set if the table is being reallocated, clear if not.
* This is used together with rtLockValidatorSerializeDetectionEnter to make
* sure there is exactly one thread doing the reallocation and that nobody is
* using the table at that point. */
bool volatile fReallocating;
/** Alignment padding. */
bool afPadding[3];
/** Pointer to a table containing pointers to records of all the owners. */
R3R0PTRTYPE(PRTLOCKVALIDATORSHAREDONE volatile *) papOwners;
/** Alignment padding. */
uint64_t u64Alignment;
} RTLOCKVALIDATORSHARED;
AssertCompileSize(RTLOCKVALIDATORSHARED, HC_ARCH_BITS == 32 ? 20 + 20 + 8 : 32 + 32);
/** Pointer to a RTLOCKVALIDATORSHARED. */
typedef RTLOCKVALIDATORSHARED *PRTLOCKVALIDATORSHARED;
/** @name Special sub-class values.
* The range 16..UINT32_MAX is available to the user, the range 0..15 is
* reserved for the lock validator.
* @{ */
/** Not allowed to be taken with any other locks in the same class.
* This is the recommended value. */
#define RTLOCKVALIDATOR_SUB_CLASS_NONE UINT32_C(0)
/** Any order is allowed within the class. */
#define RTLOCKVALIDATOR_SUB_CLASS_ANY UINT32_C(1)
/** The first user value. */
#define RTLOCKVALIDATOR_SUB_CLASS_USER UINT32_C(16)
/** @} */
/**
* Initialize a lock validator record.
*
* Use RTLockValidatorRecDelete to deinitialize it.
*
* @param pRec The record.
* @param hClass The class. If NIL, the no lock order
* validation will be performed on this lock.
* @param uSubClass The sub-class. This is used to define lock
* order inside the same class. If you don't know,
* then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
* @param pszName The lock name (optional).
* @param hLock The lock handle.
*/
RTDECL(void) RTLockValidatorRecInit(PRTLOCKVALIDATORREC pRec, RTLOCKVALIDATORCLASS hClass,
uint32_t uSubClass, const char *pszName, void *hLock);
/**
* Uninitialize a lock validator record previously initialized by
* RTLockRecValidatorInit.
*
* @param pRec The record. Must be valid.
*/
RTDECL(void) RTLockValidatorRecDelete(PRTLOCKVALIDATORREC pRec);
/**
* Create and initialize a lock validator record.
*
* Use RTLockValidatorRecDestroy to deinitialize and destroy the returned
* record.
*
* @return VINF_SUCCESS or VERR_NO_MEMORY.
* @param ppRec Where to return the record pointer.
* @param hClass The class. If NIL, the no lock order
* validation will be performed on this lock.
* @param uSubClass The sub-class. This is used to define lock
* order inside the same class. If you don't know,
* then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
* @param pszName The lock name (optional).
* @param hLock The lock handle.
*/
RTDECL(int) RTLockValidatorRecCreate(PRTLOCKVALIDATORREC *ppRec, RTLOCKVALIDATORCLASS hClass,
uint32_t uSubClass, const char *pszName, void *hLock);
/**
* Deinitialize and destroy a record created by RTLockValidatorRecCreate.
*
* @param ppRec Pointer to the record pointer. Will be set to
* NULL.
*/
RTDECL(void) RTLockValidatorRecDestroy(PRTLOCKVALIDATORREC *ppRec);
/**
* Initialize a lock validator record for a shared lock.
*
* Use RTLockValidatorSharedRecDelete to deinitialize it.
*
* @param pRec The shared lock record.
* @param hClass The class. If NIL, the no lock order
* validation will be performed on this lock.
* @param uSubClass The sub-class. This is used to define lock
* order inside the same class. If you don't know,
* then pass RTLOCKVALIDATOR_SUB_CLASS_NONE.
* @param pszName The lock name (optional).
* @param hLock The lock handle.
*/
RTDECL(void) RTLockValidatorSharedRecInit(PRTLOCKVALIDATORSHARED pRec, RTLOCKVALIDATORCLASS hClass,
uint32_t uSubClass, const char *pszName, void *hLock);
/**
* Uninitialize a lock validator record previously initialized by
* RTLockValidatorSharedRecInit.
*
* @param pRec The shared lock record. Must be valid.
*/
RTDECL(void) RTLockValidatorSharedRecDelete(PRTLOCKVALIDATORSHARED pRec);
/**
* Check the locking order.
*
* This is called by routines implementing lock acquisition.
*
* @retval VINF_SUCCESS on success.
* @retval VERR_SEM_LV_WRONG_ORDER if the order is wrong. Will have done all
* necessary whining and breakpointing before returning.
* @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
*
* @param pRec The validator record.
* @param hThread The handle of the calling thread. If not known,
* pass NIL_RTTHREAD and this method will figure it
* out.
* @param pSrcPos The source position of the lock operation.
*/
RTDECL(int) RTLockValidatorCheckOrder(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos);
/**
* Do deadlock detection before blocking on a lock.
*
* @retval VINF_SUCCESS
* @retval VERR_SEM_LV_DEADLOCK if blocking would deadlock. Gone thru the
* motions.
* @retval VERR_SEM_LV_NESTED if the semaphore isn't recursive and hThread is
* already the owner. Gone thru the motions.
* @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
*
* @param pRec The validator record we're blocing on.
* @param hThread The current thread. Shall not be NIL_RTTHREAD!
* @param enmState The sleep state.
* @param pvBlock Pointer to a RTLOCKVALIDATORREC structure.
* @param fRecursiveOk Whether it's ok to recurse.
* @param pSrcPos The source position of the lock operation.
*/
RTDECL(int) RTLockValidatorCheckBlocking(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread,
RTTHREADSTATE enmState, bool fRecursiveOk,
PCRTLOCKVALIDATORSRCPOS pSrcPos);
/**
* Check the exit order.
*
* This is called by routines implementing releasing the lock.
*
* @retval VINF_SUCCESS on success.
* @retval VERR_SEM_LV_WRONG_RELEASE_ORDER if the order is wrong. Will have
* done all necessary whining and breakpointing before returning.
* @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
*
* @param pRec The validator record.
*/
RTDECL(int) RTLockValidatorCheckReleaseOrder(PRTLOCKVALIDATORREC pRec);
/**
* Checks and records a lock recursion.
*
* @retval VINF_SUCCESS on success.
* @retval VERR_SEM_LV_NESTED if the semaphore class forbids recursion. Gone
* thru the motions.
* @retval VERR_SEM_LV_INVALID_PARAMETER if the input is invalid.
*
* @param pRec The validator record.
* @param pSrcPos The source position of the lock operation.
*/
RTDECL(int) RTLockValidatorRecordRecursion(PRTLOCKVALIDATORREC pRec, PCRTLOCKVALIDATORSRCPOS pSrcPos);
/**
* Records a lock unwind (releasing one recursion).
*
* This should be coupled with called to RTLockValidatorRecordRecursion.
*
* @param pRec The validator record.
*/
RTDECL(void) RTLockValidatorRecordUnwind(PRTLOCKVALIDATORREC pRec);
/**
* Record the specified thread as lock owner and increment the write lock count.
*
* This function is typically called after acquiring the lock.
*
* @returns hThread resolved. Can return NIL_RTHREAD iff we fail to adopt the
* alien thread or if pRec is invalid.
*
* @param pRec The validator record.
* @param hThread The handle of the calling thread. If not known,
* pass NIL_RTTHREAD and this method will figure it
* out.
* @param pSrcPos The source position of the lock operation.
*/
RTDECL(RTTHREAD) RTLockValidatorSetOwner(PRTLOCKVALIDATORREC pRec, RTTHREAD hThread, PCRTLOCKVALIDATORSRCPOS pSrcPos);
/**
* Clear the lock ownership and decrement the write lock count.
*
* This is typically called before release the lock.
*
* @returns The thread handle of the previous owner. NIL_RTTHREAD if the record
* is invalid or didn't have any owner.
* @param pRec The validator record.
*/
RTDECL(RTTHREAD) RTLockValidatorUnsetOwner(PRTLOCKVALIDATORREC pRec);
/**
* Gets the number of write locks and critical sections the specified
* thread owns.
*
* This number does not include any nested lock/critect entries.
*
* Note that it probably will return 0 for non-strict builds since
* release builds doesn't do unnecessary diagnostic counting like this.
*
* @returns Number of locks on success (0+) and VERR_INVALID_HANDLER on failure
* @param Thread The thread we're inquiring about.
* @remarks Will only work for strict builds.
*/
RTDECL(int32_t) RTLockValidatorWriteLockGetCount(RTTHREAD Thread);
/**
* Works the THREADINT::cWriteLocks member, mostly internal.
*
* @param Thread The current thread.
*/
RTDECL(void) RTLockValidatorWriteLockInc(RTTHREAD Thread);
/**
* Works the THREADINT::cWriteLocks member, mostly internal.
*
* @param Thread The current thread.
*/
RTDECL(void) RTLockValidatorWriteLockDec(RTTHREAD Thread);
/**
* Gets the number of read locks the specified thread owns.
*
* Note that nesting read lock entry will be included in the
* total sum. And that it probably will return 0 for non-strict
* builds since release builds doesn't do unnecessary diagnostic
* counting like this.
*
* @returns Number of read locks on success (0+) and VERR_INVALID_HANDLER on failure
* @param Thread The thread we're inquiring about.
*/
RTDECL(int32_t) RTLockValidatorReadLockGetCount(RTTHREAD Thread);
/**
* Works the THREADINT::cReadLocks member.
*
* @param Thread The current thread.
*/
RTDECL(void) RTLockValidatorReadLockInc(RTTHREAD Thread);
/**
* Works the THREADINT::cReadLocks member.
*
* @param Thread The current thread.
*/
RTDECL(void) RTLockValidatorReadLockDec(RTTHREAD Thread);
/*RTDECL(int) RTLockValidatorClassCreate();*/
RT_C_DECLS_END
/** @} */
#endif