]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/ia64/bits/syscalls.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / ia64 / bits / syscalls.h
1 /* Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2006
2    Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
5    Based on code originally written by David Mosberger-Tang
6
7    The GNU C Library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    The GNU C Library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with the GNU C Library; if not, write to the Free
19    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20    02111-1307 USA.  */
21
22 #ifndef _BITS_SYSCALLS_H
23 #define _BITS_SYSCALLS_H
24
25 #ifndef _SYSCALL_H
26 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
27 #endif
28
29 #ifndef __ASSEMBLER__
30
31 #include <errno.h>
32
33 #undef IA64_USE_NEW_STUB
34
35 #define __IA64_BREAK_SYSCALL    0x100000
36
37 /* mostly taken from glibc sysdeps/unix/sysv/linux/ia64/sysdep.h */
38 #define BREAK_INSN_1(num) "break " #num ";;\n\t"
39 #define BREAK_INSN(num) BREAK_INSN_1(num)
40
41 /* On IA-64 we have stacked registers for passing arguments.  The
42    "out" registers end up being the called function's "in"
43    registers.
44
45    Also, since we have plenty of registers we have two return values
46    from a syscall.  r10 is set to -1 on error, whilst r8 contains the
47    (non-negative) errno on error or the return value on success.
48  */
49
50 # define DO_INLINE_SYSCALL_NCS(name, nr, args...)               \
51     LOAD_ARGS_##nr (args)                                       \
52     register long _r8 __asm__ ("r8");                           \
53     register long _r10 __asm__ ("r10");                         \
54     register long _r15 __asm__ ("r15") = name;                  \
55     long _retval;                                               \
56     LOAD_REGS_##nr                                              \
57     __asm__ __volatile__ (BREAK_INSN (__IA64_BREAK_SYSCALL)     \
58                       : "=r" (_r8), "=r" (_r10), "=r" (_r15)    \
59                         ASM_OUTARGS_##nr                        \
60                       : "2" (_r15) ASM_ARGS_##nr                \
61                       : "memory" ASM_CLOBBERS_##nr);            \
62     _retval = _r8;
63
64 #define INLINE_SYSCALL_NCS(name, nr, args...)           \
65   ({                                                    \
66     DO_INLINE_SYSCALL_NCS (name, nr, args)      \
67     if (_r10 == -1)                                     \
68       {                                                 \
69         __set_errno (_retval);                          \
70         _retval = -1;                                   \
71       }                                                 \
72     _retval; })
73
74 #define INTERNAL_SYSCALL_DECL(err) long int err
75
76 #define INTERNAL_SYSCALL_NCS(name, err, nr, args...)    \
77   ({                                                    \
78     DO_INLINE_SYSCALL_NCS (name, nr, args)              \
79     err = _r10;                                         \
80     _retval; })
81
82 #define INTERNAL_SYSCALL_ERROR_P(val, err)      (err == -1)
83
84 #define INTERNAL_SYSCALL_ERRNO(val, err)        (val)
85
86 #define LOAD_ARGS_0()
87 #define LOAD_REGS_0
88 #define LOAD_ARGS_1(a1)                                 \
89   long _arg1 = (long) (a1);                             \
90   LOAD_ARGS_0 ()
91 #define LOAD_REGS_1                                     \
92   register long _out0 __asm__ ("out0") = _arg1;         \
93   LOAD_REGS_0
94 #define LOAD_ARGS_2(a1, a2)                             \
95   long _arg2 = (long) (a2);                             \
96   LOAD_ARGS_1 (a1)
97 #define LOAD_REGS_2                                     \
98   register long _out1 __asm__ ("out1") = _arg2;         \
99   LOAD_REGS_1
100 #define LOAD_ARGS_3(a1, a2, a3)                         \
101   long _arg3 = (long) (a3);                             \
102   LOAD_ARGS_2 (a1, a2)
103 #define LOAD_REGS_3                                     \
104   register long _out2 __asm__ ("out2") = _arg3;         \
105   LOAD_REGS_2
106 #define LOAD_ARGS_4(a1, a2, a3, a4)                     \
107   long _arg4 = (long) (a4);                             \
108   LOAD_ARGS_3 (a1, a2, a3)
109 #define LOAD_REGS_4                                     \
110   register long _out3 __asm__ ("out3") = _arg4;         \
111   LOAD_REGS_3
112 #define LOAD_ARGS_5(a1, a2, a3, a4, a5)                 \
113   long _arg5 = (long) (a5);                             \
114   LOAD_ARGS_4 (a1, a2, a3, a4)
115 #define LOAD_REGS_5                                     \
116   register long _out4 __asm__ ("out4") = _arg5;         \
117   LOAD_REGS_4
118 #define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6)             \
119   long _arg6 = (long) (a6);                             \
120   LOAD_ARGS_5 (a1, a2, a3, a4, a5)
121 #define LOAD_REGS_6                                     \
122   register long _out5 __asm__ ("out5") = _arg6;         \
123   LOAD_REGS_5
124
125 #define ASM_OUTARGS_0
126 #define ASM_OUTARGS_1   ASM_OUTARGS_0, "=r" (_out0)
127 #define ASM_OUTARGS_2   ASM_OUTARGS_1, "=r" (_out1)
128 #define ASM_OUTARGS_3   ASM_OUTARGS_2, "=r" (_out2)
129 #define ASM_OUTARGS_4   ASM_OUTARGS_3, "=r" (_out3)
130 #define ASM_OUTARGS_5   ASM_OUTARGS_4, "=r" (_out4)
131 #define ASM_OUTARGS_6   ASM_OUTARGS_5, "=r" (_out5)
132
133 #define ASM_ARGS_0
134 #define ASM_ARGS_1      ASM_ARGS_0, "3" (_out0)
135 #define ASM_ARGS_2      ASM_ARGS_1, "4" (_out1)
136 #define ASM_ARGS_3      ASM_ARGS_2, "5" (_out2)
137 #define ASM_ARGS_4      ASM_ARGS_3, "6" (_out3)
138 #define ASM_ARGS_5      ASM_ARGS_4, "7" (_out4)
139 #define ASM_ARGS_6      ASM_ARGS_5, "8" (_out5)
140
141 #define ASM_CLOBBERS_0  ASM_CLOBBERS_1, "out0"
142 #define ASM_CLOBBERS_1  ASM_CLOBBERS_2, "out1"
143 #define ASM_CLOBBERS_2  ASM_CLOBBERS_3, "out2"
144 #define ASM_CLOBBERS_3  ASM_CLOBBERS_4, "out3"
145 #define ASM_CLOBBERS_4  ASM_CLOBBERS_5, "out4"
146 #define ASM_CLOBBERS_5  ASM_CLOBBERS_6, "out5"
147 #define ASM_CLOBBERS_6  ASM_CLOBBERS_6_COMMON , "b7"
148 #define ASM_CLOBBERS_6_COMMON   , "out6", "out7",                       \
149   /* Non-stacked integer registers, minus r8, r10, r15.  */             \
150   "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18",    \
151   "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",        \
152   "r28", "r29", "r30", "r31",                                           \
153   /* Predicate registers.  */                                           \
154   "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15",     \
155   /* Non-rotating fp registers.  */                                     \
156   "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",     \
157   /* Branch registers.  */                                              \
158   "b6"
159
160 #endif /* __ASSEMBLER__ */
161 #endif /* _BITS_SYSCALLS_H */