VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/log/tracedefault.cpp@ 42599

Last change on this file since 42599 was 39327, checked in by vboxsync, 13 years ago

scm whitespace cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1
2/*******************************************************************************
3* Header Files *
4*******************************************************************************/
5#include "internal/iprt.h"
6#include <iprt/trace.h>
7
8#include <iprt/asm.h>
9#include <iprt/err.h>
10#include <iprt/thread.h>
11
12
13/*******************************************************************************
14* Global Variables *
15*******************************************************************************/
16/** The default trace buffer handle. */
17static RTTRACEBUF g_hDefaultTraceBuf = NIL_RTTRACEBUF;
18
19
20
21RTDECL(int) RTTraceSetDefaultBuf(RTTRACEBUF hTraceBuf)
22{
23 /* Retain the new buffer. */
24 if (hTraceBuf != NIL_RTTRACEBUF)
25 {
26 uint32_t cRefs = RTTraceBufRetain(hTraceBuf);
27 if (cRefs >= _1M)
28 return VERR_INVALID_HANDLE;
29 }
30
31 RTTRACEBUF hOldTraceBuf;
32#ifdef IN_RC
33 hOldTraceBuf = (RTTRACEBUF)ASMAtomicXchgPtr((void **)&g_hDefaultTraceBuf, hTraceBuf);
34#else
35 ASMAtomicXchgHandle(&g_hDefaultTraceBuf, hTraceBuf, &hOldTraceBuf);
36#endif
37
38 if ( hOldTraceBuf != NIL_RTTRACEBUF
39 && hOldTraceBuf != hTraceBuf)
40 {
41 /* Race prevention kludge. */
42#ifndef IN_RC
43 RTThreadSleep(33);
44#endif
45 RTTraceBufRelease(hOldTraceBuf);
46 }
47
48 return VINF_SUCCESS;
49}
50
51
52RTDECL(RTTRACEBUF) RTTraceGetDefaultBuf(void)
53{
54 return g_hDefaultTraceBuf;
55}
56
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