Skip to content

Commit 0a10015

Browse files
authored
Fix compilation on Android. (#1514)
Make `MountFlags::NOSYMFOLLOW`, `InputModes::IUCLC`, `LocalModes::XCASE`, and `PointerAuthenticationKeys` conditional on `linux_raw_dep`, so that they don't break compiling on Android with the linux_raw_sys dependency disabled. Fixes #1513.
1 parent 0f3b6ca commit 0a10015

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

src/backend/libc/c.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) const ETH_P_XDSA: c_int = linux_raw_sys::if_ether::ETH_P_XDSA as _;
6363
pub(crate) const ETH_P_MAP: c_int = linux_raw_sys::if_ether::ETH_P_MAP as _;
6464
#[cfg(all(linux_raw_dep, feature = "net"))]
6565
pub(crate) const ETH_P_MCTP: c_int = linux_raw_sys::if_ether::ETH_P_MCTP as _;
66-
#[cfg(all(linux_kernel, feature = "mount"))]
66+
#[cfg(all(linux_raw_dep, feature = "mount"))]
6767
pub(crate) const MS_NOSYMFOLLOW: c_ulong = linux_raw_sys::general::MS_NOSYMFOLLOW as _;
6868

6969
#[cfg(all(
@@ -80,9 +80,9 @@ pub(crate) const MS_NOSYMFOLLOW: c_ulong = linux_raw_sys::general::MS_NOSYMFOLLO
8080
pub(crate) const SIGEMT: c_int = linux_raw_sys::general::SIGEMT as _;
8181

8282
// TODO: Upstream these.
83-
#[cfg(all(linux_kernel, feature = "termios"))]
83+
#[cfg(all(linux_raw_dep, feature = "termios"))]
8484
pub(crate) const IUCLC: tcflag_t = linux_raw_sys::general::IUCLC as _;
85-
#[cfg(all(linux_kernel, feature = "termios"))]
85+
#[cfg(all(linux_raw_dep, feature = "termios"))]
8686
pub(crate) const XCASE: tcflag_t = linux_raw_sys::general::XCASE as _;
8787

8888
#[cfg(target_os = "aix")]

src/backend/libc/mount/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ bitflags! {
5757
const SYNCHRONOUS = c::MS_SYNCHRONOUS;
5858

5959
/// `MS_NOSYMFOLLOW`
60+
#[cfg(linux_raw_dep)]
6061
const NOSYMFOLLOW = c::MS_NOSYMFOLLOW;
6162

6263
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>

src/prctl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use bitflags::bitflags;
1010
use core::mem::MaybeUninit;
1111
use core::ptr::null_mut;
1212

13+
#[cfg(linux_raw_dep)]
1314
bitflags! {
1415
/// `PR_PAC_AP*`
1516
#[repr(transparent)]

src/process/prctl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ const PR_PAC_GET_ENABLED_KEYS: c_int = 61;
10831083
/// [`prctl(PR_PAC_GET_ENABLED_KEYS,…)`]: https://www.kernel.org/doc/html/v6.13/arch/arm64/pointer-authentication.html
10841084
#[inline]
10851085
#[doc(alias = "PR_PAC_GET_ENABLED_KEYS")]
1086+
#[cfg(linux_raw_dep)]
10861087
pub fn enabled_pointer_authentication_keys() -> io::Result<PointerAuthenticationKeys> {
10871088
let r = unsafe { prctl_1arg(PR_PAC_GET_ENABLED_KEYS)? } as c_uint;
10881089
PointerAuthenticationKeys::from_bits(r).ok_or(io::Errno::RANGE)
@@ -1103,6 +1104,7 @@ const PR_PAC_SET_ENABLED_KEYS: c_int = 60;
11031104
/// [`prctl(PR_PAC_SET_ENABLED_KEYS,…)`]: https://www.kernel.org/doc/html/v6.13/arch/arm64/pointer-authentication.html
11041105
#[inline]
11051106
#[doc(alias = "PR_PAC_SET_ENABLED_KEYS")]
1107+
#[cfg(linux_raw_dep)]
11061108
pub unsafe fn configure_pointer_authentication_keys<
11071109
Config: Iterator<Item = (PointerAuthenticationKeys, bool)>,
11081110
>(

src/termios/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ bitflags! {
275275
const ICRNL = c::ICRNL;
276276

277277
/// `IUCLC`
278-
#[cfg(any(linux_kernel, solarish, target_os = "aix", target_os = "haiku", target_os = "nto"))]
278+
#[cfg(any(linux_raw_dep, solarish, target_os = "aix", target_os = "haiku", target_os = "nto"))]
279279
const IUCLC = c::IUCLC;
280280

281281
/// `IXON`
@@ -597,7 +597,7 @@ bitflags! {
597597
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
598598
pub struct LocalModes: types::tcflag_t {
599599
/// `XCASE`
600-
#[cfg(any(linux_kernel, target_arch = "s390x", target_os = "haiku"))]
600+
#[cfg(any(linux_raw_dep, target_arch = "s390x", target_os = "haiku"))]
601601
const XCASE = c::XCASE;
602602

603603
/// `ECHOCTL`

src/thread/prctl.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ use crate::ffi::{c_int, c_uint, c_void, CStr};
2323
use crate::io;
2424
use crate::io::Errno;
2525
use crate::pid::Pid;
26-
use crate::prctl::{
27-
prctl_1arg, prctl_2args, prctl_3args, prctl_get_at_arg2_optional, PointerAuthenticationKeys,
28-
};
26+
#[cfg(linux_raw_dep)]
27+
use crate::prctl::PointerAuthenticationKeys;
28+
use crate::prctl::{prctl_1arg, prctl_2args, prctl_3args, prctl_get_at_arg2_optional};
2929
use crate::utils::as_ptr;
3030

3131
use super::CapabilitySet;
@@ -851,6 +851,7 @@ const PR_PAC_RESET_KEYS: c_int = 54;
851851
///
852852
/// [`prctl(PR_PAC_RESET_KEYS,…)`]: https://man7.org/linux/man-pages/man2/prctl.2.html
853853
#[inline]
854+
#[cfg(linux_raw_dep)]
854855
pub unsafe fn reset_pointer_authentication_keys(
855856
keys: Option<PointerAuthenticationKeys>,
856857
) -> io::Result<()> {

0 commit comments

Comments
 (0)