xref: /csrg-svn/lib/libc/sparc/SYS.h (revision 54382)
1*54382Storek /*-
2*54382Storek  * %sccs.include.redist.c%
3*54382Storek  *
4*54382Storek  *	@(#)SYS.h	5.1 (Berkeley) 06/25/92
5*54382Storek  */
6*54382Storek 
7*54382Storek #include <sys/syscall.h>
8*54382Storek #include <machine/trap.h>
9*54382Storek 
10*54382Storek #ifdef PROF
11*54382Storek #define	ENTRY(x) \
12*54382Storek 	.align 4; .globl _##x; .proc 1; _##x:; .data; .align 4; 1: .long 0; \
13*54382Storek 	.text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
14*54382Storek 	or %o0,%lo(1b),%o0; restore
15*54382Storek #else
16*54382Storek #define	ENTRY(x) \
17*54382Storek 	.align 4; .globl _##x; .proc 1; _##x:
18*54382Storek #endif
19*54382Storek 
20*54382Storek /*
21*54382Storek  * ERROR branches to cerror.  This is done with a macro so that I can
22*54382Storek  * change it to be position independent later, if need be.
23*54382Storek  */
24*54382Storek #define	ERROR() \
25*54382Storek 	sethi %hi(cerror),%g1; or %lo(cerror),%g1,%g1; jmp %g1; nop
26*54382Storek 
27*54382Storek /*
28*54382Storek  * SYSCALL is used when further action must be taken before returning.
29*54382Storek  * Note that it adds a `nop' over what we could do, if we only knew what
30*54382Storek  * came at label 1....
31*54382Storek  */
32*54382Storek #define	SYSCALL(x) \
33*54382Storek 	ENTRY(x); mov SYS_##x,%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1:
34*54382Storek 
35*54382Storek /*
36*54382Storek  * RSYSCALL is used when the system call should just return.  Here
37*54382Storek  * we use the SYSCALL_RFLAG to put the `success' return address in %g7
38*54382Storek  * and avoid a branch.
39*54382Storek  */
40*54382Storek #define	RSYSCALL(x) \
41*54382Storek 	ENTRY(x); mov (SYS_##x)|SYSCALL_RFLAG,%g1; add %o7,8,%g7; \
42*54382Storek 	t ST_SYSCALL; ERROR()
43*54382Storek 
44*54382Storek /*
45*54382Storek  * PSEUDO(x,y) is like  RSYSCALL(y) except that the name is x.
46*54382Storek  */
47*54382Storek #define	PSEUDO(x,y) \
48*54382Storek 	ENTRY(x); mov (SYS_##y)|SYSCALL_RFLAG,%g1; add %o7,8,%g7; \
49*54382Storek 	t ST_SYSCALL; ERROR()
50*54382Storek 
51*54382Storek #define	ASMSTR		.asciz
52*54382Storek 
53*54382Storek 	.globl	cerror
54