asmacros.h revision 2123
11817Sdg/*-
21817Sdg * Copyright (c) 1993 The Regents of the University of California.
31817Sdg * All rights reserved.
41817Sdg *
51817Sdg * Redistribution and use in source and binary forms, with or without
61817Sdg * modification, are permitted provided that the following conditions
71817Sdg * are met:
81817Sdg * 1. Redistributions of source code must retain the above copyright
91817Sdg *    notice, this list of conditions and the following disclaimer.
101817Sdg * 2. Redistributions in binary form must reproduce the above copyright
111817Sdg *    notice, this list of conditions and the following disclaimer in the
121817Sdg *    documentation and/or other materials provided with the distribution.
131817Sdg * 3. All advertising materials mentioning features or use of this software
141817Sdg *    must display the following acknowledgement:
151817Sdg *	This product includes software developed by the University of
161817Sdg *	California, Berkeley and its contributors.
171817Sdg * 4. Neither the name of the University nor the names of its contributors
181817Sdg *    may be used to endorse or promote products derived from this software
191817Sdg *    without specific prior written permission.
201817Sdg *
211817Sdg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221817Sdg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231817Sdg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241817Sdg * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251817Sdg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261817Sdg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271817Sdg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281817Sdg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291817Sdg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301817Sdg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311817Sdg * SUCH DAMAGE.
321817Sdg *
332123Sjkh *	$Id: asmacros.h,v 1.3 1994/08/02 07:38:40 davidg Exp $
341817Sdg */
351817Sdg
362123Sjkh#ifndef _ASMACROS_H_
372123Sjkh#define _ASMACROS_H_	1
382123Sjkh
39757Sdg#define ALIGN_DATA	.align	2	/* 4 byte alignment, zero filled */
40757Sdg#define ALIGN_TEXT	.align	2,0x90	/* 4-byte alignment, nop filled */
41757Sdg#define SUPERALIGN_TEXT	.align	4,0x90	/* 16-byte alignment (better for 486), nop filled */
42757Sdg
43757Sdg#define GEN_ENTRY(name)		ALIGN_TEXT;	.globl name; name:
44757Sdg#define NON_GPROF_ENTRY(name)	GEN_ENTRY(_/**/name)
45757Sdg
461321Sdg/* These three are place holders for future changes to the profiling code */
471321Sdg#define MCOUNT_LABEL(name)
481321Sdg#define MEXITCOUNT
491321Sdg#define FAKE_MCOUNT(caller)
501321Sdg
51757Sdg#ifdef GPROF
52757Sdg/*
53757Sdg * ALTENTRY() must be before a corresponding ENTRY() so that it can jump
54757Sdg * over the mcounting.
55757Sdg */
56757Sdg#define ALTENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; jmp 2f
57757Sdg#define ENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; 2:
58757Sdg/*
59757Sdg * The call to mcount supports the usual (bad) conventions.  We allocate
60757Sdg * some data and pass a pointer to it although the FreeBSD doesn't use
61757Sdg * the data.  We set up a frame before calling mcount because that is
62757Sdg * the standard convention although it makes work for both mcount and
63757Sdg * callers.
64757Sdg */
65757Sdg#define MCOUNT		.data; ALIGN_DATA; 1:; .long 0; .text; \
66757Sdg			pushl %ebp; movl %esp,%ebp; \
67757Sdg			movl $1b,%eax; call mcount; popl %ebp
68757Sdg#else
69757Sdg/*
70757Sdg * ALTENTRY() has to align because it is before a corresponding ENTRY().
71757Sdg * ENTRY() has to align to because there may be no ALTENTRY() before it.
72757Sdg * If there is a previous ALTENTRY() then the alignment code is empty.
73757Sdg */
74757Sdg#define ALTENTRY(name)	GEN_ENTRY(_/**/name)
75757Sdg#define ENTRY(name)	GEN_ENTRY(_/**/name)
761321Sdg#define MCOUNT
77757Sdg
78757Sdg#endif
79757Sdg
80757Sdg#ifdef DUMMY_NOPS			/* this will break some older machines */
81757Sdg#define FASTER_NOP
82757Sdg#define NOP
83757Sdg#else
84757Sdg#define FASTER_NOP	pushl %eax ; inb $0x84,%al ; popl %eax
85757Sdg#define NOP		pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax
86757Sdg#endif
87757Sdg
882123Sjkh#ifndef RCSID
892123Sjkh#define RCSID(a)
902123Sjkh#endif
912123Sjkh
922123Sjkh#endif	/* _ASMACROS_H_ */
93