Update.
[glibc.git] / sysdeps / unix / sysv / linux / alpha / getrusage.S
blob83cfc9e4e315621dbda4641a76d6be32eaa090df
1 /* Copyright (C) 1998 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 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 not,
16    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17    Boston, MA 02111-1307, USA.  */
19 #include <sysdep.h>
20 #define _ERRNO_H        1
21 #include <bits/errno.h>
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.
27    So now we have to do compatibility stuff.  */
29 /* The variable is shared between all wrappers around signal handling
30    functions which have RT equivalents.  */
31 .comm __libc_missing_axp_tv64, 4
33 .text
35 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
36 #define GETRUSAGE       __getrusage_tv64
37 #else
38 #define GETRUSAGE       __getrusage
39 #endif
41 LEAF(GETRUSAGE, 16)
42         ldgp    gp, 0(pv)
43         subq    sp, 16, sp
44 #ifdef PROF
45         .set noat
46         lda     AT, _mcount
47         jsr     AT, (AT), _mcount
48         .set at
49 #endif
50         .prologue 1
52         ldl     t0, __libc_missing_axp_tv64
54         /* Save arguments in case we do need to fall back.  */
55         stq     a0, 0(sp)
56         stq     a1, 8(sp)
58         bne     t0, $do32
60         ldi     v0, SYS_ify(getrusage)
61         callsys
62         bne     a3, $err64
64         /* Everything ok.  */
65         addq    sp, 16, sp
66         ret
68         /* If we didn't get ENOSYS, it is a real error.  */
69         .align 3
70 $err64: cmpeq   v0, ENOSYS, t0
71         beq     t0, $error
72         stl     t0, __libc_missing_axp_tv64
74         /* Recover the saved arguments.  */
75         ldq     a1, 8(sp)
76         ldq     a0, 0(sp)
78         .align 3
79 $do32:  ldi     v0, SYS_ify(osf_getrusage)
80         callsys
81         bne     a3, $error
83         /* Copy back to proper format.  */
84         ldq     a1, 8(sp)
85         ldl     t0, 0(a1)               # ru_utime.tv_sec
86         ldl     t1, 4(a1)               # ru_utime.tv_usec
87         ldl     t2, 8(a1)               # ru_stime.tv_sec
88         ldl     t3, 12(a1)              # ru_stime.tv_usec
89         ldt     $f15, 16(a1)            # ru_maxrss
90         ldt     $f16, 24(a1)            # ru_ixrss
91         ldt     $f17, 32(a1)            # ru_idrss
92         ldt     $f18, 40(a1)            # ru_isrss
93         ldt     $f19, 48(a1)            # ru_minflt
94         ldt     $f20, 56(a1)            # ru_majflt
95         ldt     $f21, 64(a1)            # ru_nswap
96         ldt     $f22, 72(a1)            # ru_inblock
97         ldt     $f23, 80(a1)            # ru_oublock
98         ldt     $f24, 88(a1)            # ru_msgsend
99         ldt     $f25, 96(a1)            # ru_msgrcv
100         ldt     $f26, 104(a1)           # ru_nsignals
101         ldt     $f27, 112(a1)           # ru_nvcsw
102         ldt     $f28, 120(a1)           # ru_nivcsw
103         stq     t0, 0(a1)
104         stq     t1, 8(a1)
105         stq     t2, 16(a1)
106         stq     t3, 24(a1)
107         stt     $f15, 32(a1)
108         stt     $f16, 40(a1)
109         stt     $f17, 48(a1)
110         stt     $f18, 56(a1)
111         stt     $f19, 64(a1)
112         stt     $f20, 72(a1)
113         stt     $f21, 80(a1)
114         stt     $f22, 88(a1)
115         stt     $f23, 96(a1)
116         stt     $f24, 104(a1)
117         stt     $f25, 112(a1)
118         stt     $f26, 120(a1)
119         stt     $f27, 128(a1)
120         stt     $f28, 136(a1)
122         addq    sp, 16, sp
123         ret
125         .align 3
126 $error:
127         lda     pv, __syscall_error
128         addq    sp, 16, sp
129         jmp     zero, (pv), __syscall_error
131 END(GETRUSAGE)
133 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
134 strong_alias(__getrusage_tv64, ____getrusage_tv64)
135 default_symbol_version (____getrusage_tv64, __getrusage, GLIBC_2.1)
136 default_symbol_version (__getrusage_tv64, getrusage, GLIBC_2.1)
137 #else
138 weak_alias(__getrusage, getrusage)
139 #endif