xref: /original-bsd/lib/libc/sparc/SYS.h (revision c3e32dec)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  *
11  *	@(#)SYS.h	8.1 (Berkeley) 06/04/93
12  *
13  * from: $Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp $
14  */
15 
16 #include <sys/syscall.h>
17 #include <machine/trap.h>
18 
19 #ifdef PROF
20 #define	ENTRY(x) \
21 	.align 4; .globl _##x; .proc 1; _##x:; .data; .align 4; 1: .long 0; \
22 	.text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
23 	or %o0,%lo(1b),%o0; restore
24 #else
25 #define	ENTRY(x) \
26 	.align 4; .globl _##x; .proc 1; _##x:
27 #endif
28 
29 /*
30  * ERROR branches to cerror.  This is done with a macro so that I can
31  * change it to be position independent later, if need be.
32  */
33 #define	ERROR() \
34 	sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop
35 
36 /*
37  * SYSCALL is used when further action must be taken before returning.
38  * Note that it adds a `nop' over what we could do, if we only knew what
39  * came at label 1....
40  */
41 #define	SYSCALL(x) \
42 	ENTRY(x); mov SYS_##x,%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1:
43 
44 /*
45  * RSYSCALL is used when the system call should just return.  Here
46  * we use the SYSCALL_G2RFLAG to put the `success' return address in %g2
47  * and avoid a branch.
48  */
49 #define	RSYSCALL(x) \
50 	ENTRY(x); mov (SYS_##x)|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
51 	t ST_SYSCALL; ERROR()
52 
53 /*
54  * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x.
55  */
56 #define	PSEUDO(x,y) \
57 	ENTRY(x); mov (SYS_##y)|SYSCALL_G2RFLAG,%g1; add %o7,8,%g2; \
58 	t ST_SYSCALL; ERROR()
59 
60 #define	ASMSTR		.asciz
61 
62 	.globl	cerror
63