profile.h revision 1.5
11.5Suwe/*	$NetBSD: profile.h,v 1.5 2006/10/26 23:54:28 uwe Exp $	*/
21.1Sitojun
31.2Stsubai/*-
41.2Stsubai * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
51.1Sitojun *
61.1Sitojun * Redistribution and use in source and binary forms, with or without
71.1Sitojun * modification, are permitted provided that the following conditions
81.1Sitojun * are met:
91.1Sitojun * 1. Redistributions of source code must retain the above copyright
101.1Sitojun *    notice, this list of conditions and the following disclaimer.
111.1Sitojun * 2. Redistributions in binary form must reproduce the above copyright
121.1Sitojun *    notice, this list of conditions and the following disclaimer in the
131.1Sitojun *    documentation and/or other materials provided with the distribution.
141.2Stsubai * 3. The name of the author may not be used to endorse or promote products
151.2Stsubai *    derived from this software without specific prior written permission.
161.1Sitojun *
171.2Stsubai * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181.2Stsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191.2Stsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201.2Stsubai * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211.2Stsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221.2Stsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231.2Stsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241.2Stsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251.2Stsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261.2Stsubai * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271.1Sitojun */
281.1Sitojun
291.3Sthorpej#if defined(__ELF__) && defined(__NO_LEADING_UNDERSCORES__)
301.3Sthorpej#define	_MCOUNT_DECL static void _mcount
311.3Sthorpej#else
321.4Such#define	_MCOUNT_DECL static void mcount
331.3Sthorpej#endif
341.1Sitojun
351.5Suwe#define	MCOUNT __asm ("				\n\
361.5Suwe	.text					\n\
371.5Suwe	.align	2				\n\
381.5Suwe	.globl	__mcount			\n\
391.5Suwe__mcount:					\n\
401.5Suwe	mov.l	r4, @-r15			\n\
411.5Suwe	mov.l	r5, @-r15			\n\
421.5Suwe	mov.l	r6, @-r15			\n\
431.5Suwe	mov.l	r7, @-r15			\n\
441.5Suwe	mov.l	r0, @-r15			\n\
451.5Suwe	mov.l	r14, @-r15			\n\
461.5Suwe	sts.l	pr, @-r15			\n\
471.5Suwe	mov	r15, r14			\n\
481.5Suwe						\n\
491.5Suwe	mov.l	1f, r1		! _mcount	\n\
501.5Suwe	sts	pr, r4		! frompc	\n\
511.5Suwe0:	bsrf	r1				\n\
521.5Suwe	 mov	r0, r5		! selfpc	\n\
531.5Suwe						\n\
541.5Suwe	mov	r14, r15			\n\
551.5Suwe	lds.l	@r15+, pr			\n\
561.5Suwe	mov.l	@r15+, r14			\n\
571.5Suwe	mov.l	@r15+, r0			\n\
581.5Suwe	mov.l	@r15+, r7			\n\
591.5Suwe	mov.l	@r15+, r6			\n\
601.5Suwe	mov.l	@r15+, r5			\n\
611.5Suwe	jmp	@r0		! real fucntion	\n\
621.5Suwe	 mov.l	@r15+, r4			\n\
631.5Suwe						\n\
641.5Suwe	.align	2				\n\
651.5Suwe1:	.long	_mcount - ((0b) + 4)		\n\
661.5Suwe						\n\
671.5Suwe	.size	__mcount, . - __mcount		");
681.1Sitojun
691.1Sitojun#ifdef _KERNEL
701.4Such#define	MCOUNT_ENTER	s = splhigh()
711.4Such#define	MCOUNT_EXIT	splx(s)
721.2Stsubai#endif
73