Update to LGPL v2.1.
[jlayton/glibc.git] / sysdeps / unix / sysv / linux / alpha / wait4.S
1 /* Copyright (C) 1998 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 WAIT4   __wait4_tv64
37 #else
38 #define WAIT4   __wait4
39 #endif
40
41 LEAF(WAIT4, 32)
42         ldgp    gp, 0(pv)
43         subq    sp, 32, 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 arguments in case we do need to fall back.  */
55         stq     a0, 0(sp)
56         stq     a1, 8(sp)
57         stq     a2, 16(sp)
58         stq     a3, 24(sp)
59
60         bne     t0, $do32
61
62         ldi     v0, SYS_ify(wait4)
63         callsys
64         bne     a3, $err64
65
66         /* Everything ok.  */
67         addq    sp, 32, sp
68         ret
69
70         /* If we didn't get ENOSYS, it is a real error.  */
71         .align 3
72 $err64: cmpeq   v0, ENOSYS, t0
73         beq     t0, $error
74         stl     t0, __libc_missing_axp_tv64
75
76         /* Recover the saved arguments.  */
77         ldq     a3, 24(sp)
78         ldq     a2, 16(sp)
79         ldq     a1, 8(sp)
80         ldq     a0, 0(sp)
81
82         .align 3
83 $do32:  ldi     v0, SYS_ify(osf_wait4)
84         callsys
85         bne     a3, $error
86
87         /* Copy back to proper format.  */
88         ldq     a3, 24(sp)
89         beq     a3, 2f
90         ldl     t0, 0(a3)               # ru_utime.tv_sec
91         ldl     t1, 4(a3)               # ru_utime.tv_usec
92         ldl     t2, 8(a3)               # ru_stime.tv_sec
93         ldl     t3, 12(a3)              # ru_stime.tv_usec
94         ldt     $f15, 16(a3)            # ru_maxrss
95         ldt     $f16, 24(a3)            # ru_ixrss
96         ldt     $f17, 32(a3)            # ru_idrss
97         ldt     $f18, 40(a3)            # ru_isrss
98         ldt     $f19, 48(a3)            # ru_minflt
99         ldt     $f20, 56(a3)            # ru_majflt
100         ldt     $f21, 64(a3)            # ru_nswap
101         ldt     $f22, 72(a3)            # ru_inblock
102         ldt     $f23, 80(a3)            # ru_oublock
103         ldt     $f24, 88(a3)            # ru_msgsend
104         ldt     $f25, 96(a3)            # ru_msgrcv
105         ldt     $f26, 104(a3)           # ru_nsignals
106         ldt     $f27, 112(a3)           # ru_nvcsw
107         .set noat
108         ldt     $f28, 120(a3)           # ru_nivcsw
109         stq     t0, 0(a3)
110         stq     t1, 8(a3)
111         stq     t2, 16(a3)
112         stq     t3, 24(a3)
113         stt     $f15, 32(a3)
114         stt     $f16, 40(a3)
115         stt     $f17, 48(a3)
116         stt     $f18, 56(a3)
117         stt     $f19, 64(a3)
118         stt     $f20, 72(a3)
119         stt     $f21, 80(a3)
120         stt     $f22, 88(a3)
121         stt     $f23, 96(a3)
122         stt     $f24, 104(a3)
123         stt     $f25, 112(a3)
124         stt     $f26, 120(a3)
125         stt     $f27, 128(a3)
126         stt     $f28, 136(a3)
127         .set at
128
129 2:      addq    sp, 32, sp
130         ret
131
132         .align 3
133 $error:
134         addq    sp, 32, sp
135         jmp     zero, __syscall_error
136
137 END(WAIT4)
138
139 #if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
140 default_symbol_version (__wait4_tv64, __wait4, GLIBC_2.1)
141
142 /* It seems to me to be a misfeature of the assembler that we can only
143    have one version-alias per symbol.  So create an alias ourselves.
144    The 'p' is for 'public'.  *Shrug*  */
145 strong_alias (__wait4_tv64, __wait4_tv64p)
146 default_symbol_version (__wait4_tv64p, wait4, GLIBC_2.1)
147 #else
148 weak_alias (__wait4, wait4)
149 #endif