2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / s390 / s390-64 / sysdep.S
blobbb61e894f1f88aa98573d15a7f4efeadef9e6461
1 /* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
3    This file is part of the GNU C Library.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
20 #include <sysdep.h>
21 #include <tls.h>
24 /* The following code is only used in the shared library when we
25    compile the reentrant version.  Otherwise each system call defines
26    each own version.  */
28 /* The syscall stubs jump here when they detect an error.  */
30 #undef CALL_MCOUNT
31 #define CALL_MCOUNT
33 .text
34 ENTRY(__syscall_error)
35 #ifndef PIC
36 # if USE___THREAD
37 #  ifndef NOT_IN_libc
38 #   define SYSCALL_ERROR_ERRNO __libc_errno
39 #  else
40 #   define SYSCALL_ERROR_ERRNO errno
41 #  endif
42         basr    %r1,0
43 0:      lg      %r1,1f-0b(%r1)
44         ear     %r3,%a0
45         sllg    %r3,%r3,32
46         ear     %r3,%a1
47         lcr     %r2,%r2
48         st      %r2,0(%r1,%r3)
49         lghi    %r2,-1
50         br      %r14
51 1:      .quad   SYSCALL_ERROR_ERRNO@ntpoff
52 # elif !defined _LIBC_REENTRANT
53         larl    %r1,errno
54         lcr     %r2,%r2
55         st      %r2,0(%r1)
56         lghi    %r2,-1
57         br      %r14
58 # else
59         stmg    %r13,%r15,104(%r15)
60         cfi_offset (%r15,-40)
61         cfi_offset (%r14,-48)
62         cfi_offset (%r13,-56)
63         lgr     %r0,%r15
64         aghi    %r15,-160
65         cfi_adjust_cfa_offset (160)
66         lcr     %r13,%r2
67         stg     %r0,0(%r15)
68         brasl   %r14,__errno_location
69         st      %r13,0(%r2)
70         lmg     %r13,%r15,264(%r15)
71         cfi_adjust_cfa_offset (-160)
72         lghi    %r2,-1
73         br      %r14
74 #endif
75 #else
76 # if RTLD_PRIVATE_ERRNO
77         larl    %r1,rtld_errno
78         lcr     %r2,%r2
79         st      %r2,0(%r1)
80         lghi    %r2,-1
81         br      %r14
82 # elif USE___THREAD
83 #  ifndef NOT_IN_libc
84 #   define SYSCALL_ERROR_ERRNO __libc_errno
85 #  else
86 #   define SYSCALL_ERROR_ERRNO errno
87 #  endif
88         larl    %r1,_GLOBAL_OFFSET_TABLE_
89         lg      %r1,SYSCALL_ERROR_ERRNO@gotntpoff(%r1)
90         ear     %r3,%a0
91         sllg    %r3,%r3,32
92         ear     %r3,%a1
93         lcr     %r2,%r2
94         st      %r2,0(%r1,%r3)
95         lghi    %r2,-1
96         br      %r14
97 # elif !defined _LIBC_REENTRANT
98         larl    %r1,_GLOBAL_OFFSET_TABLE_
99         lg      %r1,errno@GOT(%r1)
100         lcr     %r2,%r2
101         st      %r2,0(%r1)
102         lghi    %r2,-1
103         br      %r14
104 # else
105         stmg    %r13,%r15,104(%r15)
106         cfi_offset (%r15,-40)
107         cfi_offset (%r14,-48)
108         cfi_offset (%r13,-56)
109         lgr     %r0,%r15
110         aghi    %r15,-160
111         cfi_adjust_cfa_offset (160)
112         lcr     %r13,%r2
113         stg     %r0,0(%r15)
114         brasl   %r14,__errno_location@PLT
115         st      %r13,0(%r2)
116         lmg     %r13,%r15,264(%r15)
117         cfi_adjust_cfa_offset (-160)
118         lghi    %r2,-1
119         br      %r14
120 # endif
121 #endif
123 END (__syscall_error)