d3b206df6e6995e6df6d05d416fa49bc273e35f0
[platform/upstream/glibc.git] / sysdeps / unix / sysv / linux / alpha / select.S
1 /* Copyright (C) 1998, 2002 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
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    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 #include <sysdep.h>
20 #define _ERRNO_H        1
21 #include <bits/errno.h>
22
23 /* The problem here is that initially we made struct timeval compatible with
24    OSF/1, using int32.  But we defined time_t with uint64, and later found
25    that POSIX requires tv_sec to be time_t.
26
27    So now we have to do compatibility stuff.  */
28
29 /* The variable is shared between all wrappers around signal handling
30    functions which have RT equivalents.  */
31 .comm __libc_missing_axp_tv64, 4
32
33 .text
34
35 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
36 #define SELECT  __select_tv64
37 #else
38 #define SELECT  __select
39 #endif
40
41 LEAF(SELECT, 64)
42         ldgp    gp, 0(pv)
43         subq    sp, 64, sp
44 #ifdef PROF
45         .set noat
46         lda     AT, _mcount
47         jsr     AT, (AT), _mcount
48         .set at
49 #endif
50         .prologue 1
51
52         ldl     t0, __libc_missing_axp_tv64
53
54         /* Save timeout early, since we'll need to recover this after 
55            the system call.  */
56         stq     a4, 48(sp)
57
58         bne     t0, $do32
59
60         /* Save arguments in case we do need to fall back.  */
61         stq     a0, 8(sp)
62         stq     a1, 16(sp)
63         stq     a2, 24(sp)
64         stq     a3, 32(sp)
65
66         ldi     v0, SYS_ify(select)
67         callsys
68         bne     a3, $err64
69
70         /* Everything ok.  */
71         addq    sp, 64, sp
72         ret
73
74         /* If we didn't get ENOSYS, it is a real error.  */
75         .align 3
76 $err64: cmpeq   v0, ENOSYS, t0
77         beq     t0, $error
78         stl     t0, __libc_missing_axp_tv64
79
80         /* Recover the saved arguments.  */
81         ldq     a4, 48(sp)
82         ldq     a3, 32(sp)
83         ldq     a2, 24(sp)
84         ldq     a1, 16(sp)
85         ldq     a0, 8(sp)
86
87         .align 3
88 $do32:
89         /* If the timeout argument is present bounce to the smaller fmt.  */
90         beq     a4, 1f
91         ldq     t0, 0(a4)
92         ldq     t1, 8(a4)
93         stl     t0, 0(sp)
94         stl     t1, 4(sp)
95         mov     sp, a4
96
97 1:      ldi     v0, SYS_ify(osf_select)
98         callsys
99         bne     a3, $error
100
101         /* ... and bounce the remaining timeout back.  */
102         ldq     a4, 48(sp)
103         beq     a4, 2f
104         ldl     t0, 0(sp)
105         ldl     t1, 4(sp)
106         stq     t0, 0(a4)
107         stq     t1, 8(a4)
108
109 2:      addq    sp, 64, sp
110         ret
111
112         .align 3
113 $error:
114         addq    sp, 64, sp
115         SYSCALL_ERROR_HANDLER
116
117 END(SELECT)
118
119 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
120 default_symbol_version (__select_tv64, __select, GLIBC_2.1)
121
122 /* It seems to me to be a misfeature of the assembler that we can only
123    have one version-alias per symbol.  So create an alias ourselves.
124    The 'p' is for 'public'.  *Shrug*  */
125 strong_alias (__select_tv64, __select_tv64p)
126 default_symbol_version (__select_tv64p, select, GLIBC_2.1)
127 libc_hidden_ver (__select_tv64, __select)
128 #else
129 weak_alias (__select, select)
130 libc_hidden_def (__select)
131 #endif