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
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.
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.
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. */
21 #include <sysdeps/unix/sysdep.h>
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. */
29 # define SYS_ify(syscall_name) __NR_##syscall_name
31 # define SYS_ify(syscall_name) __NR_/**/syscall_name
36 /* Linux uses a negative return value to indicate syscall errors, unlike
37 most Unices, which use the condition codes' carry flag.
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. */
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
51 #error "define CALL_MCOUNT"
58 #define PSEUDO(name, syscall_name, args) \
60 DO_CALL (SYS_ify(syscall_name)); \
61 cmp.eq p6,p0=-1,r10;; \
62 (p6) br.cond.spnt.few __syscall_error;
70 .proc C_SYMBOL_NAME(name); \
71 .global C_SYMBOL_NAME(name); \
75 #define DO_CALL(num) \
77 break __BREAK_SYSCALL;
80 #define PSEUDO_END(name) .endp C_SYMBOL_NAME(name);
84 .size C_SYMBOL_NAME(name), . - C_SYMBOL_NAME(name) ; \
85 .endp C_SYMBOL_NAME(name)
87 #define ret br.ret.sptk.few b0
89 #else /* not __ASSEMBLER__ */
91 /* Define a macro which expands into the inline wrapper code for a system
95 #define INLINE_SYSCALL(name, nr, args...) __##name (args)
98 #endif /* not __ASSEMBLER__ */