2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * @(#)profile.h 8.1 (Berkeley) 6/11/93
30 * $FreeBSD: src/sys/amd64/include/profile.h,v 1.33 2004/01/06 20:36:21 nectar Exp $
33 #ifndef _CPU_PROFILE_H_
34 #define _CPU_PROFILE_H_
39 * Config generates something to tell the compiler to align functions on 16
40 * byte boundaries. A strict alignment is good for keeping the tables small.
42 #define FUNCTION_ALIGNMENT 16
45 * The kernel uses assembler stubs instead of unportable inlines.
46 * This is mainly to save a little time when profiling is not enabled,
47 * which is the usual case for the kernel.
49 #define _MCOUNT_DECL void mcount
53 #define CALIB_SCALE 1000
54 #define KCOUNT(p,index) ((p)->kcount[(index) \
55 / (HISTFRACTION * sizeof(HISTCOUNTER))])
56 #define MCOUNT_DECL(s)
57 #define MCOUNT_ENTER(s)
58 #define MCOUNT_EXIT(s)
59 #define PC_TO_I(p, pc) ((uintfptr_t)(pc) - (uintfptr_t)(p)->lowpc)
61 #define MCOUNT_DECL(s) u_long s;
62 extern int mcount_lock
;
63 #define MCOUNT_ENTER(s) { s = read_rflags(); disable_intr(); \
64 while (!atomic_cmpset_acq_int(&mcount_lock, 0, 1)) \
66 #define MCOUNT_EXIT(s) { atomic_store_rel_int(&mcount_lock, 0); \
72 #define FUNCTION_ALIGNMENT 4
74 #define _MCOUNT_DECL \
75 static void _mcount(uintfptr_t frompc, uintfptr_t selfpc) __used; \
79 #define MCOUNT __asm(" \n\
83 .type .mcount,@function \n\
93 movq 7*8(%rsp),%rsi \n\
103 .size .mcount, . - .mcount");
110 #endif /* __GNUC__ */
112 typedef unsigned long uintfptr_t
;
117 * An unsigned integral type that can hold non-negative difference between
120 typedef unsigned long fptrdiff_t
;
124 void mcount(uintfptr_t frompc
, uintfptr_t selfpc
);
125 void kmupetext(uintfptr_t nhighpc
);
130 void nullfunc_loop_profiled(void);
131 void nullfunc_profiled(void);
132 void startguprof(struct gmonparam
*p
);
133 void stopguprof(struct gmonparam
*p
);
135 #define startguprof(p)
136 #define stopguprof(p)
141 #include <sys/cdefs.h>
145 void mcount(void) __asm(".mcount");
152 /* XXX doesn't quite work outside kernel yet. */
153 extern int cputime_bias
;
157 void empty_loop(void);
158 void mexitcount(uintfptr_t selfpc
);
160 void nullfunc_loop(void);
164 #endif /* !_CPU_PROFILE_H_ */