VirtualBox

source: kStuff/trunk/kProfiler2/prfcorepre.cpp.h@ 29

Last change on this file since 29 was 29, checked in by bird, 15 years ago

Finally got around execute the switch to the MIT license.

  • Property svn:keywords set to Id Revision
File size: 5.3 KB
Line 
1/* $Id: prfcorepre.cpp.h 29 2009-07-01 20:30:29Z bird $ */
2/** @file
3 * kProfiler Mark 2 - Core Pre-Code Template.
4 */
5
6/*
7 * Copyright (c) 2006-2007 Knut St. Osmundsen <[email protected]>
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31
32/** @def KPRF_OFF2PTR
33 * Internal helper for converting a offset to a pointer.
34 * @internal
35 */
36#define KPRF_OFF2PTR(TypePrefix, TypeName, off, pHdr) \
37 ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (KPRF_TYPE(,UPTR))pHdr) )
38
39/** @def KPRF_PTR2OFF
40 * Internal helper for converting a pointer to a offset.
41 * @internal
42 */
43#define KPRF_PTR2OFF(ptr, pHdr) \
44 ( (KPRF_TYPE(,UPTR))(ptr) - (KPRF_TYPE(,UPTR))(pHdr) )
45
46/** @def KPRF_ALIGN
47 * The usual align macro.
48 * @internal
49 */
50#define KPRF_ALIGN(n, align) ( ((n) + ( (align) - 1)) & ~((align) - 1) )
51
52/** @def KPRF_SETMIN_ALIGN
53 * Ensures a minimum and aligned value.
54 * @internal
55 */
56#define KPRF_SETMIN_ALIGN(n, min, align) \
57 do { \
58 if ((n) < (min)) \
59 (n) = (min); \
60 else { \
61 const KU32 u32 = ((n) + ( (align) - 1)) & ~((align) - 1); \
62 if (u32 >= (n)) \
63 (n) = u32; \
64 } \
65 } while (0)
66
67/** @def KPRF_OFFSETOF
68 * My usual extended OFFSETOF macro, except this returns KU32 and mangles the type name.
69 * @internal
70 */
71#define KPRF_OFFSETOF(kPrfType, Member) ( (KU32)(KUPTR)&((KPRF_TYPE(P,kPrfType))0)->Member )
72
73/** @def PRF_SIZEOF
74 * Size of a kPrf type.
75 * @internal
76 */
77#define KPRF_SIZEOF(kPrfType) sizeof(KPRF_TYPE(,kPrfType))
78
79
80/** @def KPRF_NOW
81 * Gets the current timestamp.
82 */
83#ifndef KPRF_NOW
84# error "KPRF_NOW isn't defined!"
85#endif
86
87/** @def KRPF_IS_ACTIVE
88 * Checks if profiling is activated or not.
89 * The idea is to use some global variable for disabling and enabling
90 * profiling in order to deal with init/term issues.
91 */
92#ifndef KPRF_IS_ACTIVE
93# define KPRF_IS_ACTIVE() 1
94#endif
95
96/** @def KPRF_GET_HDR
97 * Gets the pointer to the profiler data header.
98 */
99#ifndef KPRF_GET_HDR
100# error "KPRF_GET_HDR isn't defined!"
101#endif
102
103/** @def KPRF_GET_THREADID
104 * Gets native thread id. This must be unique.
105 */
106#ifndef KPRF_GET_THREADID
107# error "KPRF_GET_THREADID isn't defined!"
108#endif
109
110/** @def KPRF_SET_THREAD
111 * Sets the pointer to the current thread so we can get to it
112 * without doing a linear search by thread id.
113 */
114#ifndef KPRF_SET_THREAD
115# error "KPRF_SET_THREAD isn't defined!"
116#endif
117
118/** @def KPRF_GET_THREAD
119 * Gets the pointer to the current thread as set by KPRF_SET_THREAD.
120 */
121#ifndef KPRF_GET_THREAD
122# error "KPRF_GET_THREAD isn't defined!"
123#endif
124
125/** @def KPRF_MODSEGS_LOCK
126 * Lock the module segment for updating.
127 */
128#ifndef KPRF_MODSEGS_LOCK
129# define KPRF_MODSEGS_LOCK() do { } while (0)
130#endif
131
132/** @def KPRF_MODSEGS_UNLOCK
133 * Unlock the module segments.
134 */
135#ifndef KPRF_MODSEGS_UNLOCK
136# define KPRF_MODSEGS_UNLOCK() do { } while (0)
137#endif
138
139/** @def KPRF_THREADS_LOCK
140 * Lock the threads for updating.
141 */
142#ifndef KPRF_THREADS_LOCK
143# define KPRF_THREADS_LOCK() do { } while (0)
144#endif
145
146/** @def KPRF_THREADS_UNLOCK
147 * Unlock the threads.
148 */
149#ifndef KPRF_THREADS_UNLOCK
150# define KPRF_THREADS_UNLOCK() do { } while (0)
151#endif
152
153/** @def KPRF_FUNCS_READ_LOCK
154 * Lock the functions for reading.
155 */
156#ifndef KPRF_FUNCS_READ_LOCK
157# define KPRF_FUNCS_READ_LOCK() do { } while (0)
158#endif
159
160/** @def KPRF_FUNCS_READ_UNLOCK
161 * Releases a read lock on the functions.
162 */
163#ifndef KPRF_FUNCS_READ_UNLOCK
164# define KPRF_FUNCS_READ_UNLOCK() do { } while (0)
165#endif
166
167/** @def KPRF_FUNCS_WRITE_LOCK
168 * Lock the functions for updating.
169 */
170#ifndef KPRF_FUNCS_WRITE_LOCK
171# define KPRF_FUNCS_WRITE_LOCK() do { } while (0)
172#endif
173
174/** @def KPRF_FUNCS_WRITE_UNLOCK
175 * Releases a write lock on the functions.
176 */
177#ifndef KPRF_FUNCS_WRITE_UNLOCK
178# define KPRF_FUNCS_WRITE_UNLOCK() do { } while (0)
179#endif
180
181
182/** @def KPRF_ATOMIC_SET32
183 * Atomically set a 32-bit value.
184 */
185#ifndef KPRF_ATOMIC_SET32
186# define KPRF_ATOMIC_SET32(pu32, u32) do { *(pu32) = (u32); } while (0)
187#endif
188
189/** @def KPRF_ATOMIC_SET64
190 * Atomically (well, in a safe way) adds to a 64-bit value.
191 */
192#ifndef KPRF_ATOMIC_ADD64
193# define KPRF_ATOMIC_ADD64(pu64, u64) do { *(pu64) += (u64); } while (0)
194#endif
195
196/** @def KPRF_ATOMIC_SET64
197 * Atomically (well, in a safe way) increments a 64-bit value.
198 */
199#ifndef KPRF_ATOMIC_INC64
200# define KPRF_ATOMIC_INC64(pu64) KPRF_ATOMIC_ADD64(pu64, 1)
201#endif
202
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