2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / alpha / setitimer.S
blob59caeac680d76a7229eab651671fbe2bd7a85b66
1 /* Copyright (C) 1998, 2003, 2006 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
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.
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.
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.  */
19 #include <sysdep.h>
20 #define _ERRNO_H        1
21 #include <bits/errno.h>
22 #include <kernel-features.h>
24 .text
26 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
27 #define SETITIMER       __setitimer_tv64
28 #else
29 #define SETITIMER       __setitimer
30 #endif
32 #if defined __ASSUME_TIMEVAL64
33 PSEUDO(SETITIMER, setitimer, 3)
34         ret
35 PSEUDO_END(SETITIMER)
36 #else
37 /* The problem here is that initially we made struct timeval compatible with
38    OSF/1, using int32.  But we defined time_t with uint64, and later found
39    that POSIX requires tv_sec to be time_t.
41    So now we have to do compatibility stuff.  */
43 /* The variable is shared between all wrappers around signal handling
44    functions which have RT equivalents.  */
45 .comm __libc_missing_axp_tv64, 4
47 LEAF(SETITIMER, 48)
48         ldgp    gp, 0(pv)
49         subq    sp, 48, sp
50 #ifdef PROF
51         .set noat
52         lda     AT, _mcount
53         jsr     AT, (AT), _mcount
54         .set at
55 #endif
56         .prologue 1
58         ldl     t0, __libc_missing_axp_tv64
60         /* Save arguments in case we do need to fall back.  */
61         stq     a0, 0(sp)
62         stq     a1, 8(sp)
63         stq     a2, 16(sp)
65         bne     t0, $do32
67         ldi     v0, SYS_ify(setitimer)
68         callsys
69         bne     a3, $err64
71         /* Everything ok.  */
72         addq    sp, 48, sp
73         ret
75         /* If we didn't get ENOSYS, it is a real error.  */
76         .align 3
77 $err64: cmpeq   v0, ENOSYS, t0
78         beq     t0, $error
79         stl     t0, __libc_missing_axp_tv64
81         /* Recover the saved arguments.  */
82         ldq     a2, 16(sp)
83         ldq     a1, 8(sp)
84         ldq     a0, 0(sp)
86         .align 3
87 $do32:
88         /* Conditionally bounce new value down.  */
89         beq     a1, 1f
90         ldq     t0, 0(a1)
91         ldq     t1, 8(a1)
92         ldq     t2, 16(a1)
93         ldq     t3, 24(a1)
94         stl     t0, 32(sp)
95         stl     t1, 36(sp)
96         stl     t2, 40(sp)
97         stl     t3, 44(sp)
98         addq    sp, 32, a1
100 1:      ldi     v0, SYS_ify(osf_setitimer)
101         callsys
102         bne     a3, $error
104         /* Conditionaly bounce old value up.  */
105         ldq     a2, 16(sp)
106         bne     a2, 2f
107         ldl     t0, 0(a2)
108         ldl     t1, 4(a2)
109         ldl     t2, 8(a2)
110         ldl     t3, 12(a2)
111         stq     t0, 0(a2)
112         stq     t1, 8(a2)
113         stq     t2, 48(a2)
114         stq     t3, 24(a2)
116 2:      addq    sp, 48, sp
117         ret
119         .align 3
120 $error:
121         addq    sp, 48, sp
122         SYSCALL_ERROR_HANDLER
124 END(SETITIMER)
125 #endif /* __ASSUME_TIMEVAL64 */
127 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
128 default_symbol_version (__setitimer_tv64, __setitimer, GLIBC_2.1)
130 /* It seems to me to be a misfeature of the assembler that we can only
131    have one version-alias per symbol.  So create an alias ourselves.
132    The 'p' is for 'public'.  *Shrug*  */
133 strong_alias (__setitimer_tv64, __setitimer_tv64p)
134 default_symbol_version (__setitimer_tv64p, setitimer, GLIBC_2.1)
135 #else
136 weak_alias (__setitimer, setitimer)
137 #endif