No empty .Rs/.Re
[netbsd-mini2440.git] / sys / compat / osf1 / osf1_resource.c
blob47df02d910e9cf28a05654e529b7fa695d33c43b
1 /* $NetBSD: osf1_resource.c,v 1.13 2008/04/24 18:39:23 ad Exp $ */
3 /*
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: osf1_resource.c,v 1.13 2008/04/24 18:39:23 ad Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/proc.h>
39 #include <sys/mount.h>
40 #include <sys/syscallargs.h>
41 #include <sys/resource.h>
42 #include <sys/resourcevar.h>
44 #include <compat/osf1/osf1.h>
45 #include <compat/osf1/osf1_syscallargs.h>
46 #include <compat/osf1/osf1_cvt.h>
48 int
49 osf1_sys_getrlimit(struct lwp *l, const struct osf1_sys_getrlimit_args *uap, register_t *retval)
51 struct sys_getrlimit_args a;
53 switch (SCARG(uap, which)) {
54 case OSF1_RLIMIT_CPU:
55 SCARG(&a, which) = RLIMIT_CPU;
56 break;
57 case OSF1_RLIMIT_FSIZE:
58 SCARG(&a, which) = RLIMIT_FSIZE;
59 break;
60 case OSF1_RLIMIT_DATA:
61 SCARG(&a, which) = RLIMIT_DATA;
62 break;
63 case OSF1_RLIMIT_STACK:
64 SCARG(&a, which) = RLIMIT_STACK;
65 break;
66 case OSF1_RLIMIT_CORE:
67 SCARG(&a, which) = RLIMIT_CORE;
68 break;
69 case OSF1_RLIMIT_RSS:
70 SCARG(&a, which) = RLIMIT_RSS;
71 break;
72 case OSF1_RLIMIT_NOFILE:
73 SCARG(&a, which) = RLIMIT_NOFILE;
74 break;
75 case OSF1_RLIMIT_AS:
76 SCARG(&a, which) = RLIMIT_AS;
77 break;
78 default:
79 return (EINVAL);
82 /* XXX should translate */
83 SCARG(&a, rlp) = SCARG(uap, rlp);
85 return sys_getrlimit(l, &a, retval);
88 int
89 osf1_sys_getrusage(struct lwp *l, const struct osf1_sys_getrusage_args *uap, register_t *retval)
91 struct osf1_rusage osf1_rusage;
92 struct rusage ru;
93 struct proc *p = l->l_proc;
96 switch (SCARG(uap, who)) {
97 case OSF1_RUSAGE_SELF:
98 mutex_enter(p->p_lock);
99 ru = p->p_stats->p_ru;
100 calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL);
101 rulwps(p, &ru);
102 mutex_exit(p->p_lock);
103 break;
105 case OSF1_RUSAGE_CHILDREN:
106 ru = p->p_stats->p_cru;
107 break;
109 case OSF1_RUSAGE_THREAD: /* XXX not supported */
110 default:
111 return (EINVAL);
114 osf1_cvt_rusage_from_native(&ru, &osf1_rusage);
116 return copyout(&osf1_rusage, SCARG(uap, rusage), sizeof osf1_rusage);
120 osf1_sys_setrlimit(struct lwp *l, const struct osf1_sys_setrlimit_args *uap, register_t *retval)
122 struct sys_setrlimit_args a;
124 switch (SCARG(uap, which)) {
125 case OSF1_RLIMIT_CPU:
126 SCARG(&a, which) = RLIMIT_CPU;
127 break;
128 case OSF1_RLIMIT_FSIZE:
129 SCARG(&a, which) = RLIMIT_FSIZE;
130 break;
131 case OSF1_RLIMIT_DATA:
132 SCARG(&a, which) = RLIMIT_DATA;
133 break;
134 case OSF1_RLIMIT_STACK:
135 SCARG(&a, which) = RLIMIT_STACK;
136 break;
137 case OSF1_RLIMIT_CORE:
138 SCARG(&a, which) = RLIMIT_CORE;
139 break;
140 case OSF1_RLIMIT_RSS:
141 SCARG(&a, which) = RLIMIT_RSS;
142 break;
143 case OSF1_RLIMIT_NOFILE:
144 SCARG(&a, which) = RLIMIT_NOFILE;
145 break;
146 case OSF1_RLIMIT_AS:
147 SCARG(&a, which) = RLIMIT_AS;
148 break;
149 default:
150 return (EINVAL);
153 /* XXX should translate */
154 SCARG(&a, rlp) = SCARG(uap, rlp);
156 return sys_setrlimit(l, &a, retval);