diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-02-29 12:44:23 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-02-29 12:44:23 +0100 |
commit | 65c89727ffaea201123ecfbaa45c42cb280cc4c0 (patch) | |
tree | e348bc3c9cc9a309a64e042aaaf3ed7d4d0910cf | |
parent | 43394049b01c0107e928f818f23f7666be99505f (diff) | |
download | psutil-65c89727ffaea201123ecfbaa45c42cb280cc4c0.tar.gz |
#780: attempt to fix compilation issues on OSX
-rw-r--r-- | psutil/_psutil_osx.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index f76ca0e6..8c3d81e4 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -581,11 +581,14 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { mach_msg_type_number_t info_count = VM_REGION_TOP_INFO_COUNT; kern_return_t kr; vm_size_t page_size; + mach_vm_address_t addr = MACH_VM_MIN_ADDRESS + mach_port_t task = MACH_PORT_NULL; + vm_region_top_info_data_t info; + mach_port_t object_name; if (! PyArg_ParseTuple(args, "l", &pid)) return NULL; - mach_port_t task = MACH_PORT_NULL; err = task_for_pid(mach_task_self(), pid, &task); if (err != KERN_SUCCESS) { psutil_raise_ad_or_nsp(pid); @@ -600,10 +603,7 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { // Roughly based on libtop_update_vm_regions in // http://www.opensource.apple.com/source/top/top-100.1.2/libtop.c - for (mach_vm_address_t addr = MACH_VM_MIN_ADDRESS; ; addr += size) { - vm_region_top_info_data_t info; - mach_port_t object_name; - + for (addr; ; addr += size) { kr = mach_vm_region( task, &addr, &size, VM_REGION_TOP_INFO, (vm_region_info_t)&info, &info_count, &object_name); @@ -612,7 +612,8 @@ psutil_proc_memory_uss(PyObject *self, PyObject *args) { break; } else if (kr != KERN_SUCCESS) { - return false; + PyErr_Format(PyExc_RuntimeError, "mach_vm_region() failed"); + return NULL; } if (psutil_in_shared_region(addr, cpu_type) && |