xref: /dragonfly/sys/cpu/x86_64/include/profile.h (revision 49837aef)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
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.
16  *
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
27  * SUCH DAMAGE.
28  *
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 $
31  */
32 
33 #ifndef _CPU_PROFILE_H_
34 #define	_CPU_PROFILE_H_
35 
36 #include <sys/cdefs.h>
37 
38 #define	FUNCTION_ALIGNMENT	4
39 
40 #define	_MCOUNT_DECL \
41 static void _mcount(u_long frompc, u_long selfpc) __used; \
42 static void _mcount
43 
44 #ifdef	__GNUC__
45 #define	MCOUNT __asm("			\n\
46 	.text				\n\
47 	.p2align 4,0x90			\n\
48 	.globl	.mcount			\n\
49 	.type	.mcount,@function	\n\
50 .mcount:				\n\
51 	pushq	%rdi			\n\
52 	pushq	%rsi			\n\
53 	pushq	%rdx			\n\
54 	pushq	%rcx			\n\
55 	pushq	%r8			\n\
56 	pushq	%r9			\n\
57 	pushq	%rax			\n\
58 	movq	8(%rbp),%rdi		\n\
59 	movq	7*8(%rsp),%rsi		\n\
60 	call	_mcount			\n\
61 	popq	%rax			\n\
62 	popq	%r9			\n\
63 	popq	%r8			\n\
64 	popq	%rcx			\n\
65 	popq	%rdx			\n\
66 	popq	%rsi			\n\
67 	popq	%rdi			\n\
68 	ret				\n\
69 	.size	.mcount, . - .mcount");
70 #else	/* __GNUC__ */
71 #define	MCOUNT		\
72 void			\
73 mcount()		\
74 {			\
75 }
76 #endif	/* __GNUC__ */
77 
78 __BEGIN_DECLS
79 #ifdef __GNUC__
80 void	mcount(void) __asm(".mcount");
81 #endif
82 __END_DECLS
83 
84 #endif /* !_CPU_PROFILE_H_ */
85