Skip to content

Commit d69e2ed

Browse files
committed
uclibc support
1 parent c3731f1 commit d69e2ed

File tree

16 files changed

+75
-27
lines changed

16 files changed

+75
-27
lines changed

.cirrus.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ task:
280280
- name: OpenBSD x86_64
281281
env:
282282
TARGET: x86_64-unknown-openbsd
283+
- name: Linux armv7 uclibceabihf
284+
env:
285+
TARGET: armv7-unknown-linux-uclibceabihf
283286
setup_script:
284287
- rustup component add rust-src
285288
<< : *BUILD

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ targets = [
2727
]
2828

2929
[dependencies]
30-
libc = { git = "https://github.com/rust-lang/libc", rev = "e470e3b6a1f940e0024d40d3b79fc73fe29c7f17", features = [ "extra_traits" ] }
30+
libc = { version = "0.2.113", features = [ "extra_traits" ] }
3131
bitflags = "1.1"
3232
cfg-if = "1.0"
3333

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Tier 2:
7878
* x86_64-unknown-netbsd
7979

8080
Tier 3:
81+
* armv7-unknown-linux-uclibceabihf
8182
* x86_64-fuchsia
8283
* x86_64-unknown-dragonfly
8384
* x86_64-unknown-linux-gnux32

bors.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ status = [
1414
"Linux arm gnueabi",
1515
"Linux arm-musleabi",
1616
"Linux armv7 gnueabihf",
17+
"Linux armv7 uclibceabihf",
1718
"Linux i686 musl",
1819
"Linux i686",
1920
"Linux mipsel",

src/sys/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#[cfg(any(target_os = "dragonfly",
33
target_os = "freebsd",
44
target_os = "ios",
5-
target_os = "linux",
5+
all(target_os = "linux", not(target_env = "uclibc")),
66
target_os = "macos",
77
target_os = "netbsd"))]
88
feature! {

src/sys/personality.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ libc_bitflags! {
1111
ADDR_NO_RANDOMIZE;
1212
ADDR_LIMIT_32BIT;
1313
ADDR_LIMIT_3GB;
14-
#[cfg(not(target_env = "musl"))]
14+
#[cfg(not(any(target_env = "musl", target_env = "uclibc")))]
1515
FDPIC_FUNCPTRS;
1616
MMAP_PAGE_ZERO;
1717
READ_IMPLIES_EXEC;
1818
SHORT_INODE;
1919
STICKY_TIMEOUTS;
20-
#[cfg(not(target_env = "musl"))]
20+
#[cfg(not(any(target_env = "musl", target_env = "uclibc")))]
2121
UNAME26;
2222
WHOLE_SECONDS;
2323
}

src/sys/ptrace/linux.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use libc::user_regs_struct;
2020

2121
cfg_if! {
2222
if #[cfg(any(all(target_os = "linux", target_arch = "s390x"),
23-
all(target_os = "linux", target_env = "gnu")))] {
23+
all(target_os = "linux", target_env = "gnu"),
24+
target_env = "uclibc"))] {
2425
#[doc(hidden)]
2526
pub type RequestType = ::libc::c_uint;
2627
} else {
@@ -30,8 +31,8 @@ cfg_if! {
3031
}
3132

3233
libc_enum!{
33-
#[cfg_attr(not(any(target_env = "musl", target_os = "android")), repr(u32))]
34-
#[cfg_attr(any(target_env = "musl", target_os = "android"), repr(i32))]
34+
#[cfg_attr(not(any(target_env = "musl", target_env = "uclibc", target_os = "android")), repr(u32))]
35+
#[cfg_attr(any(target_env = "musl", target_env = "uclibc", target_os = "android"), repr(i32))]
3536
/// Ptrace Request enum defining the action to be taken.
3637
#[non_exhaustive]
3738
pub enum Request {

src/sys/resource.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ pub use libc::rlim_t;
77
use std::mem;
88

99
cfg_if! {
10-
if #[cfg(all(target_os = "linux", target_env = "gnu"))]{
10+
if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{
1111
use libc::{__rlimit_resource_t, rlimit, RLIM_INFINITY};
12-
}else if #[cfg(any(
12+
} else if #[cfg(any(
1313
target_os = "freebsd",
1414
target_os = "openbsd",
1515
target_os = "netbsd",
@@ -199,9 +199,9 @@ pub fn getrlimit(resource: Resource) -> Result<(Option<rlim_t>, Option<rlim_t>)>
199199
let mut old_rlim = mem::MaybeUninit::<rlimit>::uninit();
200200

201201
cfg_if! {
202-
if #[cfg(all(target_os = "linux", target_env = "gnu"))]{
202+
if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{
203203
let res = unsafe { libc::getrlimit(resource as __rlimit_resource_t, old_rlim.as_mut_ptr()) };
204-
}else{
204+
} else {
205205
let res = unsafe { libc::getrlimit(resource as c_int, old_rlim.as_mut_ptr()) };
206206
}
207207
}
@@ -253,7 +253,7 @@ pub fn setrlimit(
253253
rlim_max: hard_limit.unwrap_or(RLIM_INFINITY),
254254
};
255255
cfg_if! {
256-
if #[cfg(all(target_os = "linux", target_env = "gnu"))]{
256+
if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")))]{
257257
let res = unsafe { libc::setrlimit(resource as __rlimit_resource_t, &new_rlim as *const rlimit) };
258258
}else{
259259
let res = unsafe { libc::setrlimit(resource as c_int, &new_rlim as *const rlimit) };

src/sys/signal.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::str::FromStr;
1111
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
1212
use std::os::unix::io::RawFd;
1313
use std::ptr;
14+
use cfg_if::cfg_if;
1415

1516
#[cfg(not(any(target_os = "openbsd", target_os = "redox")))]
1617
#[cfg(any(feature = "aio", feature = "signal"))]
@@ -420,10 +421,15 @@ pub const SIGPOLL : Signal = SIGIO;
420421
/// Alias for [`SIGSYS`]
421422
pub const SIGUNUSED : Signal = SIGSYS;
422423

423-
#[cfg(not(target_os = "redox"))]
424-
type SaFlags_t = libc::c_int;
425-
#[cfg(target_os = "redox")]
426-
type SaFlags_t = libc::c_ulong;
424+
cfg_if! {
425+
if #[cfg(target_os = "redox")] {
426+
type SaFlags_t = libc::c_ulong;
427+
} else if #[cfg(target_env = "uclibc")] {
428+
type SaFlags_t = libc::c_ulong;
429+
} else {
430+
type SaFlags_t = libc::c_int;
431+
}
432+
}
427433
}
428434

429435
#[cfg(feature = "signal")]
@@ -1046,6 +1052,8 @@ mod sigevent {
10461052
SigevNotify::SigevThreadId{..} => libc::SIGEV_THREAD_ID,
10471053
#[cfg(all(target_os = "linux", target_env = "gnu", not(target_arch = "mips")))]
10481054
SigevNotify::SigevThreadId{..} => libc::SIGEV_THREAD_ID,
1055+
#[cfg(all(target_os = "linux", target_env = "uclibc"))]
1056+
SigevNotify::SigevThreadId{..} => libc::SIGEV_THREAD_ID,
10491057
#[cfg(any(all(target_os = "linux", target_env = "musl"), target_arch = "mips"))]
10501058
SigevNotify::SigevThreadId{..} => 4 // No SIGEV_THREAD_ID defined
10511059
};

src/sys/socket/addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ pub enum AddressFamily {
120120
#[cfg(any(target_os = "android", target_os = "linux"))]
121121
#[cfg_attr(docsrs, doc(cfg(all())))]
122122
Llc = libc::AF_LLC,
123-
#[cfg(target_os = "linux")]
123+
#[cfg(all(target_os = "linux", not(target_env = "uclibc")))]
124124
#[cfg_attr(docsrs, doc(cfg(all())))]
125125
Ib = libc::AF_IB,
126-
#[cfg(target_os = "linux")]
126+
#[cfg(all(target_os = "linux", not(target_env = "uclibc")))]
127127
#[cfg_attr(docsrs, doc(cfg(all())))]
128128
Mpls = libc::AF_MPLS,
129129
#[cfg(any(target_os = "android", target_os = "linux"))]

0 commit comments

Comments
 (0)