Skip to content

Commit

Permalink
Fixing compilation issues for ARM targets
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Feb 28, 2020
1 parent 3f34039 commit d93084f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
17 changes: 15 additions & 2 deletions heim-host/src/os/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ use std::net::IpAddr;

use crate::Pid;

/// User session ID.
#[cfg(not(target_arch = "aarch64"))]
pub type SessionId = i32;

/// User session ID.
#[cfg(target_arch = "aarch64")]
pub type SessionId = i64;

/// Linux-specific extensions for [User].
///
/// In Linux user information is provided by `utmpx` (see `man utmpx(5)`),
Expand All @@ -27,7 +35,12 @@ pub trait UserExt {
fn address(&self) -> Option<IpAddr>;

/// Returns the Session ID.
fn session_id(&self) -> i32;
///
/// ## Compatibility
///
/// Note that session id type is not portable
/// and varies depending on target architecture.
fn session_id(&self) -> SessionId;
}

#[cfg(target_os = "linux")]
Expand All @@ -52,7 +65,7 @@ impl UserExt for crate::User {
self.as_ref().address()
}

fn session_id(&self) -> i32 {
fn session_id(&self) -> SessionId {
self.as_ref().session_id()
}
}
5 changes: 3 additions & 2 deletions heim-host/src/sys/linux/users/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::net::IpAddr;
use heim_common::prelude::*;
use heim_common::Pid;

use crate::os::linux::SessionId;
use crate::sys::unix::{from_ut_addr_v6, get_users};

#[derive(Debug)]
Expand All @@ -14,7 +15,7 @@ pub struct User {
hostname: String,
pid: libc::pid_t,
addr: Option<IpAddr>,
session_id: i32,
session_id: SessionId,
}

impl User {
Expand Down Expand Up @@ -42,7 +43,7 @@ impl User {
self.addr
}

pub fn session_id(&self) -> i32 {
pub fn session_id(&self) -> SessionId {
self.session_id
}
}
Expand Down
4 changes: 3 additions & 1 deletion heim-virt/src/sys/linux/device_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ where
target_arch = "powerpc64"
))]
pub async fn detect_vm_device_tree() -> Result<Virtualization, ()> {
hypervisor(HYPERVISOR_COMPAT_PATH).or_else(|_| device_tree(DEVICE_TREE_ROOT))
hypervisor(HYPERVISOR_COMPAT_PATH)
.or_else(|_| device_tree(DEVICE_TREE_ROOT))
.await
}

#[cfg(not(any(
Expand Down

0 comments on commit d93084f

Please sign in to comment.