]>
Commit | Line | Data |
---|---|---|
3e9a9758 RM |
1 | /* Copyright (C) 1992, 1993, 1994, 1997, 1998, 1999, 2000, 2002, 2003 |
2 | Free Software Foundation, Inc. | |
db31c863 | 3 | This file is part of the GNU C Library. |
6ad344f0 RM |
4 | Contributed by Brendan Kehoe (brendan@zen.org). |
5 | ||
db31c863 | 6 | The GNU C Library is free software; you can redistribute it and/or |
3214b89b AJ |
7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
6ad344f0 | 10 | |
db31c863 UD |
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 | |
3214b89b | 14 | Lesser General Public License for more details. |
6ad344f0 | 15 | |
3214b89b | 16 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff PE |
17 | License along with the GNU C Library. If not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
6ad344f0 RM |
19 | |
20 | #include <sysdep.h> | |
21 | #define _ERRNO_H | |
405916ef | 22 | #include <bits/errno.h> |
a9b0e919 | 23 | #include <sys/asm.h> |
6ad344f0 | 24 | |
c79dd0e8 UD |
25 | #ifdef _LIBC_REENTRANT |
26 | ||
ca2b264c AO |
27 | LOCALSZ= 3 |
28 | FRAMESZ= (((NARGSAVE+LOCALSZ)*SZREG)+ALSZ)&ALMASK | |
29 | RAOFF= FRAMESZ-(1*SZREG) | |
30 | GPOFF= FRAMESZ-(2*SZREG) | |
31 | V0OFF= FRAMESZ-(3*SZREG) | |
32 | ||
c79dd0e8 | 33 | ENTRY(__syscall_error) |
8ef0fc04 | 34 | #ifdef __PIC__ |
ca2b264c AO |
35 | .set noat |
36 | SETUP_GPX (AT) | |
37 | .set at | |
c79dd0e8 | 38 | #endif |
ca2b264c AO |
39 | PTR_SUBU sp, FRAMESZ |
40 | .set noat | |
41 | SETUP_GPX64(GPOFF,AT) | |
42 | .set at | |
c79dd0e8 | 43 | #ifdef __PIC__ |
ca2b264c | 44 | SAVE_GP(GPOFF) |
c79dd0e8 | 45 | #endif |
ca2b264c AO |
46 | REG_S v0, V0OFF(sp) |
47 | REG_S ra, RAOFF(sp) | |
c79dd0e8 UD |
48 | |
49 | #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN | |
50 | /* We translate the system's EWOULDBLOCK error into EAGAIN. | |
51 | The GNU C library always defines EWOULDBLOCK==EAGAIN. | |
52 | EWOULDBLOCK_sys is the original number. */ | |
3e9a9758 | 53 | bne v0, EWOULDBLOCK_sys, L(skip) |
c79dd0e8 UD |
54 | nop |
55 | li v0, EAGAIN | |
3e9a9758 | 56 | L(skip): |
5a50d6f5 | 57 | #endif |
c79dd0e8 UD |
58 | /* Find our per-thread errno address */ |
59 | jal __errno_location | |
60 | ||
61 | /* Store the error value. */ | |
96c095cf AO |
62 | REG_L t0, V0OFF(sp) |
63 | sw t0, 0(v0) | |
c79dd0e8 UD |
64 | |
65 | /* And just kick back a -1. */ | |
ca2b264c AO |
66 | REG_L ra, RAOFF(sp) |
67 | RESTORE_GP64 | |
68 | PTR_ADDU sp, FRAMESZ | |
c79dd0e8 UD |
69 | li v0, -1 |
70 | j ra | |
71 | END(__syscall_error) | |
72 | ||
73 | #else /* _LIBC_REENTRANT */ | |
5a50d6f5 | 74 | |
6ad344f0 | 75 | |
5a50d6f5 | 76 | ENTRY(__syscall_error) |
c79dd0e8 | 77 | #ifdef __PIC__ |
ca2b264c | 78 | SETUP_GPX (AT) |
5a50d6f5 | 79 | #endif |
ca2b264c AO |
80 | SETUP_GPX64 (t9, AT) |
81 | ||
6ad344f0 RM |
82 | #if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN |
83 | /* We translate the system's EWOULDBLOCK error into EAGAIN. | |
84 | The GNU C library always defines EWOULDBLOCK==EAGAIN. | |
85 | EWOULDBLOCK_sys is the original number. */ | |
3e9a9758 | 86 | bne v0, EWOULDBLOCK_sys, L(skip) |
6ad344f0 | 87 | li v0, EAGAIN |
3e9a9758 | 88 | L(skip): |
6ad344f0 RM |
89 | #endif |
90 | /* Store it in errno... */ | |
91 | sw v0, errno | |
92 | ||
93 | /* And just kick back a -1. */ | |
b2ff3460 | 94 | li v0, -1 |
ca2b264c AO |
95 | |
96 | RESTORE_GP64 | |
c79dd0e8 | 97 | j ra |
5a50d6f5 | 98 | END(__syscall_error) |
c79dd0e8 | 99 | #endif /* _LIBC_REENTRANT */ |