VirtualBox

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

Last change on this file since 24 was 2, checked in by bird, 18 years ago

Imported http://svn.netlabs.org/repos/libc/trunk/kStuff, revision 3612.

  • Property svn:keywords set to Id Revision
File size: 5.0 KB
Line 
1/* $Id: prfcorepre.cpp.h 2 2007-11-16 16:07:14Z 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 * This file is part of kProfiler.
10 *
11 * kProfiler is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * kProfiler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with kProfiler; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 *
25 */
26
27
28/** @def KPRF_OFF2PTR
29 * Internal helper for converting a offset to a pointer.
30 * @internal
31 */
32#define KPRF_OFF2PTR(TypePrefix, TypeName, off, pHdr) \
33 ( (KPRF_TYPE(TypePrefix, TypeName)) ((off) + (KPRF_TYPE(,UPTR))pHdr) )
34
35/** @def KPRF_PTR2OFF
36 * Internal helper for converting a pointer to a offset.
37 * @internal
38 */
39#define KPRF_PTR2OFF(ptr, pHdr) \
40 ( (KPRF_TYPE(,UPTR))(ptr) - (KPRF_TYPE(,UPTR))(pHdr) )
41
42/** @def KPRF_ALIGN
43 * The usual align macro.
44 * @internal
45 */
46#define KPRF_ALIGN(n, align) ( ((n) + ( (align) - 1)) & ~((align) - 1) )
47
48/** @def KPRF_SETMIN_ALIGN
49 * Ensures a minimum and aligned value.
50 * @internal
51 */
52#define KPRF_SETMIN_ALIGN(n, min, align) \
53 do { \
54 if ((n) < (min)) \
55 (n) = (min); \
56 else { \
57 const KU32 u32 = ((n) + ( (align) - 1)) & ~((align) - 1); \
58 if (u32 >= (n)) \
59 (n) = u32; \
60 } \
61 } while (0)
62
63/** @def KPRF_OFFSETOF
64 * My usual extended OFFSETOF macro, except this returns KU32 and mangles the type name.
65 * @internal
66 */
67#define KPRF_OFFSETOF(kPrfType, Member) ( (KU32)(KUPTR)&((KPRF_TYPE(P,kPrfType))0)->Member )
68
69/** @def PRF_SIZEOF
70 * Size of a kPrf type.
71 * @internal
72 */
73#define KPRF_SIZEOF(kPrfType) sizeof(KPRF_TYPE(,kPrfType))
74
75
76/** @def KPRF_NOW
77 * Gets the current timestamp.
78 */
79#ifndef KPRF_NOW
80# error "KPRF_NOW isn't defined!"
81#endif
82
83/** @def KRPF_IS_ACTIVE
84 * Checks if profiling is activated or not.
85 * The idea is to use some global variable for disabling and enabling
86 * profiling in order to deal with init/term issues.
87 */
88#ifndef KPRF_IS_ACTIVE
89# define KPRF_IS_ACTIVE() 1
90#endif
91
92/** @def KPRF_GET_HDR
93 * Gets the pointer to the profiler data header.
94 */
95#ifndef KPRF_GET_HDR
96# error "KPRF_GET_HDR isn't defined!"
97#endif
98
99/** @def KPRF_GET_THREADID
100 * Gets native thread id. This must be unique.
101 */
102#ifndef KPRF_GET_THREADID
103# error "KPRF_GET_THREADID isn't defined!"
104#endif
105
106/** @def KPRF_SET_THREAD
107 * Sets the pointer to the current thread so we can get to it
108 * without doing a linear search by thread id.
109 */
110#ifndef KPRF_SET_THREAD
111# error "KPRF_SET_THREAD isn't defined!"
112#endif
113
114/** @def KPRF_GET_THREAD
115 * Gets the pointer to the current thread as set by KPRF_SET_THREAD.
116 */
117#ifndef KPRF_GET_THREAD
118# error "KPRF_GET_THREAD isn't defined!"
119#endif
120
121/** @def KPRF_MODSEGS_LOCK
122 * Lock the module segment for updating.
123 */
124#ifndef KPRF_MODSEGS_LOCK
125# define KPRF_MODSEGS_LOCK() do { } while (0)
126#endif
127
128/** @def KPRF_MODSEGS_UNLOCK
129 * Unlock the module segments.
130 */
131#ifndef KPRF_MODSEGS_UNLOCK
132# define KPRF_MODSEGS_UNLOCK() do { } while (0)
133#endif
134
135/** @def KPRF_THREADS_LOCK
136 * Lock the threads for updating.
137 */
138#ifndef KPRF_THREADS_LOCK
139# define KPRF_THREADS_LOCK() do { } while (0)
140#endif
141
142/** @def KPRF_THREADS_UNLOCK
143 * Unlock the threads.
144 */
145#ifndef KPRF_THREADS_UNLOCK
146# define KPRF_THREADS_UNLOCK() do { } while (0)
147#endif
148
149/** @def KPRF_FUNCS_READ_LOCK
150 * Lock the functions for reading.
151 */
152#ifndef KPRF_FUNCS_READ_LOCK
153# define KPRF_FUNCS_READ_LOCK() do { } while (0)
154#endif
155
156/** @def KPRF_FUNCS_READ_UNLOCK
157 * Releases a read lock on the functions.
158 */
159#ifndef KPRF_FUNCS_READ_UNLOCK
160# define KPRF_FUNCS_READ_UNLOCK() do { } while (0)
161#endif
162
163/** @def KPRF_FUNCS_WRITE_LOCK
164 * Lock the functions for updating.
165 */
166#ifndef KPRF_FUNCS_WRITE_LOCK
167# define KPRF_FUNCS_WRITE_LOCK() do { } while (0)
168#endif
169
170/** @def KPRF_FUNCS_WRITE_UNLOCK
171 * Releases a write lock on the functions.
172 */
173#ifndef KPRF_FUNCS_WRITE_UNLOCK
174# define KPRF_FUNCS_WRITE_UNLOCK() do { } while (0)
175#endif
176
177
178/** @def KPRF_ATOMIC_SET32
179 * Atomically set a 32-bit value.
180 */
181#ifndef KPRF_ATOMIC_SET32
182# define KPRF_ATOMIC_SET32(pu32, u32) do { *(pu32) = (u32); } while (0)
183#endif
184
185/** @def KPRF_ATOMIC_SET64
186 * Atomically (well, in a safe way) adds to a 64-bit value.
187 */
188#ifndef KPRF_ATOMIC_ADD64
189# define KPRF_ATOMIC_ADD64(pu64, u64) do { *(pu64) += (u64); } while (0)
190#endif
191
192/** @def KPRF_ATOMIC_SET64
193 * Atomically (well, in a safe way) increments a 64-bit value.
194 */
195#ifndef KPRF_ATOMIC_INC64
196# define KPRF_ATOMIC_INC64(pu64) KPRF_ATOMIC_ADD64(pu64, 1)
197#endif
198
Note: See TracBrowser for help on using the repository browser.

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