1 /* $OpenBSD: profile.h,v 1.2 1999/01/27 04:46:05 imp Exp $ */
2 /*-
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Ralph Campbell.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * from: @(#)profile.h 8.1 (Berkeley) 6/10/93
34 * JNPR: profile.h,v 1.4 2006/12/02 09:53:41 katta
35 * $FreeBSD$
36 */
37 #ifndef _MACHINE_PROFILE_H_
38 #define _MACHINE_PROFILE_H_
39
40 #define _MCOUNT_DECL void ___mcount
41
42 /*XXX The cprestore instruction is a "dummy" to shut up as(1). */
43
44 /*XXX This is not MIPS64 safe. */
45
46 #define MCOUNT \
47 __asm(".text;" \
48 ".globl _mcount;" \
49 ".type _mcount,@function;" \
50 "_mcount:;" \
51 ".set noreorder;" \
52 ".set noat;" \
53 ".cpload $25;" \
54 ".cprestore 4;" \
55 "sw $4,8($29);" \
56 "sw $5,12($29);" \
57 "sw $6,16($29);" \
58 "sw $7,20($29);" \
59 "sw $1,0($29);" \
60 "sw $31,4($29);" \
61 "move $5,$31;" \
62 "jal ___mcount;" \
63 "move $4,$1;" \
64 "lw $4,8($29);" \
65 "lw $5,12($29);" \
66 "lw $6,16($29);" \
67 "lw $7,20($29);" \
68 "lw $31,4($29);" \
69 "lw $1,0($29);" \
70 "addu $29,$29,8;" \
71 "j $31;" \
72 "move $31,$1;" \
73 ".set reorder;" \
74 ".set at");
75
76 #ifdef _KERNEL
77 /*
78 * The following two macros do splhigh and splx respectively.
79 * They have to be defined this way because these are real
80 * functions on the MIPS, and we do not want to invoke mcount
81 * recursively.
82 */
83
84 #define MCOUNT_DECL(s) u_long s;
85 #ifdef SMP
86 extern int mcount_lock;
87 #define MCOUNT_ENTER(s) { \
88 s = intr_disable(); \
89 while (!atomic_cmpset_acq_int(&mcount_lock, 0, 1)) \
90 /* nothing */ ; \
91 }
92 #define MCOUNT_EXIT(s) { \
93 atomic_store_rel_int(&mcount_lock, 0); \
94 intr_restore(s); \
95 }
96 #else
97 #define MCOUNT_ENTER(s) { s = intr_disable(); }
98 #define MCOUNT_EXIT(s) (intr_restore(s))
99 #endif
100
101 /* REVISIT for mips */
102 /*
103 * Config generates something to tell the compiler to align functions on 16
104 * byte boundaries. A strict alignment is good for keeping the tables small.
105 */
106 #define FUNCTION_ALIGNMENT 16
107
108 #ifdef GUPROF
109 struct gmonparam;
110 void stopguprof __P((struct gmonparam *p));
111 #else
112 #define stopguprof(p)
113 #endif /* GUPROF */
114
115 #else /* !_KERNEL */
116
117 #define FUNCTION_ALIGNMENT 4
118
119 #ifdef __mips_n64
120 typedef u_long uintfptr_t;
121 #else
122 typedef u_int uintfptr_t;
123 #endif
124
125 #endif /* _KERNEL */
126
127 /*
128 * An unsigned integral type that can hold non-negative difference between
129 * function pointers.
130 */
131 #ifdef __mips_n64
132 typedef u_long fptrdiff_t;
133 #else
134 typedef u_int fptrdiff_t;
135 #endif
136
137 #ifdef _KERNEL
138
139 void mcount(uintfptr_t frompc, uintfptr_t selfpc);
140
141 #ifdef GUPROF
142 struct gmonparam;
143
144 void nullfunc_loop_profiled(void);
145 void nullfunc_profiled(void);
146 void startguprof(struct gmonparam *p);
147 void stopguprof(struct gmonparam *p);
148 #else
149 #define startguprof(p)
150 #define stopguprof(p)
151 #endif /* GUPROF */
152
153 #else /* !_KERNEL */
154
155 #include <sys/cdefs.h>
156
157 __BEGIN_DECLS
158 #ifdef __GNUC__
159 #ifdef __ELF__
160 void mcount(void) __asm(".mcount");
161 #else
162 void mcount(void) __asm("mcount");
163 #endif
164 #endif
165 void _mcount(uintfptr_t frompc, uintfptr_t selfpc);
166 __END_DECLS
167
168 #endif /* _KERNEL */
169
170 #ifdef GUPROF
171 /* XXX doesn't quite work outside kernel yet. */
172 extern int cputime_bias;
173
174 __BEGIN_DECLS
175 int cputime(void);
176 void empty_loop(void);
177 void mexitcount(uintfptr_t selfpc);
178 void nullfunc(void);
179 void nullfunc_loop(void);
180 __END_DECLS
181 #endif
182
183 #endif /* !_MACHINE_PROFILE_H_ */
Cache object: 066e856684b103e7d41f74bc99f773fa
|