]>
Commit | Line | Data |
---|---|---|
36960f0c | 1 | /* syscall error handlers |
04277e02 | 2 | Copyright (C) 2011-2019 Free Software Foundation, Inc. |
36960f0c PD |
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 | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
36960f0c PD |
18 | |
19 | #include <sysdep.h> | |
20 | ||
21 | #if IS_IN (libc) | |
22 | # define errno __libc_errno | |
23 | #endif | |
24 | ||
25 | ENTRY (__syscall_error) | |
26 | mv t0, ra | |
27 | /* Fall through to __syscall_set_errno. */ | |
28 | END (__syscall_error) | |
29 | ||
30 | /* Non-standard calling convention: argument in a0, return address in t0, | |
31 | and clobber only t1. */ | |
32 | ENTRY (__syscall_set_errno) | |
33 | /* We got here because a0 < 0, but only codes in the range [-4095, -1] | |
34 | represent errors. Otherwise, just return the result normally. */ | |
35 | li t1, -4096 | |
36 | bleu a0, t1, 1f | |
37 | neg a0, a0 | |
38 | #if RTLD_PRIVATE_ERRNO | |
39 | sw a0, rtld_errno, t1 | |
40 | #elif defined(__PIC__) | |
41 | la.tls.ie t1, errno | |
42 | add t1, t1, tp | |
43 | sw a0, 0(t1) | |
44 | #else | |
45 | lui t1, %tprel_hi(errno) | |
46 | add t1, t1, tp, %tprel_add(errno) | |
47 | sw a0, %tprel_lo(errno)(t1) | |
48 | #endif | |
49 | li a0, -1 | |
50 | 1: jr t0 | |
51 | END (__syscall_set_errno) |