]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/arm/sysdep.h
1 /* Copyright (C) 1992, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
4 ARM changes by Philip Blundell, <pjb27@cam.ac.uk>, May 1997.
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 #ifndef _LINUX_ARM_SYSDEP_H
22 #define _LINUX_ARM_SYSDEP_H 1
24 /* There is some commonality. */
25 #include <sysdeps/unix/arm/sysdep.h>
27 /* For Linux we can use the system call table in the header file
28 /usr/include/asm/unistd.h
29 of the kernel. But these symbols do not follow the SYS_* syntax
30 so we have to redefine the `SYS_ify' macro here. */
32 #define SWI_BASE (0x900000)
33 #define SYS_ify(syscall_name) (__NR_##syscall_name)
38 /* Linux uses a negative return value to indicate syscall errors,
39 unlike most Unices, which use the condition codes' carry flag.
41 Since version 2.1 the return value of a system call might be
42 negative even if the call succeeded. E.g., the `lseek' system call
43 might return a large offset. Therefore we must not anymore test
44 for < 0, but test for a real error by making sure the value in R0
45 is a real error number. Linus said he will make sure the no syscall
46 returns a value in -1 .. -4095 as a valid result so we can savely
50 #define PSEUDO(name, syscall_name, args) \
52 .type syscall_error,%function; \
54 DO_CALL (args, syscall_name); \
56 bhs PLTJMP(C_SYMBOL_NAME(__syscall_error));
59 #define PSEUDO_END(name) \
60 SYSCALL_ERROR_HANDLER \
63 #define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
65 /* Linux takes system call args in registers:
66 syscall number in the SWI instruction
71 arg 5 r4 (this is different from the APCS convention)
73 The compiler is going to form a call by coming here, through PSEUDO, with
75 syscall number in the DO_CALL macro
82 We need to shuffle values between R4 and the stack so that the caller's
83 R4 is not corrupted, and the kernel sees the right argument there.
88 #define DO_CALL(args, syscall_name) \
90 swi SYS_ify (syscall_name); \
93 #define DOARGS_0 /* nothing */
94 #define DOARGS_1 /* nothing */
95 #define DOARGS_2 /* nothing */
96 #define DOARGS_3 /* nothing */
97 #define DOARGS_4 /* nothing */
98 #define DOARGS_5 ldr ip, [sp]; str r4, [sp]; mov r4, ip;
100 #define UNDOARGS_0 /* nothing */
101 #define UNDOARGS_1 /* nothing */
102 #define UNDOARGS_2 /* nothing */
103 #define UNDOARGS_3 /* nothing */
104 #define UNDOARGS_4 /* nothing */
105 #define UNDOARGS_5 ldr r4, [sp];
107 #endif /* __ASSEMBLER__ */
109 #endif /* linux/arm/sysdep.h */