/* [<][>][^][v][top][bottom][index][help] */
1 /* Copyright (C) 2005, 2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18 /* This file was modified from the original below.
19 * ../eglibc-2.17/ports/sysdeps/unix/sysv/linux/arm/syscall.S
20 */
21
22 // #include <sysdep.h>
23 // Macros copied or modifid from:
24 // ../eglibc-2.17/ports/sysdeps/arm/sysdep.h
25 // ../eglibc-2.17/sysdeps/generic/sysdep.h
26
27 /* In the EABI syscall interface, we don't need a special syscall to
28 implement syscall(). It won't work reliably with 64-bit arguments
29 (but that is true on many modern platforms). */
30
31 // Added for DMTCP
32 #define cfi_adjust_cfa_offset(x)
33 #define cfi_rel_offset(x,y)
34 #define cfi_adjust_cfa_offset(x)
35 #define cfi_restore(x)
36 #define RETINSTR(cc,lr) bx##cc lr
37 #define PSEUDO_END(fnc)
38 #define ENTRY(fnc) \
39 .globl fnc ;\
40 .type fnc,%function ;\
41 .align 4 ;\
42 fnc:
43
44 /* This define is needed on command line for the DMTCP-2.2 release. After
45 * that, this code will move from the mtcp_restart executable to a library,
46 * libmtcp.so. The current mtcp_restart cannot use global variables.
47 * But libmtcp.so will again employ global variables, and so the main branch
48 * here will again align well with glibc.
49 */
50 // #define MTCP_SYS_ERRNO_ON_STACK
51
52 // Call it mtcp_syscall instead of syscall to avoid any DMTCP wrappers.
53 ENTRY (mtcp_syscall)
54 mov ip, sp
55 stmfd sp!, {r4, r5, r6, r7, r8}
56 #ifdef MTCP_SYS_ERRNO_ON_STACK
57 mov r8, r1 /* Save address of mtcp_sys_errno here */
58 #endif
59 cfi_adjust_cfa_offset (16)
60 cfi_rel_offset (r4, 0)
61 cfi_rel_offset (r5, 4)
62 cfi_rel_offset (r6, 8)
63 cfi_rel_offset (r7, 12)
64 mov r7, r0
65 #ifdef MTCP_SYS_ERRNO_ON_STACK
66 mov r0, r2
67 mov r1, r3
68 ldmfd ip, {r2, r3, r4, r5, r6}
69 #else
70 mov r0, r1
71 mov r1, r2
72 mov r2, r3
73 ldmfd ip, {r3, r4, r5, r6}
74 #endif
75 swi 0x0
76 #ifdef MTCP_SYS_ERRNO_ON_STACK
77 mov r1, r8 /* Restore address of mtcp_sys_errno to r1 here */
78 #endif
79 ldmfd sp!, {r4, r5, r6, r7, r8}
80 cfi_adjust_cfa_offset (-16)
81 cfi_restore (r4)
82 cfi_restore (r5)
83 cfi_restore (r6)
84 cfi_restore (r7)
85 cmn r0, #4096
86 RETINSTR(cc, lr)
87 #ifdef MTCP_SYS_ERRNO_ON_STACK
88 // r1 has &mtcp_sys_errno and r0 has encoded errno
89 neg r0, r0 /* If r0-4096 was negative, 4096-r0 is the errno. */
90 str r0, [r1, #0]
91 mvn r0, #0 /* return -1 */
92 mov pc, lr
93 #else
94 // This will call a DMTCP function in C that sets mtcp_sys_errno :
95 // b PLTJMP(syscall_error)
96 #endif
97 PSEUDO_END (mtcp_syscall)