Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/irix Fixed functions to get the number of CPU in ...
details: https://anonhg.NetBSD.org/src/rev/566b423db561
branches: trunk
changeset: 525915:566b423db561
user: manu <manu%NetBSD.org@localhost>
date: Sat Apr 20 21:25:01 2002 +0000
description:
Fixed functions to get the number of CPU in sysmp() and systeminfo(). The
problam was that when hw_sysctl() is used, the result is supposed to be
in userland
diffstat:
sys/compat/irix/irix_sysmp.c | 14 +++++++++-----
sys/compat/irix/irix_systeminfo.c | 22 +++++++++++++++-------
2 files changed, 24 insertions(+), 12 deletions(-)
diffs (114 lines):
diff -r be2e334c54ee -r 566b423db561 sys/compat/irix/irix_sysmp.c
--- a/sys/compat/irix/irix_sysmp.c Sat Apr 20 20:56:25 2002 +0000
+++ b/sys/compat/irix/irix_sysmp.c Sat Apr 20 21:25:01 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_sysmp.c,v 1.7 2002/03/28 10:37:46 manu Exp $ */
+/* $NetBSD: irix_sysmp.c,v 1.8 2002/04/20 21:25:01 manu Exp $ */
/*-
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_sysmp.c,v 1.7 2002/03/28 10:37:46 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_sysmp.c,v 1.8 2002/04/20 21:25:01 manu Exp $");
#include <sys/errno.h>
#include <sys/param.h>
@@ -52,6 +52,8 @@
#include <machine/vmparam.h>
+#include <compat/common/compat_util.h>
+
#include <compat/svr4/svr4_types.h>
#include <compat/irix/irix_types.h>
@@ -81,6 +83,7 @@
} */ *uap = v;
int cmd = SCARG(uap, cmd);
int error = 0;
+ caddr_t sg = stackgap_init(p, 0);
#ifdef DEBUG_IRIX
printf("irix_sys_sysmp(): cmd = %d\n", cmd);
@@ -89,13 +92,14 @@
switch(cmd) {
case IRIX_MP_NPROCS: /* Number of processors in complex */
case IRIX_MP_NAPROCS: { /* Number of active processors in complex */
- int ncpu;
+ int *ncpu = stackgap_alloc(p, &sg, sizeof(int));
int name = HW_NCPU;
int namelen = sizeof(name);
- error = hw_sysctl(&name, 1, &ncpu, &namelen, NULL, 0, p);
+ error = hw_sysctl(&name, 1, ncpu, &namelen, NULL, 0, p);
if (!error)
- *retval = (register_t)ncpu;
+ error = copyin(ncpu, retval, sizeof(int));
+
return error;
break;
}
diff -r be2e334c54ee -r 566b423db561 sys/compat/irix/irix_systeminfo.c
--- a/sys/compat/irix/irix_systeminfo.c Sat Apr 20 20:56:25 2002 +0000
+++ b/sys/compat/irix/irix_systeminfo.c Sat Apr 20 21:25:01 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: irix_systeminfo.c,v 1.2 2002/02/21 11:09:43 manu Exp $ */
+/* $NetBSD: irix_systeminfo.c,v 1.3 2002/04/20 21:25:01 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_systeminfo.c,v 1.2 2002/02/21 11:09:43 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_systeminfo.c,v 1.3 2002/04/20 21:25:01 manu Exp $");
#include <sys/types.h>
#include <sys/signal.h>
@@ -48,6 +48,8 @@
#include <sys/sysctl.h>
#include <sys/syscallargs.h>
+#include <compat/common/compat_util.h>
+
#include <compat/svr4/svr4_systeminfo.h>
#include <compat/svr4/svr4_types.h>
#include <compat/svr4/svr4_signal.h>
@@ -86,6 +88,7 @@
int error;
size_t len;
char buf[256];
+ caddr_t sg = stackgap_init(p, 0);
u_int rlen = SCARG(uap, len);
@@ -124,15 +127,20 @@
case SVR4_MIPS_SI_NUM_PROCESSORS:
case SVR4_MIPS_SI_AVAIL_PROCESSORS: {
+ int *ncpup = stackgap_alloc(p, &sg, sizeof(int));
int ncpu;
int name = HW_NCPU;
int namelen = sizeof(name);
- error = hw_sysctl(&name, 1, &ncpu, &namelen, NULL, 0, p);
- if (!error) {
- snprintf(strbuf, BUF_SIZE, "%d", ncpu);
- str = strbuf;
- }
+ if ((error = hw_sysctl
+ (&name, 1, ncpup, &namelen, NULL, 0, p)) != 0)
+ return error;
+
+ if ((error = copyin(ncpup, &ncpu, sizeof(int))) != 0)
+ return error;
+
+ snprintf(strbuf, BUF_SIZE, "%d", ncpu);
+ str = strbuf;
break;
}
Home |
Main Index |
Thread Index |
Old Index