Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add rumpuser interface to fetch number of host cpus.
details: https://anonhg.NetBSD.org/src/rev/37dbc35fc6a1
branches: trunk
changeset: 754327:37dbc35fc6a1
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Apr 28 00:33:45 2010 +0000
description:
Add rumpuser interface to fetch number of host cpus.
diffstat:
lib/librumpuser/rumpuser.c | 20 ++++++++++++++++++--
sys/rump/include/rump/rumpuser.h | 4 +++-
2 files changed, 21 insertions(+), 3 deletions(-)
diffs (63 lines):
diff -r 01061fcbf6df -r 37dbc35fc6a1 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c Wed Apr 28 00:32:30 2010 +0000
+++ b/lib/librumpuser/rumpuser.c Wed Apr 28 00:33:45 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.c,v 1.3 2010/04/21 11:16:41 pooka Exp $ */
+/* $NetBSD: rumpuser.c,v 1.4 2010/04/28 00:33:45 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.3 2010/04/21 11:16:41 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.4 2010/04/28 00:33:45 pooka Exp $");
#endif /* !lint */
/* thank the maker for this */
@@ -46,6 +46,7 @@
#ifdef __NetBSD__
#include <sys/disklabel.h>
+#include <sys/sysctl.h>
#endif
#include <assert.h>
@@ -589,3 +590,18 @@
return -1;
#endif
}
+
+int
+rumpuser_getnhostcpu(void)
+{
+ int ncpu;
+ size_t sz = sizeof(ncpu);
+
+#ifdef __NetBSD__
+ if (sysctlbyname("hw.ncpu", &ncpu, &sz, NULL, 0) == -1)
+ return 1;
+ return ncpu;
+#else
+ return 1;
+#endif
+}
diff -r 01061fcbf6df -r 37dbc35fc6a1 sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Wed Apr 28 00:32:30 2010 +0000
+++ b/sys/rump/include/rump/rumpuser.h Wed Apr 28 00:33:45 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.39 2010/04/21 11:13:29 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.40 2010/04/28 00:33:45 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@@ -109,6 +109,8 @@
int rumpuser_dprintf(const char *, ...);
+int rumpuser_getnhostcpu(void);
+
/* rumpuser_pth */
void rumpuser_thrinit(kernel_lockfn, kernel_unlockfn, int);
void rumpuser_biothread(void *);
Home |
Main Index |
Thread Index |
Old Index