STAMInternal.h revision d292438512fae43184049e5354a9d74788a135ed
/* $Id$ */
/** @file
* STAM Internal Header.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___STAMInternal_h
#define ___STAMInternal_h
#include <iprt/semaphore.h>
# error "Not in STAM! This is an internal header!"
#endif
/** @defgroup grp_stam_int Internals
* @ingroup grp_stam
* @internal
* @{
*/
/**
* Sample descriptor.
*/
typedef struct STAMDESC
{
/** Pointer to the next sample. */
/** Sample name. */
const char *pszName;
/** Sample type. */
/** Visibility type. */
/** Pointer to the sample data. */
union STAMDESCSAMPLEDATA
{
/** Counter. */
/** Profile. */
/** Advanced profile. */
/** Ratio, unsigned 32-bit. */
/** unsigned 8-bit. */
/** unsigned 16-bit. */
/** unsigned 32-bit. */
/** unsigned 64-bit. */
/** Simple void pointer. */
void *pv;
/** */
struct STAMDESCSAMPLEDATACALLBACKS
{
/** The same pointer. */
void *pvSample;
/** Pointer to the reset callback. */
/** Pointer to the print callback. */
} Callback;
} u;
/** Unit. */
/** Description. */
const char *pszDesc;
} STAMDESC;
/** Pointer to sample descriptor. */
/** Pointer to const sample descriptor. */
typedef const STAMDESC *PCSTAMDESC;
/**
* Converts a STAM pointer into a VM pointer.
* @returns Pointer to the VM structure the STAM is part of.
* @param pSTAM Pointer to STAM instance data.
*/
/**
* The stam data in the VM.
*/
struct STAM
{
/** Offset to the VM structure.
* See STAM2VM(). */
/** Alignment padding. */
/** Pointer to the first sample. */
/** RW Lock for the list. */
/** The copy of the GVMM statistics. */
};
/** Locks the sample descriptors for reading. */
#define STAM_LOCK_RD(pVM) do { int rcSem = RTSemRWRequestRead(pVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
/** Locks the sample descriptors for writing. */
#define STAM_LOCK_WR(pVM) do { int rcSem = RTSemRWRequestWrite(pVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
/** UnLocks the sample descriptors after reading. */
#define STAM_UNLOCK_RD(pVM) do { int rcSem = RTSemRWReleaseRead(pVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
/** UnLocks the sample descriptors after writing. */
#define STAM_UNLOCK_WR(pVM) do { int rcSem = RTSemRWReleaseWrite(pVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
/** @} */
#endif