1*e0c16185Smartin /* $NetBSD: profile.h,v 1.17 2017/05/31 11:09:22 martin Exp $ */ 2274a9076Sderaadt 34588caefSderaadt /* 44588caefSderaadt * Copyright (c) 1992, 1993 54588caefSderaadt * The Regents of the University of California. All rights reserved. 64588caefSderaadt * 74588caefSderaadt * This software was developed by the Computer Systems Engineering group 84588caefSderaadt * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 94588caefSderaadt * contributed to Berkeley. 104588caefSderaadt * 114588caefSderaadt * All advertising materials mentioning features or use of this software 124588caefSderaadt * must display the following acknowledgement: 134588caefSderaadt * This product includes software developed by the University of 144588caefSderaadt * California, Lawrence Berkeley Laboratory. 154588caefSderaadt * 164588caefSderaadt * Redistribution and use in source and binary forms, with or without 174588caefSderaadt * modification, are permitted provided that the following conditions 184588caefSderaadt * are met: 194588caefSderaadt * 1. Redistributions of source code must retain the above copyright 204588caefSderaadt * notice, this list of conditions and the following disclaimer. 214588caefSderaadt * 2. Redistributions in binary form must reproduce the above copyright 224588caefSderaadt * notice, this list of conditions and the following disclaimer in the 234588caefSderaadt * documentation and/or other materials provided with the distribution. 24aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 254588caefSderaadt * may be used to endorse or promote products derived from this software 264588caefSderaadt * without specific prior written permission. 274588caefSderaadt * 284588caefSderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 294588caefSderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 304588caefSderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 314588caefSderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 324588caefSderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 334588caefSderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 344588caefSderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 354588caefSderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 364588caefSderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 374588caefSderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 384588caefSderaadt * SUCH DAMAGE. 394588caefSderaadt * 404588caefSderaadt * @(#)profile.h 8.1 (Berkeley) 6/11/93 414588caefSderaadt */ 424588caefSderaadt 43d30ef27fSchristos #ifdef __ELF__ 44725b3015Stv #define _MCOUNT_SYM "__mcount" 4588ff6897Sthorpej #define _MCOUNT_ENTRY "_mcount" 4688ff6897Sthorpej #else 4788ff6897Sthorpej #define _MCOUNT_SYM "___mcount" 4888ff6897Sthorpej #define _MCOUNT_ENTRY "mcount" 49725b3015Stv #endif 50725b3015Stv 514d12bfcdSjoerg #ifdef __PIC__ 52de80daa3Spk /* Inline expansion of PICCY_SET() (see <machine/asm.h>). */ 5344a3eec3Smrg #ifdef __arch64__ 5444a3eec3Smrg #define MCOUNT \ 5550a256a3Sperry __asm(".global " _MCOUNT_ENTRY);\ 5650a256a3Sperry __asm(_MCOUNT_ENTRY ":");\ 5750a256a3Sperry __asm("add %o7, 8, %o1");\ 5850a256a3Sperry __asm("1: rd %pc, %o2");\ 5950a256a3Sperry __asm("add %o2," _MCOUNT_SYM "-1b, %o2");\ 6050a256a3Sperry __asm("jmpl %o2, %g0");\ 6150a256a3Sperry __asm("add %i7, 8, %o0"); 6244a3eec3Smrg #else 63de80daa3Spk #define MCOUNT \ 6450a256a3Sperry __asm(".global " _MCOUNT_ENTRY);\ 6550a256a3Sperry __asm(_MCOUNT_ENTRY ":");\ 6650a256a3Sperry __asm("add %o7, 8, %o1");\ 67*e0c16185Smartin __asm("mov %o7, %o3");\ 6850a256a3Sperry __asm("1: call 2f; nop; 2:");\ 6950a256a3Sperry __asm("add %o7," _MCOUNT_SYM "-1b, %o2");\ 70*e0c16185Smartin __asm("mov %o3, %o7");\ 7150a256a3Sperry __asm("jmpl %o2, %g0");\ 7250a256a3Sperry __asm("add %i7, 8, %o0"); 7344a3eec3Smrg #endif 74de80daa3Spk #else 754588caefSderaadt #define MCOUNT \ 7650a256a3Sperry __asm(".global " _MCOUNT_ENTRY);\ 7750a256a3Sperry __asm(_MCOUNT_ENTRY ":");\ 7850a256a3Sperry __asm("add %i7, 8, %o0");\ 7950a256a3Sperry __asm("sethi %hi(" _MCOUNT_SYM "), %o2");\ 8050a256a3Sperry __asm("jmpl %o2 + %lo(" _MCOUNT_SYM "), %g0");\ 8150a256a3Sperry __asm("add %o7, 8, %o1"); 82de80daa3Spk #endif 834588caefSderaadt 8488ff6897Sthorpej #define _MCOUNT_DECL static void __mcount 854588caefSderaadt 8671ab4ed9Sjtc #ifdef _KERNEL 874588caefSderaadt /* 884588caefSderaadt * Block interrupts during mcount so that those interrupts can also be 894588caefSderaadt * counted (as soon as we get done with the current counting). On the 904588caefSderaadt * SPARC, we just splhigh/splx as those do not recursively invoke mcount. 914588caefSderaadt */ 924588caefSderaadt #define MCOUNT_ENTER s = splhigh() 934588caefSderaadt #define MCOUNT_EXIT splx(s) 9471ab4ed9Sjtc #endif /* _KERNEL */ 95