]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/alpha/SYS.h
This commit was generated by cvs2svn to compensate for changes in r50397,
[FreeBSD/FreeBSD.git] / lib / libc / alpha / SYS.h
1 /* $Id: SYS.h,v 1.4 1998/12/23 11:50:51 dfr Exp $ */
2 /*      From: NetBSD: SYS.h,v 1.5 1997/05/02 18:15:15 kleink Exp */
3
4 /*
5  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
6  * All rights reserved.
7  *
8  * Author: Chris G. Demetriou
9  * 
10  * Permission to use, copy, modify and distribute this software and
11  * its documentation is hereby granted, provided that both the copyright
12  * notice and this permission notice appear in all copies of the
13  * software, derivative works or modified versions, and any portions
14  * thereof, and that both notices appear in supporting documentation.
15  * 
16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19  * 
20  * Carnegie Mellon requests users of this software to return to
21  *
22  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23  *  School of Computer Science
24  *  Carnegie Mellon University
25  *  Pittsburgh PA 15213-3890
26  *
27  * any improvements or extensions that they make and grant Carnegie the
28  * rights to redistribute these changes.
29  */
30
31 #include <machine/asm.h>
32 #ifdef __NETBSD_SYSCALLS
33 #include <sys/netbsd_syscall.h>
34 #else
35 #include <sys/syscall.h>
36 #endif
37
38 #define CALLSYS_ERROR(name)                                     \
39         CALLSYS_NOERROR(name);                                  \
40         br      gp, LLABEL(name,0);                             \
41 LLABEL(name,0):                                                 \
42         LDGP(gp);                                               \
43         beq     a3, LLABEL(name,1);                             \
44         jmp     zero, .cerror;                                  \
45 LLABEL(name,1):
46
47
48 #define SYSCALL(name)                                           \
49 LEAF(name,0);                           /* XXX # of args? */    \
50         CALLSYS_ERROR(name)
51
52 #define SYSCALL_NOERROR(name)                                   \
53 LEAF(name,0);                           /* XXX # of args? */    \
54         CALLSYS_NOERROR(name)
55
56
57 #define RSYSCALL(name)                                          \
58         SYSCALL(name);                                          \
59         RET;                                                    \
60 END(name)
61
62 #define RSYSCALL_NOERROR(name)                                  \
63         SYSCALL_NOERROR(name);                                  \
64         RET;                                                    \
65 END(name)
66
67
68 #define PSEUDO(label,name)                                      \
69 LEAF(label,0);                          /* XXX # of args? */    \
70         CALLSYS_ERROR(name);                                    \
71         RET;                                                    \
72 END(label);
73
74 #define PSEUDO_NOERROR(label,name)                              \
75 LEAF(label,0);                          /* XXX # of args? */    \
76         CALLSYS_NOERROR(name);                                  \
77         RET;                                                    \
78 END(label);
79
80 /*
81  * Design note:
82  *
83  * The macros PSYSCALL() and PRSYSCALL() are intended for use where a
84  * syscall needs to be renamed in the threaded library. When building
85  * a normal library, they default to the traditional SYSCALL() and
86  * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
87  * that the renamed function needs to be called.
88  */
89 #ifdef _THREAD_SAFE
90 /*
91  * For the thread_safe versions, we prepend _thread_sys_ to the function
92  * name so that the 'C' wrapper can go around the real name.
93  */
94 #define PCALL(name)                                             \
95         CALL(___CONCAT(_thread_sys_,name))
96
97 #define PLEAF(name, args)                                       \
98 LEAF(___CONCAT(_thread_sys_,name),args)
99
100 #define PEND(name)                                              \
101 END(___CONCAT(_thread_sys_,name))
102
103 #define PSYSCALL(name)                                          \
104 PLEAF(name,0);                          /* XXX # of args? */    \
105         CALLSYS_ERROR(name)
106
107 #define PRSYSCALL(name)                                         \
108 PLEAF(name,0);                          /* XXX # of args? */    \
109         CALLSYS_ERROR(name)                                     \
110         RET;                                                    \
111 PEND(name)
112
113 #define PPSEUDO(label,name)                                     \
114 PLEAF(label,0);                         /* XXX # of args? */    \
115         CALLSYS_ERROR(name);                                    \
116         RET;                                                    \
117 PEND(label)
118
119 #else
120 /*
121  * The non-threaded library defaults to traditional syscalls where
122  * the function name matches the syscall name.
123  */
124 #define PSYSCALL(x)     SYSCALL(x)
125 #define PRSYSCALL(x)    RSYSCALL(x)
126 #define PPSEUDO(x,y)    PSEUDO(x,y)
127 #define PLEAF(x,y)      LEAF(x,y)
128 #define PEND(x)         END(x)
129 #define PCALL(x)        CALL(x)
130 #endif