asmacros.h revision 2579
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 *
332579Sbde *	$Id: asmacros.h,v 1.4 1994/08/19 11:20:11 jkh Exp $
341817Sdg */
351817Sdg
362579Sbde#ifndef _MACHINE_ASMACROS_H_
372579Sbde#define _MACHINE_ASMACROS_H_
382123Sjkh
392579Sbde#ifdef KERNEL
402579Sbde
41757Sdg#define ALIGN_DATA	.align	2	/* 4 byte alignment, zero filled */
42757Sdg#define ALIGN_TEXT	.align	2,0x90	/* 4-byte alignment, nop filled */
43757Sdg#define SUPERALIGN_TEXT	.align	4,0x90	/* 16-byte alignment (better for 486), nop filled */
44757Sdg
45757Sdg#define GEN_ENTRY(name)		ALIGN_TEXT;	.globl name; name:
46757Sdg#define NON_GPROF_ENTRY(name)	GEN_ENTRY(_/**/name)
47757Sdg
481321Sdg/* These three are place holders for future changes to the profiling code */
491321Sdg#define MCOUNT_LABEL(name)
501321Sdg#define MEXITCOUNT
511321Sdg#define FAKE_MCOUNT(caller)
521321Sdg
53757Sdg#ifdef GPROF
54757Sdg/*
55757Sdg * ALTENTRY() must be before a corresponding ENTRY() so that it can jump
56757Sdg * over the mcounting.
57757Sdg */
58757Sdg#define ALTENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; jmp 2f
59757Sdg#define ENTRY(name)	GEN_ENTRY(_/**/name); MCOUNT; 2:
60757Sdg/*
61757Sdg * The call to mcount supports the usual (bad) conventions.  We allocate
62757Sdg * some data and pass a pointer to it although the FreeBSD doesn't use
63757Sdg * the data.  We set up a frame before calling mcount because that is
64757Sdg * the standard convention although it makes work for both mcount and
65757Sdg * callers.
66757Sdg */
67757Sdg#define MCOUNT		.data; ALIGN_DATA; 1:; .long 0; .text; \
68757Sdg			pushl %ebp; movl %esp,%ebp; \
69757Sdg			movl $1b,%eax; call mcount; popl %ebp
70757Sdg#else
71757Sdg/*
72757Sdg * ALTENTRY() has to align because it is before a corresponding ENTRY().
73757Sdg * ENTRY() has to align to because there may be no ALTENTRY() before it.
74757Sdg * If there is a previous ALTENTRY() then the alignment code is empty.
75757Sdg */
76757Sdg#define ALTENTRY(name)	GEN_ENTRY(_/**/name)
77757Sdg#define ENTRY(name)	GEN_ENTRY(_/**/name)
781321Sdg#define MCOUNT
79757Sdg
80757Sdg#endif
81757Sdg
82757Sdg#ifdef DUMMY_NOPS			/* this will break some older machines */
83757Sdg#define FASTER_NOP
84757Sdg#define NOP
85757Sdg#else
86757Sdg#define FASTER_NOP	pushl %eax ; inb $0x84,%al ; popl %eax
87757Sdg#define NOP		pushl %eax ; inb $0x84,%al ; inb $0x84,%al ; popl %eax
88757Sdg#endif
89757Sdg
902579Sbde#else /* !KERNEL */
912579Sbde
922579Sbde#include "/usr/src/lib/libc/i386/DEFS.h"	/* XXX blech */
932579Sbde
942123Sjkh#ifndef RCSID
952123Sjkh#define RCSID(a)
962123Sjkh#endif
972123Sjkh
982579Sbde#endif /* KERNEL */
992579Sbde
1002579Sbde#endif /* !_MACHINE_ASMACROS_H_ */
101