Add Changelog ...
[glibc.git] / sysdeps / unix / mips / sysdep.S
blobf42d0f94f9570e5a859a8cc1eeb77ce35d85f16d
1 /* Copyright (C) 1992, 1993, 1994, 1997, 1998, 1999, 2000, 2002, 2003 
2    Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Brendan Kehoe (brendan@zen.org).
6    The GNU C Library is free software; you can redistribute it and/or
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.
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
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library.  If not, see
18    <http://www.gnu.org/licenses/>.  */
20 #include <sysdep.h>
21 #define _ERRNO_H
22 #include <bits/errno.h>
23 #include <sys/asm.h>
25 #ifdef _LIBC_REENTRANT
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         
33 ENTRY(__syscall_error)
34 #ifdef __PIC__
35         .set noat
36         SETUP_GPX (AT)
37         .set at
38 #endif
39         PTR_SUBU sp, FRAMESZ
40         .set noat
41         SETUP_GPX64(GPOFF,AT)
42         .set at
43 #ifdef __PIC__
44         SAVE_GP(GPOFF)
45 #endif
46         REG_S   v0, V0OFF(sp)
47         REG_S   ra, RAOFF(sp)
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.  */
53         bne     v0, EWOULDBLOCK_sys, L(skip)
54         nop
55         li      v0, EAGAIN
56 L(skip):
57 #endif
58         /* Find our per-thread errno address  */
59         jal     __errno_location
61         /* Store the error value.  */
62         REG_L   t0, V0OFF(sp)
63         sw      t0, 0(v0)
65         /* And just kick back a -1.  */
66         REG_L   ra, RAOFF(sp)
67         RESTORE_GP64
68         PTR_ADDU sp, FRAMESZ
69         li      v0, -1
70         j       ra
71         END(__syscall_error)
73 #else /* _LIBC_REENTRANT */
76 ENTRY(__syscall_error)
77 #ifdef __PIC__
78         SETUP_GPX (AT)
79 #endif
80         SETUP_GPX64 (t9, AT)
81         
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.  */
86         bne v0, EWOULDBLOCK_sys, L(skip)
87         li v0, EAGAIN
88 L(skip):
89 #endif
90         /* Store it in errno... */
91         sw v0, errno
93         /* And just kick back a -1.  */
94         li v0, -1
96         RESTORE_GP64
97         j ra
98         END(__syscall_error)
99 #endif  /* _LIBC_REENTRANT  */