Skip to content

Commit

Permalink
upgrade to libuv v1.44.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatcuk committed Sep 4, 2022
1 parent 0843969 commit df60c99
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libuv"
version = "2.4.0"
version = "2.5.0"
description = "A safe rust wrapper for libuv"
homepage = "https://github.com/bmatcuk/libuv-rs"
repository = "https://github.com/bmatcuk/libuv-rs"
Expand All @@ -20,7 +20,7 @@ maintenance = { status = "actively-developed" }

[dependencies]
bitflags = "~1.2.1"
libuv-sys2 = "~1.43.0"
libuv-sys2 = "~1.44.2"

[dev-dependencies]
rand = "~0.7.3"
Expand Down
12 changes: 12 additions & 0 deletions src/handles/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,21 @@ extern "C" fn uv_exit_cb(
bitflags! {
/// Flags specifying how a stdio should be transmitted to the child process.
pub struct StdioFlags: u32 {
/// No file descriptor will be provided (or redirected to `/dev/null` if it is fd 0, 1 or
/// 2).
const IGNORE = uv::uv_stdio_flags_UV_IGNORE as _;

/// Open a new pipe into `data.stream`, per the flags below. The `data.stream` field must
/// point to a PipeHandle object that has been initialized with `new`, but not yet opened
/// or connected.
const CREATE_PIPE = uv::uv_stdio_flags_UV_CREATE_PIPE as _;

/// The child process will be given a duplicate of the parent's file descriptor given by
/// `data.fd`.
const INHERIT_FD = uv::uv_stdio_flags_UV_INHERIT_FD as _;

/// The child process will be given a duplicate of the parent's file descriptor being used
/// by the stream handle given by `data.stream`.
const INHERIT_STREAM = uv::uv_stdio_flags_UV_INHERIT_STREAM as _;

/// When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE determine the
Expand Down
3 changes: 2 additions & 1 deletion src/misc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ pub fn resident_set_memory() -> crate::Result<usize> {
crate::uvret(unsafe { uv_resident_set_memory(&mut rss as _) }).map(|_| rss as _)
}

/// Gets the current system uptime.
/// Gets the current system uptime. Depending on the system full or fractional seconds are
/// returned.
pub fn uptime() -> crate::Result<f64> {
let mut uptime = 0f64;
crate::uvret(unsafe { uv_uptime(&mut uptime as _) }).map(|_| uptime)
Expand Down
19 changes: 17 additions & 2 deletions src/misc/os.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{FromInner, IntoInner};
use std::ffi::CStr;
use uv::{
uv_os_free_passwd, uv_os_get_passwd, uv_os_gethostname, uv_os_getpid, uv_os_getppid,
uv_os_getpriority, uv_os_setpriority, uv_os_uname, uv_passwd_t, uv_utsname_t,
uv_available_parallelism, uv_os_free_passwd, uv_os_get_passwd, uv_os_gethostname, uv_os_getpid,
uv_os_getppid, uv_os_getpriority, uv_os_setpriority, uv_os_uname, uv_passwd_t, uv_utsname_t,
UV_MAXHOSTNAMESIZE,
};

Expand Down Expand Up @@ -122,6 +122,21 @@ pub fn getppid() -> Pid {
unsafe { uv_os_getppid() as _ }
}

/// Returns an estimate of the default amount of parallelism a program should use. Always returns a
/// non-zero value.
///
/// On Linux, inspects the calling thread’s CPU affinity mask to determine if it has been pinned to
/// specific CPUs.
///
/// On Windows, the available parallelism may be underreported on systems with more than 64 logical
/// CPUs.
///
/// On other platforms, reports the number of CPUs that the operating system considers to be
/// online.
pub fn available_parallelism() -> u32 {
unsafe { uv_available_parallelism() as _ }
}

/// Retrieves the scheduling priority of the process specified by pid. The returned value of
/// priority is between -20 (high priority) and 19 (low priority).
///
Expand Down

0 comments on commit df60c99

Please sign in to comment.