Add rumpuser interface to fetch number of host cpus.

This commit is contained in:
pooka 2010-04-28 00:33:45 +00:00
parent a801fd0fcf
commit db171f695e
2 changed files with 21 additions and 3 deletions

View File

@ -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 @@ __RCSID("$NetBSD: rumpuser.c,v 1.3 2010/04/21 11:16:41 pooka Exp $");
#ifdef __NetBSD__
#include <sys/disklabel.h>
#include <sys/sysctl.h>
#endif
#include <assert.h>
@ -589,3 +590,18 @@ rumpuser_kill(int64_t pid, int sig, int *error)
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
}

View File

@ -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_writewatchfile_wait(int, intptr_t *, int *);
int rumpuser_dprintf(const char *, ...);
int rumpuser_getnhostcpu(void);
/* rumpuser_pth */
void rumpuser_thrinit(kernel_lockfn, kernel_unlockfn, int);
void rumpuser_biothread(void *);