diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-10-04 16:53:17 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-10-04 16:53:20 -0700 |
commit | 627f379f2273341426ab3d5cb7eb4d5c148d500a (patch) | |
tree | 70e7a29423d2572db04fd16ce664396e9bbf0426 /deps/uv/src/unix/darwin.c | |
parent | bc7cfd7cd7c2e513a9ac9a2820f3b6f7331735b5 (diff) | |
download | android-node-v8-627f379f2273341426ab3d5cb7eb4d5c148d500a.tar.gz android-node-v8-627f379f2273341426ab3d5cb7eb4d5c148d500a.tar.bz2 android-node-v8-627f379f2273341426ab3d5cb7eb4d5c148d500a.zip |
upgrade libuv to 0303197
Diffstat (limited to 'deps/uv/src/unix/darwin.c')
-rw-r--r-- | deps/uv/src/unix/darwin.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c index fde515444b..a518cb265e 100644 --- a/deps/uv/src/unix/darwin.c +++ b/deps/uv/src/unix/darwin.c @@ -29,6 +29,9 @@ #include <mach/mach.h> #include <mach/mach_time.h> #include <mach-o/dyld.h> /* _NSGetExecutablePath */ +#include <sys/resource.h> +#include <sys/sysctl.h> +#include <unistd.h> /* sysconf */ uint64_t uv_hrtime() { @@ -68,16 +71,38 @@ int uv_exepath(char* buffer, size_t* size) { return 0; } +double uv_get_free_memory(void) { + vm_statistics_data_t info; + mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t); -int uv_fs_event_init(uv_loop_t* loop, - uv_fs_event_t* handle, - const char* filename, - uv_fs_event_cb cb) { - uv__set_sys_error(loop, ENOSYS); - return -1; + if (host_statistics(mach_host_self(), HOST_VM_INFO, + (host_info_t)&info, &count) != KERN_SUCCESS) { + return -1; + } + + return (double) info.free_count * sysconf(_SC_PAGESIZE); +} + +double uv_get_total_memory(void) { + uint64_t info; + int which[] = {CTL_HW, HW_MEMSIZE}; + size_t size = sizeof(info); + + if (sysctl(which, 2, &info, &size, NULL, 0) < 0) { + return -1; + } + + return (double) info; } +void uv_loadavg(double avg[3]) { + struct loadavg info; + size_t size = sizeof(info); + int which[] = {CTL_VM, VM_LOADAVG}; + + if (sysctl(which, 2, &info, &size, NULL, 0) < 0) return; -void uv__fs_event_destroy(uv_fs_event_t* handle) { - assert(0 && "implement me"); + avg[0] = (double) info.ldavg[0] / info.fscale; + avg[1] = (double) info.ldavg[1] / info.fscale; + avg[2] = (double) info.ldavg[2] / info.fscale; } |