VirtualBox

source: vbox/trunk/src/VBox/VMM/STAMInternal.h@ 4485

Last change on this file since 4485 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1/* $Id: STAMInternal.h 4071 2007-08-07 17:07:59Z vboxsync $ */
2/** @file
3 * STAM Internal Header.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___STAMInternal_h
19#define ___STAMInternal_h
20
21#include <VBox/cdefs.h>
22#include <VBox/types.h>
23#include <VBox/stam.h>
24#include <iprt/semaphore.h>
25
26#if !defined(IN_STAM_R3) && !defined(IN_STAM_R0) && !defined(IN_STAM_GC)
27# error "Not in STAM! This is an internal header!"
28#endif
29
30
31__BEGIN_DECLS
32
33/** @defgroup grp_stam_int Internals
34 * @ingroup grp_stam
35 * @internal
36 * @{
37 */
38
39/**
40 * Sample descriptor.
41 */
42typedef struct STAMDESC
43{
44 /** Pointer to the next sample. */
45 struct STAMDESC *pNext;
46 /** Sample name. */
47 const char *pszName;
48 /** Sample type. */
49 STAMTYPE enmType;
50 /** Visibility type. */
51 STAMVISIBILITY enmVisibility;
52 /** Pointer to the sample data. */
53 union STAMDESCSAMPLEDATA
54 {
55 /** Counter. */
56 PSTAMCOUNTER pCounter;
57 /** Profile. */
58 PSTAMPROFILE pProfile;
59 /** Advanced profile. */
60 PSTAMPROFILEADV pProfileAdv;
61 /** Ratio, unsigned 32-bit. */
62 PSTAMRATIOU32 pRatioU32;
63 /** unsigned 8-bit. */
64 uint8_t *pu8;
65 /** unsigned 16-bit. */
66 uint16_t *pu16;
67 /** unsigned 32-bit. */
68 uint32_t *pu32;
69 /** unsigned 64-bit. */
70 uint64_t *pu64;
71 /** Simple void pointer. */
72 void *pv;
73 /** */
74 struct STAMDESCSAMPLEDATACALLBACKS
75 {
76 /** The same pointer. */
77 void *pvSample;
78 /** Pointer to the reset callback. */
79 PFNSTAMR3CALLBACKRESET pfnReset;
80 /** Pointer to the print callback. */
81 PFNSTAMR3CALLBACKPRINT pfnPrint;
82 } Callback;
83 } u;
84 /** Unit. */
85 STAMUNIT enmUnit;
86 /** Description. */
87 const char *pszDesc;
88} STAMDESC;
89/** Pointer to sample descriptor. */
90typedef STAMDESC *PSTAMDESC;
91/** Pointer to const sample descriptor. */
92typedef const STAMDESC *PCSTAMDESC;
93
94
95/**
96 * Converts a STAM pointer into a VM pointer.
97 * @returns Pointer to the VM structure the STAM is part of.
98 * @param pSTAM Pointer to STAM instance data.
99 */
100#define STAM2VM(pSTAM) ( (PVM)((char*)pSTAM - pSTAM->offVM) )
101
102
103/**
104 * The stam data in the VM.
105 */
106struct STAM
107{
108 /** Offset to the VM structure.
109 * See STAM2VM(). */
110 RTINT offVM;
111 /** Alignment padding. */
112 RTUINT uPadding;
113 /** Pointer to the first sample. */
114 HCPTRTYPE(PSTAMDESC) pHead;
115 /** RW Lock for the list. */
116 RTSEMRW RWSem;
117};
118
119/** Locks the sample descriptors for reading. */
120#define STAM_LOCK_RD(pVM) do { int rcSem = RTSemRWRequestRead(pVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
121/** Locks the sample descriptors for writing. */
122#define STAM_LOCK_WR(pVM) do { int rcSem = RTSemRWRequestWrite(pVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
123/** UnLocks the sample descriptors after reading. */
124#define STAM_UNLOCK_RD(pVM) do { int rcSem = RTSemRWReleaseRead(pVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
125/** UnLocks the sample descriptors after writing. */
126#define STAM_UNLOCK_WR(pVM) do { int rcSem = RTSemRWReleaseWrite(pVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
127
128/** @} */
129
130__END_DECLS
131
132#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette