2.9
[glibc/nacl-glibc.git] / sysdeps / unix / sysv / linux / alpha / getrusage.S
blob0bca4b5f23b3c0b97e507243d2eb068d4a637616
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 GETRUSAGE       __getrusage_tv64
28 #else
29 #define GETRUSAGE       __getrusage
30 #endif
32 #if defined __ASSUME_TIMEVAL64
33 PSEUDO(GETRUSAGE, getrusage, 2)
34         ret
35 PSEUDO_END(GETRUSAGE)
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(GETRUSAGE, 16)
48         ldgp    gp, 0(pv)
49         subq    sp, 16, 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)
64         bne     t0, $do32
66         ldi     v0, SYS_ify(getrusage)
67         callsys
68         bne     a3, $err64
70         /* Everything ok.  */
71         addq    sp, 16, sp
72         ret
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
80         /* Recover the saved arguments.  */
81         ldq     a1, 8(sp)
82         ldq     a0, 0(sp)
84         .align 3
85 $do32:  ldi     v0, SYS_ify(osf_getrusage)
86         callsys
87         bne     a3, $error
89         /* Copy back to proper format.  */
90         ldq     a1, 8(sp)
91         ldl     t0, 0(a1)               # ru_utime.tv_sec
92         ldl     t1, 4(a1)               # ru_utime.tv_usec
93         ldl     t2, 8(a1)               # ru_stime.tv_sec
94         ldl     t3, 12(a1)              # ru_stime.tv_usec
95         ldt     $f15, 16(a1)            # ru_maxrss
96         ldt     $f16, 24(a1)            # ru_ixrss
97         ldt     $f17, 32(a1)            # ru_idrss
98         ldt     $f18, 40(a1)            # ru_isrss
99         ldt     $f19, 48(a1)            # ru_minflt
100         ldt     $f20, 56(a1)            # ru_majflt
101         ldt     $f21, 64(a1)            # ru_nswap
102         ldt     $f22, 72(a1)            # ru_inblock
103         ldt     $f23, 80(a1)            # ru_oublock
104         ldt     $f24, 88(a1)            # ru_msgsend
105         ldt     $f25, 96(a1)            # ru_msgrcv
106         ldt     $f26, 104(a1)           # ru_nsignals
107         ldt     $f27, 112(a1)           # ru_nvcsw
108         .set noat
109         ldt     $f28, 120(a1)           # ru_nivcsw
110         .set at
111         stq     t0, 0(a1)
112         stq     t1, 8(a1)
113         stq     t2, 16(a1)
114         stq     t3, 24(a1)
115         stt     $f15, 32(a1)
116         stt     $f16, 40(a1)
117         stt     $f17, 48(a1)
118         stt     $f18, 56(a1)
119         stt     $f19, 64(a1)
120         stt     $f20, 72(a1)
121         stt     $f21, 80(a1)
122         stt     $f22, 88(a1)
123         stt     $f23, 96(a1)
124         stt     $f24, 104(a1)
125         stt     $f25, 112(a1)
126         stt     $f26, 120(a1)
127         stt     $f27, 128(a1)
128         .set noat
129         stt     $f28, 136(a1)
130         .set at
132         addq    sp, 16, sp
133         ret
135         .align 3
136 $error:
137         addq    sp, 16, sp
138         SYSCALL_ERROR_HANDLER
140 END(GETRUSAGE)
141 #endif /* __ASSUME_TIMEVAL64 */
143 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
144 strong_alias(__getrusage_tv64, ____getrusage_tv64)
145 default_symbol_version (____getrusage_tv64, __getrusage, GLIBC_2.1)
146 default_symbol_version (__getrusage_tv64, getrusage, GLIBC_2.1)
147 #else
148 weak_alias (__getrusage, getrusage)
149 #endif