xref: /original-bsd/sys/i386/include/profile.h (revision 3705696b)
1 /*
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)profile.h	8.1 (Berkeley) 06/11/93
8  */
9 
10 #define	_MCOUNT_DECL static inline void _mcount
11 
12 #define	MCOUNT \
13 extern void mcount() asm("mcount"); void mcount() { \
14 	int selfpc, frompcindex; \
15 	/* \
16 	 * find the return address for mcount, \
17 	 * and the return address for mcount's caller. \
18 	 * \
19 	 * selfpc = pc pushed by mcount call \
20 	 */ \
21 	asm("movl 4(%%ebp),%0" : "=r" (selfpc)); \
22 	/* \
23 	 * frompcindex = pc pushed by jsr into self. \
24 	 * In GCC the caller's stack frame has already been built so we \
25 	 * have to chase a6 to find caller's raddr. \
26 	 */ \
27 	asm("movl (%%ebp),%0" : "=r" (frompcindex)); \
28 	frompcindex = ((int *)frompcindex)[1]; \
29 	_mcount(frompcindex, selfpc); \
30 }
31