Browse Source

getmem for freebsd

v0.7.4-release
Vanilla Hsu 15 years ago
committed by Ryan Dahl
parent
commit
d22952bfe0
  1. 38
      src/node.cc
  2. 7
      wscript

38
src/node.cc

@ -457,6 +457,44 @@ v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
return Undefined(); return Undefined();
} }
#ifdef __FreeBSD__
#define HAVE_GETMEM 1
#include <kvm.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <fcntl.h>
#include <unistd.h>
int getmem(size_t *rss, size_t *vsize) {
kvm_t *kd = NULL;
struct kinfo_proc *kinfo = NULL;
pid_t pid;
int nprocs;
pid = getpid();
kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
if (kd == NULL) goto error;
kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &nprocs);
if (kinfo == NULL) goto error;
*rss = kinfo->ki_rssize * PAGE_SIZE;
*vsize = kinfo->ki_size;
kvm_close(kd);
return 0;
error:
if (kd) kvm_close(kd);
return -1;
}
#endif // __FreeBSD__
#ifdef __APPLE__ #ifdef __APPLE__
#define HAVE_GETMEM 1 #define HAVE_GETMEM 1
/* Researched by Tim Becker and Michael Knight /* Researched by Tim Becker and Michael Knight

7
wscript

@ -109,6 +109,9 @@ def configure(conf):
conf.env.append_value("CCFLAGS", "-rdynamic") conf.env.append_value("CCFLAGS", "-rdynamic")
conf.env.append_value("LINKFLAGS_DL", "-rdynamic") conf.env.append_value("LINKFLAGS_DL", "-rdynamic")
if sys.platform.startswith("freebsd"):
conf.check(lib='kvm', uselib_store='KVM')
#if Options.options.debug: #if Options.options.debug:
# conf.check(lib='profiler', uselib_store='PROFILER') # conf.check(lib='profiler', uselib_store='PROFILER')
@ -127,7 +130,7 @@ def configure(conf):
#libpath=['/usr/lib', '/usr/local/lib'], #libpath=['/usr/lib', '/usr/local/lib'],
uselib_store='GNUTLS'): uselib_store='GNUTLS'):
if conf.check(lib='gpg-error', if conf.check(lib='gpg-error',
#libpath=['/usr/lib', '/usr/local/lib'], libpath=['/usr/lib', '/usr/local/lib'],
uselib_store='GPGERROR'): uselib_store='GPGERROR'):
conf.env.append_value("CCFLAGS", "-DEVCOM_HAVE_GNUTLS=1") conf.env.append_value("CCFLAGS", "-DEVCOM_HAVE_GNUTLS=1")
conf.env.append_value("CXXFLAGS", "-DEVCOM_HAVE_GNUTLS=1") conf.env.append_value("CXXFLAGS", "-DEVCOM_HAVE_GNUTLS=1")
@ -346,7 +349,7 @@ def build(bld):
""" """
node.add_objects = 'ev eio evcom http_parser coupling' node.add_objects = 'ev eio evcom http_parser coupling'
node.uselib_local = '' node.uselib_local = ''
node.uselib = 'UDNS V8 EXECINFO DL GPGERROR GNUTLS' node.uselib = 'UDNS V8 EXECINFO DL KVM GPGERROR GNUTLS'
node.install_path = '${PREFIX}/lib' node.install_path = '${PREFIX}/lib'
node.install_path = '${PREFIX}/bin' node.install_path = '${PREFIX}/bin'

Loading…
Cancel
Save