Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade libc #27414

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ indexmap = { version = "2", features = ["serde"] }
ipnet = "2.3"
jsonc-parser = { version = "=0.26.2", features = ["serde"] }
lazy-regex = "3"
libc = "0.2.126"
libc = "0.2.168"
libz-sys = { version = "1.1.20", default-features = false }
log = { version = "0.4.20", features = ["kv"] }
lsp-types = "=0.97.0" # used by tower-lsp and "proposed" feature is unstable in patch releases
Expand Down
9 changes: 7 additions & 2 deletions ext/node/ops/os/cpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ pub fn cpu_info() -> Option<Vec<CpuInfo>> {
cpu_speed = 2_400_000_000;
}

extern "C" {
fn mach_host_self() -> std::ffi::c_uint;
static mut mach_task_self_: std::ffi::c_uint;
}

let mut num_cpus: libc::natural_t = 0;
let mut info: *mut libc::processor_cpu_load_info_data_t =
std::ptr::null_mut();
let mut msg_type: libc::mach_msg_type_number_t = 0;
if libc::host_processor_info(
libc::mach_host_self(),
mach_host_self(),
libc::PROCESSOR_CPU_LOAD_INFO,
&mut num_cpus,
&mut info as *mut _ as *mut libc::processor_info_array_t,
Expand Down Expand Up @@ -111,7 +116,7 @@ pub fn cpu_info() -> Option<Vec<CpuInfo>> {
}

libc::vm_deallocate(
libc::mach_task_self(),
mach_task_self_,
info.as_ptr() as libc::vm_address_t,
msg_type as _,
);
Expand Down
5 changes: 4 additions & 1 deletion runtime/ops/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,11 @@ fn rss() -> usize {
let mut count = libc::MACH_TASK_BASIC_INFO_COUNT;
// SAFETY: libc calls
let r = unsafe {
extern "C" {
static mut mach_task_self_: std::ffi::c_uint;
}
libc::task_info(
libc::mach_task_self(),
mach_task_self_,
libc::MACH_TASK_BASIC_INFO,
task_info.as_mut_ptr() as libc::task_info_t,
&mut count as *mut libc::mach_msg_type_number_t,
Expand Down
6 changes: 5 additions & 1 deletion runtime/sys_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,15 @@ pub fn mem_info() -> Option<MemInfo> {
mem_info.swap_total = xs.xsu_total;
mem_info.swap_free = xs.xsu_avail;

extern "C" {
fn mach_host_self() -> std::ffi::c_uint;
}

let mut count: u32 = libc::HOST_VM_INFO64_COUNT as _;
let mut stat = std::mem::zeroed::<libc::vm_statistics64>();
if libc::host_statistics64(
// TODO(@littledivy): Put this in a once_cell.
libc::mach_host_self(),
mach_host_self(),
libc::HOST_VM_INFO64,
&mut stat as *mut libc::vm_statistics64 as *mut _,
&mut count,
Expand Down
Loading