Home | History | Annotate | Line # | Download | only in i386
SYS.h revision 1.20
      1   1.1      cgd /*-
      2   1.1      cgd  * Copyright (c) 1990 The Regents of the University of California.
      3   1.1      cgd  * All rights reserved.
      4   1.1      cgd  *
      5   1.1      cgd  * This code is derived from software contributed to Berkeley by
      6   1.1      cgd  * William Jolitz.
      7   1.1      cgd  *
      8   1.1      cgd  * Redistribution and use in source and binary forms, with or without
      9   1.1      cgd  * modification, are permitted provided that the following conditions
     10   1.1      cgd  * are met:
     11   1.1      cgd  * 1. Redistributions of source code must retain the above copyright
     12   1.1      cgd  *    notice, this list of conditions and the following disclaimer.
     13   1.1      cgd  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1      cgd  *    notice, this list of conditions and the following disclaimer in the
     15   1.1      cgd  *    documentation and/or other materials provided with the distribution.
     16  1.20      agc  * 3. Neither the name of the University nor the names of its contributors
     17   1.1      cgd  *    may be used to endorse or promote products derived from this software
     18   1.1      cgd  *    without specific prior written permission.
     19   1.1      cgd  *
     20   1.1      cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     21   1.1      cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     22   1.1      cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     23   1.1      cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     24   1.1      cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     25   1.1      cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     26   1.1      cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     27   1.1      cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     28   1.1      cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29   1.1      cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30   1.1      cgd  * SUCH DAMAGE.
     31   1.1      cgd  *
     32   1.1      cgd  *	from: @(#)SYS.h	5.5 (Berkeley) 5/7/91
     33  1.20      agc  *	$NetBSD: SYS.h,v 1.20 2003/08/07 16:42:06 agc Exp $
     34   1.1      cgd  */
     35   1.1      cgd 
     36   1.1      cgd #include <machine/asm.h>
     37   1.1      cgd #include <sys/syscall.h>
     38   1.1      cgd 
     39  1.19      wiz #ifdef __STDC__
     40  1.10      jtc #define SYSTRAP(x)	movl $(SYS_ ## x),%eax; int $0x80
     41  1.19      wiz #else
     42  1.19      wiz #define SYSTRAP(x)	movl $(SYS_/**/x),%eax; int $0x80
     43  1.19      wiz #endif
     44   1.8      jtc 
     45  1.12   kleink #ifdef __ELF__
     46  1.12   kleink #define CERROR		_C_LABEL(__cerror)
     47  1.12   kleink #define CURBRK		_C_LABEL(__curbrk)
     48  1.12   kleink #else
     49  1.12   kleink #define CERROR		_ASM_LABEL(cerror)
     50  1.12   kleink #define CURBRK		_ASM_LABEL(curbrk)
     51  1.12   kleink #endif
     52   1.8      jtc 
     53  1.11   kleink #define _SYSCALL_NOERROR(x,y)						\
     54  1.11   kleink 	ENTRY(x);							\
     55  1.11   kleink 	SYSTRAP(y)
     56  1.11   kleink 
     57  1.15  mycroft #ifdef PIC
     58  1.11   kleink #define _SYSCALL(x,y)							\
     59  1.14   kleink 	.text; _ALIGN_TEXT;						\
     60  1.15  mycroft 	2: PIC_PROLOGUE;						\
     61  1.15  mycroft 	   mov PIC_GOT(CERROR), %ecx;					\
     62  1.15  mycroft 	   PIC_EPILOGUE;						\
     63  1.17     ross 	   jmp *%ecx;							\
     64  1.11   kleink 	_SYSCALL_NOERROR(x,y);						\
     65  1.11   kleink 	jc 2b
     66  1.15  mycroft #else
     67  1.15  mycroft #define _SYSCALL(x,y)							\
     68  1.15  mycroft 	.text; _ALIGN_TEXT;						\
     69  1.15  mycroft 	2: jmp CERROR;							\
     70  1.15  mycroft 	_SYSCALL_NOERROR(x,y);						\
     71  1.15  mycroft 	jc 2b
     72  1.15  mycroft #endif
     73  1.10      jtc 
     74  1.11   kleink #define SYSCALL_NOERROR(x)						\
     75  1.11   kleink 	_SYSCALL_NOERROR(x,x)
     76  1.11   kleink 
     77  1.11   kleink #define SYSCALL(x)							\
     78  1.11   kleink 	_SYSCALL(x,x)
     79  1.11   kleink 
     80  1.11   kleink #define PSEUDO_NOERROR(x,y)						\
     81  1.11   kleink 	_SYSCALL_NOERROR(x,y);						\
     82  1.10      jtc 	ret
     83  1.10      jtc 
     84  1.11   kleink #define PSEUDO(x,y)							\
     85  1.11   kleink 	_SYSCALL(x,y);							\
     86  1.10      jtc 	ret
     87  1.10      jtc 
     88  1.11   kleink #define RSYSCALL_NOERROR(x)						\
     89  1.11   kleink 	PSEUDO_NOERROR(x,x)
     90  1.11   kleink 
     91  1.11   kleink #define RSYSCALL(x)							\
     92  1.11   kleink 	PSEUDO(x,x)
     93  1.11   kleink 
     94  1.16  thorpej #ifdef WEAK_ALIAS
     95  1.16  thorpej #define	WSYSCALL(weak,strong)						\
     96  1.16  thorpej 	WEAK_ALIAS(weak,strong);					\
     97  1.16  thorpej 	PSEUDO(strong,weak)
     98  1.16  thorpej #else
     99  1.16  thorpej #define	WSYSCALL(weak,strong)						\
    100  1.16  thorpej 	PSEUDO(weak,weak)
    101  1.16  thorpej #endif
    102   1.1      cgd 
    103  1.12   kleink 	.globl	CERROR
    104