Added initial port for BSD/OS (aka BSDI) 2.x and 3.x. 4.x should also(?)
Thu Apr 8 23:47:29 1999 Timur Bakeyev <timur@gnu.org> * cpu.c, mem.c, netload.c, procargs.c, procstate.c, proctime.c, sem_limits.c, shm_limits.c, swap.c: Added initial port for BSD/OS (aka BSDI) 2.x and 3.x. 4.x should also(?) work. Still, this port require more close look and extended check.
This commit is contained in:
committed by
Timur I. Bakeyev
parent
5967e6c3e4
commit
fac354623b
@@ -28,17 +28,13 @@
|
||||
#include <glibtop_suid.h>
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#ifndef __bsdi__
|
||||
#include <sys/vmmeter.h>
|
||||
#endif
|
||||
#include <vm/vm_param.h>
|
||||
|
||||
static const unsigned long _glibtop_sysdeps_mem =
|
||||
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
|
||||
(1 << GLIBTOP_MEM_FREE) +
|
||||
#ifndef __bsdi__
|
||||
(1 << GLIBTOP_MEM_SHARED) +
|
||||
#endif
|
||||
(1 << GLIBTOP_MEM_BUFFER) +
|
||||
#ifdef __FreeBSD__
|
||||
(1 << GLIBTOP_MEM_CACHED) +
|
||||
@@ -58,7 +54,9 @@ static int pageshift; /* log base 2 of the pagesize */
|
||||
/* nlist structure for kernel access */
|
||||
static struct nlist nlst [] = {
|
||||
{ "_cnt" },
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__bsdi__)
|
||||
{ "_bufcachemem" },
|
||||
#elif defined(__FreeBSD__)
|
||||
{ "_bufspace" },
|
||||
#else
|
||||
{ "_bufpages" },
|
||||
@@ -66,11 +64,13 @@ static struct nlist nlst [] = {
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#ifndef __bsdi__
|
||||
/* MIB array for sysctl */
|
||||
/* static int mib_length=2; */
|
||||
static int mib_length=2;
|
||||
#ifdef __bsdi__
|
||||
static int mib [] = { CTL_VM, VM_TOTAL };
|
||||
#else
|
||||
static int mib [] = { CTL_VM, VM_METER };
|
||||
#endif /* __bsdi__ */
|
||||
#endif
|
||||
|
||||
/* Init function. */
|
||||
|
||||
@@ -102,10 +102,8 @@ glibtop_init_mem_p (glibtop *server)
|
||||
void
|
||||
glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
{
|
||||
#ifndef __bsdi__
|
||||
struct vmtotal vmt;
|
||||
size_t length_vmt;
|
||||
#endif
|
||||
struct vmmeter vmm;
|
||||
u_int v_used_count;
|
||||
u_int v_total_count;
|
||||
@@ -118,7 +116,6 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
if (server->sysdeps.mem == 0)
|
||||
return;
|
||||
|
||||
#ifndef __bsdi__
|
||||
/* [FIXME: On FreeBSD 2.2.6, sysctl () returns an incorrect
|
||||
* value for `vmt.vm'. We use some code from Unix top
|
||||
* here.] */
|
||||
@@ -129,7 +126,6 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
glibtop_warn_io_r (server, "sysctl");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get the data from kvm_* */
|
||||
if (kvm_read (server->machine.kd, nlst[0].n_value,
|
||||
@@ -146,7 +142,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
|
||||
/* convert memory stats to Kbytes */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__)
|
||||
v_total_count = vmm.v_page_count;
|
||||
#else
|
||||
v_total_count = vmm.v_kernel_pages +
|
||||
@@ -165,9 +161,7 @@ glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
|
||||
#endif
|
||||
|
||||
buf->locked = (u_int64_t) pagetok (vmm.v_wire_count) << LOG1024;
|
||||
#ifndef __bsdi__
|
||||
buf->shared = (u_int64_t) pagetok (vmt.t_rmshr) << LOG1024;
|
||||
#endif
|
||||
|
||||
#if __FreeBSD__
|
||||
buf->buffer = (u_int64_t) bufspace;
|
||||
|
Reference in New Issue
Block a user