ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/tools.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/tools.c (file contents):
Revision 1.27 by pajs, Tue Feb 10 16:23:07 2004 UTC vs.
Revision 1.28 by ats, Fri Feb 13 15:22:49 2004 UTC

# Line 35 | Line 35
35   #include <fcntl.h>
36   #include <kvm.h>
37   #endif
38 < #ifdef NETBSD
38 > #if defined(NETBSD) || defined(OPENBSD)
39   #include <uvm/uvm_extern.h>
40 + #include <sys/param.h>
41 + #include <sys/sysctl.h>
42   #endif
43  
44   #include "tools.h"
# Line 429 | Line 431 | kvm_t *get_kvm() {
431   }
432   #endif
433  
434 < #ifdef NETBSD
434 > #if defined(NETBSD) || defined(OPENBSD)
435   struct uvmexp *get_uvmexp() {
436 <        static u_long addr = 0;
437 <        static struct uvmexp uvm;
438 <        kvm_t *kvmd = get_kvm();
436 >        int mib[2];
437 >        size_t size;
438 >        static struct uvmexp *uvm = NULL;
439  
440 <        if (kvmd == NULL) {
440 >        mib[0] = CTL_VM;
441 >        mib[1] = VM_UVMEXP;
442 >
443 >        if (sysctl(mib, 2, NULL, &size, NULL, 0) < 0) {
444                  return NULL;
445          }
446  
447 <        if (addr == 0) {
448 <                struct nlist symbols[] = {
449 <                        { "_uvmexp" },
445 <                        { NULL }
446 <                };
447 <
448 <                if (kvm_nlist(kvmd, symbols) != 0) {
449 <                        return NULL;
450 <                }
451 <                addr = symbols[0].n_value;
447 >        uvm = realloc(uvm, size);
448 >        if (uvm == NULL) {
449 >                return NULL;
450          }
451  
452 <        if (kvm_read(kvmd, addr, &uvm, sizeof uvm) != sizeof uvm) {
452 >        if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) {
453                  return NULL;
454          }
455 <        return &uvm;
455 >
456 >        return uvm;
457   }
458   #endif
459  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines