about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-06-28 13:46:43 +0000
committerbors <bors@rust-lang.org>2022-06-28 13:46:43 +0000
commit00ebeb87ac87a492bd59ace6bd43d6ad1629ca4e (patch)
tree08462526fb5f69acea449b972d435d0ebed03906 /compiler/rustc_data_structures/src
parentbaf382e63c023259fa1f9042f8f479f183ca6ed3 (diff)
parent66b806084ec50917ab6cb87c3774facfdf3038fa (diff)
downloadrust-00ebeb87ac87a492bd59ace6bd43d6ad1629ca4e.tar.gz
rust-00ebeb87ac87a492bd59ace6bd43d6ad1629ca4e.zip
Auto merge of #98612 - Dylan-DPC:rollup-7tasikc, r=Dylan-DPC
Rollup of 9 pull requests

Successful merges:

 - #97346 (Remove a back-compat hack on lazy TAIT)
 - #98261 (Remove `MAX_SUGGESTION_HIGHLIGHT_LINES`)
 - #98337 ([RFC 2011] Optimize non-consuming operators)
 - #98384 (Fix RSS reporting on macOS)
 - #98420 (translation: lint fix + more migration)
 - #98430 (Refactor iter adapters with less macros)
 - #98555 (Hermit: Fix initializing lazy locks)
 - #98595 (Implement `Send` and `Sync` for `ThinBox<T>`)
 - #98597 (Remove unstable CStr/CString change from 1.62 release note)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/profiling.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs
index 88ff33b4d09..d8b26f9840b 100644
--- a/compiler/rustc_data_structures/src/profiling.rs
+++ b/compiler/rustc_data_structures/src/profiling.rs
@@ -826,6 +826,24 @@ cfg_if! {
                 }
             }
         }
+    } else if #[cfg(target_os = "macos")] {
+        pub fn get_resident_set_size() -> Option<usize> {
+            use libc::{c_int, c_void, getpid, proc_pidinfo, proc_taskinfo, PROC_PIDTASKINFO};
+            use std::mem;
+            const PROC_TASKINFO_SIZE: c_int = mem::size_of::<proc_taskinfo>() as c_int;
+
+            unsafe {
+                let mut info: proc_taskinfo = mem::zeroed();
+                let info_ptr = &mut info as *mut proc_taskinfo as *mut c_void;
+                let pid = getpid() as c_int;
+                let ret = proc_pidinfo(pid, PROC_PIDTASKINFO, 0, info_ptr, PROC_TASKINFO_SIZE);
+                if ret == PROC_TASKINFO_SIZE {
+                    Some(info.pti_resident_size as usize)
+                } else {
+                    None
+                }
+            }
+        }
     } else if #[cfg(unix)] {
         pub fn get_resident_set_size() -> Option<usize> {
             let field = 1;