Annotation of sys/arch/sparc/include/asm.h, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: asm.h,v 1.4 2003/06/04 22:08:17 deraadt Exp $ */
! 2: /* $NetBSD: asm.h,v 1.5 1997/07/16 15:16:43 christos Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1994 Allen Briggs
! 6: * All rights reserved.
! 7: *
! 8: * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
! 9: * locore.s:
! 10: * Copyright (c) 1988 University of Utah.
! 11: * Copyright (c) 1982, 1990 The Regents of the University of California.
! 12: * sun3/include/asm.h:
! 13: * Copyright (c) 1993 Adam Glass
! 14: * Copyright (c) 1990 The Regents of the University of California.
! 15: *
! 16: * Redistribution and use in source and binary forms, with or without
! 17: * modification, are permitted provided that the following conditions
! 18: * are met:
! 19: * 1. Redistributions of source code must retain the above copyright
! 20: * notice, this list of conditions and the following disclaimer.
! 21: * 2. Redistributions in binary form must reproduce the above copyright
! 22: * notice, this list of conditions and the following disclaimer in the
! 23: * documentation and/or other materials provided with the distribution.
! 24: * 3. Neither the name of the University nor the names of its contributors
! 25: * may be used to endorse or promote products derived from this software
! 26: * without specific prior written permission.
! 27: *
! 28: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 29: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 30: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 31: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 32: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 33: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 34: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 35: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 36: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 37: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 38: * SUCH DAMAGE.
! 39: */
! 40:
! 41: #ifndef _ASM_H_
! 42: #define _ASM_H_
! 43:
! 44: #ifdef __ELF__
! 45: #define _C_LABEL(name) name
! 46: #else
! 47: #ifdef __STDC__
! 48: #define _C_LABEL(name) _ ## name
! 49: #else
! 50: #define _C_LABEL(name) _/**/name
! 51: #endif
! 52: #endif
! 53: #define _ASM_LABEL(name) name
! 54:
! 55: /*
! 56: * WEAK_ALIAS: create a weak alias (ELF only)
! 57: */
! 58: #ifdef __ELF__
! 59: #define WEAK_ALIAS(alias,sym) \
! 60: .weak alias; \
! 61: alias = sym
! 62: #endif
! 63:
! 64: /*
! 65: * WARN_REFERENCES: create a warning if the specified symbol is referenced
! 66: * (ELF only).
! 67: */
! 68: #ifdef __ELF__
! 69: #define WARN_REFERENCES(_sym,_msg) \
! 70: .section .gnu.warning. ## _sym ; .ascii _msg ; .text
! 71: #endif /* __ELF__ */
! 72:
! 73:
! 74: #ifdef PIC
! 75: /*
! 76: * PIC_PROLOGUE() is akin to the compiler generated function prologue for
! 77: * PIC code. It leaves the address of the Global Offset Table in DEST,
! 78: * clobbering register TMP in the process. Using the temporary enables us
! 79: * to work without a stack frame (doing so requires saving %o7) .
! 80: */
! 81: #define PIC_PROLOGUE(dest,tmp) \
! 82: mov %o7,tmp; 3: call 4f; nop; 4: \
! 83: sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
! 84: or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
! 85: add dest,%o7,dest; mov tmp,%o7
! 86:
! 87: /*
! 88: * PICCY_SET() does the equivalent of a `set var, %dest' instruction in
! 89: * a PIC-like way, but without involving the Global Offset Table. This
! 90: * only works for VARs defined in the same file *and* in the text segment.
! 91: */
! 92: #define PICCY_SET(var,dest,tmp) \
! 93: mov %o7,tmp; 3: call 4f; nop; 4: \
! 94: add %o7,(var-3b),dest; mov tmp,%o7
! 95: #else
! 96: #define PIC_PROLOGUE(dest,tmp)
! 97: #define PICCY_OFFSET(var,dest,tmp)
! 98: #endif
! 99:
! 100: #define FTYPE(x) .type x,@function
! 101: #define OTYPE(x) .type x,@object
! 102:
! 103: #define _ENTRY(name) \
! 104: .align 4; .globl name; .proc 1; FTYPE(name); name:
! 105:
! 106: #ifdef GPROF
! 107: #define _PROF_PROLOGUE \
! 108: .data; .align 4; 1: .long 0; \
! 109: .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
! 110: or %o0,%lo(1b),%o0; restore
! 111: #else
! 112: #define _PROF_PROLOGUE
! 113: #endif
! 114:
! 115: #define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE
! 116: #define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE
! 117: #define FUNC(name) ASENTRY(name)
! 118:
! 119:
! 120: #define ASMSTR .asciz
! 121:
! 122: #define RCSID(name) .asciz name
! 123:
! 124: #endif /* _ASM_H_ */
CVSweb