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