Update.
[platform/upstream/glibc.git] / sysdeps / unix / sysv / linux / ia64 / sysdep.h
1 /* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
4    Based on code originally written by David Mosberger-Tang
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Library General Public License as
8    published by the Free Software Foundation; either version 2 of the
9    License, or (at your option) any later version.
10
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Library General Public License for more details.
15
16    You should have received a copy of the GNU Library General Public
17    License along with the GNU C Library; see the file COPYING.LIB.  If not,
18    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20
21 #include <sysdeps/unix/sysdep.h>
22
23 /* For Linux we can use the system call table in the header file
24         /usr/include/asm/unistd.h
25    of the kernel.  But these symbols do not follow the SYS_* syntax
26    so we have to redefine the `SYS_ify' macro here.  */
27 #undef SYS_ify
28 #ifdef __STDC__
29 # define SYS_ify(syscall_name)  __NR_##syscall_name
30 #else
31 # define SYS_ify(syscall_name)  __NR_/**/syscall_name
32 #endif
33
34 #ifdef __ASSEMBLER__
35
36 /* Linux uses a negative return value to indicate syscall errors, unlike
37    most Unices, which use the condition codes' carry flag.
38
39    Since version 2.1 the return value of a system call might be negative
40    even if the call succeeded.  E.g., the `lseek' system call might return
41    a large offset.  Therefore we must not anymore test for < 0, but test
42    for a real error by making sure the value in %d0 is a real error
43    number.  Linus said he will make sure the no syscall returns a value
44    in -1 .. -4095 as a valid result so we can savely test with -4095.  */
45
46 /* We don't want the label for the error handler to be visible in the symbol
47    table when we define it here.  */
48 #define SYSCALL_ERROR_LABEL __syscall_error
49
50 #ifdef PROF
51 #error "define CALL_MCOUNT"
52 #else
53 #define CALL_MCOUNT
54 #endif
55
56
57 #undef PSEUDO
58 #define PSEUDO(name, syscall_name, args)        \
59   ENTRY(name)                                   \
60     DO_CALL (SYS_ify(syscall_name));            \
61         cmp.eq p6,p0=-1,r10;;                   \
62 (p6)    br.cond.spnt.few __syscall_error;
63
64 #define ENTRY(name)                             \
65         .psr abi64;                             \
66         .psr lsb;                               \
67         .lsb;                                   \
68         .text;                                  \
69         .align 32;                              \
70         .proc C_SYMBOL_NAME(name);              \
71         .global C_SYMBOL_NAME(name);            \
72         C_LABEL(name)                           \
73         CALL_MCOUNT
74
75 #define DO_CALL(num)                            \
76         mov r15=num;                            \
77         break __BREAK_SYSCALL;
78
79 #undef PSEUDO_END
80 #define PSEUDO_END(name)        .endp C_SYMBOL_NAME(name);
81
82 #undef END
83 #define END(name)                                               \
84         .size   C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ;  \
85         .endp   C_SYMBOL_NAME(name)
86
87 #define ret                     br.ret.sptk.few b0
88
89 #else /* not __ASSEMBLER__ */
90
91 /* Define a macro which expands into the inline wrapper code for a system
92    call.  */
93 #if 0
94 #undef INLINE_SYSCALL
95 #define INLINE_SYSCALL(name, nr, args...)       __##name (args)
96 #endif
97
98 #endif /* not __ASSEMBLER__ */