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.8 by ats, Sun Oct 19 00:25:30 2003 UTC vs.
Revision 1.12 by tdb, Mon Nov 10 21:07:04 2003 UTC

# Line 27 | Line 27
27   #include <stdlib.h>
28   #include <sys/types.h>
29   #include <regex.h>
30 < #ifdef FREEBSD
30 > #ifdef ALLBSD
31   #include <fcntl.h>
32   #include <kvm.h>
33   #endif
34 + #ifdef NETBSD
35 + #include <uvm/uvm_extern.h>
36 + #endif
37  
38   #include "tools.h"
39  
# Line 57 | Line 60 | char *get_string_match(char *line, regmatch_t *match){
60          return match_string;
61   }
62  
60 #ifdef HAVE_ATOLL
63   long long get_ll_match(char *line, regmatch_t *match){
64          char *ptr;
65          long long num;
66  
67          ptr=line+match->rm_so;
68 + #ifdef HAVE_ATOLL
69          num=atoll(ptr);
70 + #else
71 +        /* Don't have atoll, so use this bodge instead */
72 +        {
73 +                long numl;
74 +                numl=atol(ptr);
75 +                num=numl;
76 +        }
77 + #endif
78  
79          return num;
80   }
70 #endif
81  
82 < #ifdef FREEBSD
82 > #ifdef ALLBSD
83   kvm_t *get_kvm() {
84          static kvm_t *kvmd = NULL;
85  
# Line 81 | Line 91 | kvm_t *get_kvm() {
91          return kvmd;
92   }
93   #endif
94 +
95 + #ifdef NETBSD
96 + struct uvmexp *get_uvmexp() {
97 +        static u_long addr = 0;
98 +        static struct uvmexp uvm;
99 +        kvm_t *kvmd = get_kvm();
100 +
101 +        if (kvmd == NULL) {
102 +                return NULL;
103 +        }
104 +
105 +        if (addr == 0) {
106 +                struct nlist symbols[] = {
107 +                        { "_uvmexp" },
108 +                        { NULL }
109 +                };
110 +
111 +                if (kvm_nlist(kvmd, symbols) != 0) {
112 +                        return NULL;
113 +                }
114 +                addr = symbols[0].n_value;
115 +        }
116 +
117 +        if (kvm_read(kvmd, addr, &uvm, sizeof uvm) != sizeof uvm) {
118 +                return NULL;
119 +        }
120 +        return &uvm;
121 + }
122 + #endif
123 +
124 + int statgrab_init(){
125 + #ifdef ALLBSD
126 +        {
127 +                kvm_t *kvmd = get_kvm();
128 +                if (kvmd == NULL) return 1;
129 +        }
130 + #endif
131 + #ifdef NETBSD
132 +        {
133 +                struct uvmexp *uvm = get_uvmexp();
134 +                if (uvm == NULL) return 1;
135 +        }
136 + #endif
137 +        return 0;
138 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines