Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-01-20 22:12:25 +0300
committerRyan Dahl <ry@tinyclouds.org>2010-01-20 22:19:17 +0300
commitf88d39de7416431db590f5e3034cc5ce81e6bc67 (patch)
treef952051e7f3fd9880529865657acd3c24d011aac
parentfaefb3f5a411ebaaa381ed77c5e00d405af92a3f (diff)
getmem() for solaris
-rw-r--r--src/node.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc
index 01b9ed5c9ea..8796047c6af 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -475,6 +475,50 @@ v8::Handle<v8::Value> Exit(const v8::Arguments& args) {
return Undefined();
}
+#ifdef __sun
+#define HAVE_GETMEM 1
+#include <unistd.h> /* getpagesize() */
+
+#if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64)
+#define PROCFS_FILE_OFFSET_BITS_HACK 1
+#undef _FILE_OFFSET_BITS
+#else
+#define PROCFS_FILE_OFFSET_BITS_HACK 0
+#endif
+
+#include <procfs.h>
+
+#if (PROCFS_FILE_OFFSET_BITS_HACK - 0 == 1)
+#define _FILE_OFFSET_BITS 64
+#endif
+
+int getmem(size_t *rss, size_t *vsize) {
+ pid_t pid = getpid();
+
+ size_t page_size = getpagesize();
+ char pidpath[1024];
+ sprintf(pidpath, "/proc/%d/psinfo", pid);
+
+ psinfo_t psinfo;
+ FILE *f = fopen(pidpath, "r");
+ if (!f) return -1;
+
+ if (fread(&psinfo, sizeof(psinfo_t), 1, f) != 1) {
+ fclose (f);
+ return -1;
+ }
+
+ /* XXX correct? */
+
+ *vsize = (size_t) psinfo.pr_size * page_size;
+ *rss = (size_t) psinfo.pr_rssize * 1024;
+
+ fclose (f);
+
+ return 0;
+}
+#endif
+
#ifdef __FreeBSD__
#define HAVE_GETMEM 1