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.13 by ats, Mon Nov 10 22:46:32 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  
63 < #ifdef HAVE_ATOLL
63 > #ifndef HAVE_ATOLL
64 > static long long atoll(const char *s) {
65 >        long long value = 0;
66 >        int isneg = 0;
67 >
68 >        while (*s == ' ' || *s == '\t') {
69 >                s++;
70 >        }
71 >        if (*s == '-') {
72 >                isneg = 1;
73 >                s++;
74 >        }
75 >        while (*s >= '0' && *s <= '9') {
76 >                value = (10 * value) + (*s - '0');
77 >                s++;
78 >        }
79 >        return (isneg ? -value : value);
80 > }
81 > #endif
82 >
83   long long get_ll_match(char *line, regmatch_t *match){
84          char *ptr;
85          long long num;
# Line 67 | Line 89 | long long get_ll_match(char *line, regmatch_t *match){
89  
90          return num;
91   }
70 #endif
92  
93 < #ifdef FREEBSD
93 > #ifdef ALLBSD
94   kvm_t *get_kvm() {
95          static kvm_t *kvmd = NULL;
96  
# Line 81 | Line 102 | kvm_t *get_kvm() {
102          return kvmd;
103   }
104   #endif
105 +
106 + #ifdef NETBSD
107 + struct uvmexp *get_uvmexp() {
108 +        static u_long addr = 0;
109 +        static struct uvmexp uvm;
110 +        kvm_t *kvmd = get_kvm();
111 +
112 +        if (kvmd == NULL) {
113 +                return NULL;
114 +        }
115 +
116 +        if (addr == 0) {
117 +                struct nlist symbols[] = {
118 +                        { "_uvmexp" },
119 +                        { NULL }
120 +                };
121 +
122 +                if (kvm_nlist(kvmd, symbols) != 0) {
123 +                        return NULL;
124 +                }
125 +                addr = symbols[0].n_value;
126 +        }
127 +
128 +        if (kvm_read(kvmd, addr, &uvm, sizeof uvm) != sizeof uvm) {
129 +                return NULL;
130 +        }
131 +        return &uvm;
132 + }
133 + #endif
134 +
135 + int statgrab_init(){
136 + #ifdef ALLBSD
137 +        {
138 +                kvm_t *kvmd = get_kvm();
139 +                if (kvmd == NULL) return 1;
140 +        }
141 + #endif
142 + #ifdef NETBSD
143 +        {
144 +                struct uvmexp *uvm = get_uvmexp();
145 +                if (uvm == NULL) return 1;
146 +        }
147 + #endif
148 +        return 0;
149 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines