1 | /* syscall error handlers. C-SKY ABIV2 version. |
2 | Copyright (C) 2018-2024 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
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. |
9 | |
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. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library. If not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <sysdep.h> |
20 | |
21 | /* The syscall stubs jump here when they detect an error. |
22 | The code for Linux is almost identical to the canonical Unix |
23 | code, except that the error number in R0 is negated. */ |
24 | |
25 | #undef CALL_MCOUNT |
26 | #define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */ |
27 | |
28 | .text |
29 | ENTRY (__syscall_error) |
30 | movi a1, 0 |
31 | rsub a0, a0, a1 |
32 | |
33 | #if !IS_IN (rtld) |
34 | mov a1, a0 |
35 | mov a0, tls |
36 | |
37 | grs t1, .Lgetpc1 |
38 | .Lgetpc1: |
39 | lrw t0, errno@gottpoff |
40 | add t1, t1, t0 |
41 | ldw t1, (t1) |
42 | add t1, a0 |
43 | stw a1, (t1) |
44 | bmaski a0, 0 |
45 | rts |
46 | #elif RTLD_PRIVATE_ERRNO /* !IS_IN (rtld) */ |
47 | # ifdef __PIC__ |
48 | grs t1, .Lgetpc2 |
49 | .Lgetpc2: |
50 | lrw t0, .Lgetpc2@GOTPC |
51 | addu t1, t1, t0 |
52 | lrw t0, rtld_errno@PLT |
53 | ldr.w t0, (t1, t0 << 0) |
54 | # else |
55 | lrw t0, rtld_errno |
56 | # endif /* __PIC__ */ |
57 | stw a0, (t0) |
58 | bmaski a0, 0 |
59 | rts |
60 | #else |
61 | # error "Unsupported non-TLS case" |
62 | #endif /* RTLD_PRIVATE_ERRNO */ |
63 | |
64 | #undef __syscall_error |
65 | END (__syscall_error) |
66 | |