Skip to content

RawOpcode is defined incorrectly on Linux uclibc #827

@spritetong

Description

@spritetong

0.38.13 can not be compiled on Linux uclibc.

In src/ioctl/mod.rs, _RawOpcode is defined as c::c_int.

// On libc Linux with GNU libc, this is an unsigned long.
#[cfg(all(not(linux_raw), target_os = "linux", target_env = "gnu"))]
type _RawOpcode = c::c_ulong;

// Musl uses a c_int
#[cfg(all(not(linux_raw), target_os = "linux", not(target_env = "gnu")))]
type _RawOpcode = c::c_int;

But in the crate libc, Ioctl is ::c_ulong (src/unix/linux_like/linux/uclibc/mod.rs)

cfg_if! {
    if #[cfg(doc)] {
        // Used in `linux::arch` to define ioctl constants.
        pub(crate) type Ioctl = ::c_ulong;
    } else {
        #[doc(hidden)]
        pub type Ioctl = ::c_ulong;
    }
}

I have created a patch to address this issue, for your reference.

 src/ioctl/mod.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/ioctl/mod.rs b/src/ioctl/mod.rs
index 61a08b8e..e870b7eb 100644
--- a/src/ioctl/mod.rs
+++ b/src/ioctl/mod.rs
@@ -293,12 +293,12 @@ pub type RawOpcode = _RawOpcode;
 #[cfg(linux_raw)]
 type _RawOpcode = c::c_uint;
 
-// On libc Linux with GNU libc, this is an unsigned long.
-#[cfg(all(not(linux_raw), target_os = "linux", target_env = "gnu"))]
+// On libc Linux with GNU libc or uclibc, this is an unsigned long.
+#[cfg(all(not(linux_raw), target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]
 type _RawOpcode = c::c_ulong;
 
 // Musl uses a c_int
-#[cfg(all(not(linux_raw), target_os = "linux", not(target_env = "gnu")))]
+#[cfg(all(not(linux_raw), target_os = "linux", not(target_env = "gnu"), not(target_env = "uclibc")))]
 type _RawOpcode = c::c_int;
 
 // Android uses c_int

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions