155306Smckusick /* 2*63359Sbostic * Copyright (c) 1992, 1993 3*63359Sbostic * The Regents of the University of California. All rights reserved. 455306Smckusick * 555306Smckusick * %sccs.include.redist.c% 655306Smckusick * 7*63359Sbostic * @(#)profile.h 8.1 (Berkeley) 06/11/93 855306Smckusick */ 955306Smckusick 1055306Smckusick #define _MCOUNT_DECL static inline void _mcount 1155306Smckusick 1255306Smckusick #define MCOUNT \ 1355306Smckusick extern void mcount() asm("mcount"); void mcount() { \ 1455306Smckusick int selfpc, frompcindex; \ 1555306Smckusick /* \ 1655306Smckusick * find the return address for mcount, \ 1755306Smckusick * and the return address for mcount's caller. \ 1855306Smckusick * \ 1955306Smckusick * selfpc = pc pushed by mcount call \ 2055306Smckusick */ \ 2155306Smckusick asm("movl 4(%%ebp),%0" : "=r" (selfpc)); \ 2255306Smckusick /* \ 2355306Smckusick * frompcindex = pc pushed by jsr into self. \ 2455306Smckusick * In GCC the caller's stack frame has already been built so we \ 2555306Smckusick * have to chase a6 to find caller's raddr. \ 2655306Smckusick */ \ 2755306Smckusick asm("movl (%%ebp),%0" : "=r" (frompcindex)); \ 2860352Storek frompcindex = ((int *)frompcindex)[1]; \ 2955306Smckusick _mcount(frompcindex, selfpc); \ 3055306Smckusick } 31