SYS.h revision 1.9
11.9Swiz/*	$NetBSD: SYS.h,v 1.9 2002/05/26 12:24:59 wiz Exp $ */
21.1Sragge/*
31.1Sragge * Copyright (c) 1983, 1993
41.1Sragge *	The Regents of the University of California.  All rights reserved.
51.1Sragge *
61.1Sragge * Redistribution and use in source and binary forms, with or without
71.1Sragge * modification, are permitted provided that the following conditions
81.1Sragge * are met:
91.1Sragge * 1. Redistributions of source code must retain the above copyright
101.1Sragge *    notice, this list of conditions and the following disclaimer.
111.1Sragge * 2. Redistributions in binary form must reproduce the above copyright
121.1Sragge *    notice, this list of conditions and the following disclaimer in the
131.1Sragge *    documentation and/or other materials provided with the distribution.
141.1Sragge * 3. All advertising materials mentioning features or use of this software
151.1Sragge *    must display the following acknowledgement:
161.1Sragge *	This product includes software developed by the University of
171.1Sragge *	California, Berkeley and its contributors.
181.1Sragge * 4. Neither the name of the University nor the names of its contributors
191.1Sragge *    may be used to endorse or promote products derived from this software
201.1Sragge *    without specific prior written permission.
211.1Sragge *
221.1Sragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
231.1Sragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
241.1Sragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
251.1Sragge * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
261.1Sragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
271.1Sragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
281.1Sragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
291.1Sragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
301.1Sragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
311.1Sragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
321.1Sragge * SUCH DAMAGE.
331.1Sragge *
341.1Sragge *	@(#)SYS.h	8.1 (Berkeley) 6/4/93
351.1Sragge */
361.1Sragge
371.3Sjtc#include <machine/asm.h>
381.1Sragge#include <sys/syscall.h>
391.1Sragge
401.9Swiz#ifdef __STDC__
411.3Sjtc#define SYSTRAP(x)	chmk $ SYS_ ## x
421.9Swiz#else
431.9Swiz#define SYSTRAP(x)	chmk $ SYS_/**/x
441.9Swiz#endif
451.3Sjtc
461.4Skleink#define _SYSCALL_NOERROR(x,y)						\
471.4Skleink	ENTRY(x,0);							\
481.4Skleink	SYSTRAP(y)
491.4Skleink
501.4Skleink#define _SYSCALL(x,y)							\
511.6Smatt	err: nop; nop; jmp CERROR+2;					\
521.4Skleink	_SYSCALL_NOERROR(x,y);						\
531.5Smatt	jcs err+2
541.3Sjtc
551.4Skleink#define SYSCALL_NOERROR(x)						\
561.4Skleink	_SYSCALL_NOERROR(x,x)
571.2Sragge
581.4Skleink#define SYSCALL(x)							\
591.4Skleink	_SYSCALL(x,x)
601.2Sragge
611.4Skleink#define PSEUDO_NOERROR(x,y)						\
621.4Skleink	_SYSCALL_NOERROR(x,y);						\
631.3Sjtc	ret
641.4Skleink
651.4Skleink#define PSEUDO(x,y)							\
661.4Skleink	_SYSCALL(x,y);							\
671.3Sjtc	ret
681.4Skleink
691.4Skleink#define RSYSCALL_NOERROR(x)						\
701.4Skleink	PSEUDO_NOERROR(x,x)
711.4Skleink
721.4Skleink#define RSYSCALL(x)							\
731.4Skleink	PSEUDO(x,x)
741.7Sthorpej
751.7Sthorpej#ifdef WEAK_ALIAS
761.7Sthorpej#define	WSYSCALL(weak,strong)						\
771.7Sthorpej	WEAK_ALIAS(weak,strong);					\
781.7Sthorpej	PSEUDO(strong,weak)
791.7Sthorpej#else
801.7Sthorpej#define	WSYSCALL(weak,strong)						\
811.7Sthorpej	PSEUDO(weak,weak)
821.7Sthorpej#endif
831.1Sragge
841.1Sragge#define	ASMSTR		.asciz
851.1Sragge
861.6Smatt#ifdef __ELF__
871.6Smatt#define	CERROR	_C_LABEL(__cerror)
881.6Smatt#define	CURBRK	_C_LABEL(__curbrk)
891.6Smatt#else
901.6Smatt#define	CERROR	_ASM_LABEL(cerror)
911.6Smatt#define	CURBRK	_ASM_LABEL(curbrk)
921.6Smatt#endif
931.6Smatt
941.6Smatt	.globl	CERROR
95