update from main archive 961001
[glibc.git] / sysdeps / unix / alpha / sysdep.S
blob08dc3b4851288869d50a0c7e3c244c0cdca2522d
1 /* Copyright (C) 1993, 1996 Free Software Foundation, Inc.
2    Contributed by Brendan Kehoe (brendan@zen.org).
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB.  If
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA.  */
19 #include <sysdep.h>
20 #include <features.h>
22         .section .bss
23         .globl errno
24         .align 2
25 errno:  .space 4
26 #ifdef __ELF__
27         .type errno, @object
28         .size errno, 4
29 #endif
30         .globl __errno
31 __errno = errno
33         .text
34         .align 2
36 #ifdef  _LIBC_REENTRANT
38         .globl __syscall_error
39         .ent __syscall_error
40 __syscall_error:
41         ldgp    gp, 0(t12)
42         lda     sp, -16(sp)
43         .frame  sp, 16, ra, 0
44         stq     ra, 0(sp)
45         stq     v0, 8(sp)
46         .mask   0x4000001, -16
47         .prologue 1
49         /* Store into the "real" variable.  */
50         stl     v0, errno
52         /* Find our per-thread errno address  */
53         jsr     ra, __errno_location
55         /* Store the error value.  */
56         ldl     t0, 8(sp)
57         stl     t0, 0(v0)
59         /* And kick back a -1.  */
60         ldi     v0, -1
62         ldq     ra, 0(sp)
63         lda     sp, 16(sp)
64         ret
65         .end __syscall_error
67 /* A default non-threaded version of __errno_location that just returns
68    the address of errno.  */
70         .weak   __errno_location
71         .ent    __errno_location
72 __errno_location:
73         .frame  sp, 0, ra
74         ldgp    gp, 0(t12)
75         .mask   0, 0
76         .prologue 1
78         lda     v0, errno
79         ret
80         .end __errno_location
82 #else
84 ENTRY(__syscall_error)
85         ldgp    gp, 0(t12)
86         .prologue 1
88         stl     v0, errno
89         lda     v0, -1
90         ret
91         END(__syscall_error)
93 #endif /* _LIBC_REENTRANT */