]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/arm/sysdep.h
(PSEUDO): Add missing semicolon so that profiling works.
[thirdparty/glibc.git] / 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.
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 #ifndef _LINUX_ARM_SYSDEP_H
22 #define _LINUX_ARM_SYSDEP_H 1
23
24 /* There is some commonality. */
25 #include <sysdeps/unix/arm/sysdep.h>
26
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. */
31 #undef SYS_ify
32 #define SWI_BASE (0x900000)
33 #define SYS_ify(syscall_name) (__NR_##syscall_name)
34
35
36 #ifdef __ASSEMBLER__
37
38 /* Linux uses a negative return value to indicate syscall errors,
39 unlike most Unices, which use the condition codes' carry flag.
40
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
47 test with -4095. */
48
49 #undef PSEUDO
50 #define PSEUDO(name, syscall_name, args) \
51 .text; \
52 .type syscall_error,%function; \
53 ENTRY (name); \
54 DO_CALL (args, syscall_name); \
55 cmn r0, $4096; \
56 bhs PLTJMP(C_SYMBOL_NAME(__syscall_error));
57
58 #undef PSEUDO_END
59 #define PSEUDO_END(name) \
60 SYSCALL_ERROR_HANDLER \
61 END (name)
62
63 #define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
64
65 /* Linux takes system call args in registers:
66 syscall number in the SWI instruction
67 arg 1 r0
68 arg 2 r1
69 arg 3 r2
70 arg 4 r3
71 arg 5 r4 (this is different from the APCS convention)
72
73 The compiler is going to form a call by coming here, through PSEUDO, with
74 arguments
75 syscall number in the DO_CALL macro
76 arg 1 r0
77 arg 2 r1
78 arg 3 r2
79 arg 4 r3
80 arg 5 [sp]
81
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.
84
85 */
86
87 #undef DO_CALL
88 #define DO_CALL(args, syscall_name) \
89 DOARGS_##args \
90 swi SYS_ify (syscall_name); \
91 UNDOARGS_##args
92
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;
99
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];
106
107 #endif /* __ASSEMBLER__ */
108
109 #endif /* linux/arm/sysdep.h */