Skip to content

Commit c204605

Browse files
authored
Add more hurd support (#1066)
Now tested with all features.
1 parent 3346526 commit c204605

File tree

15 files changed

+98
-22
lines changed

15 files changed

+98
-22
lines changed

src/backend/libc/conv.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ pub(crate) fn msg_iov_len(len: usize) -> c::c_int {
226226
target_os = "emscripten",
227227
target_os = "fuchsia",
228228
target_os = "haiku",
229+
target_os = "hurd",
229230
target_os = "nto",
230231
))]
231232
#[inline]
@@ -244,6 +245,7 @@ pub(crate) fn msg_control_len(len: usize) -> c::socklen_t {
244245
target_os = "espidf",
245246
target_os = "fuchsia",
246247
target_os = "haiku",
248+
target_os = "hurd",
247249
target_os = "nto",
248250
target_os = "redox",
249251
target_os = "vita",

src/backend/libc/fs/syscalls.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ use {
8080
crate::backend::conv::nonnegative_ret,
8181
crate::fs::{copyfile_state_t, CloneFlags, CopyfileFlags},
8282
};
83-
#[cfg(any(apple, linux_kernel))]
83+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
8484
use {crate::fs::XattrFlags, core::mem::size_of, core::ptr::null_mut};
8585
#[cfg(linux_kernel)]
8686
use {
@@ -2239,7 +2239,7 @@ struct Attrlist {
22392239
forkattr: Attrgroup,
22402240
}
22412241

2242-
#[cfg(any(apple, linux_kernel))]
2242+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
22432243
pub(crate) fn getxattr(path: &CStr, name: &CStr, value: &mut [u8]) -> io::Result<usize> {
22442244
let value_ptr = value.as_mut_ptr();
22452245

@@ -2275,7 +2275,7 @@ pub(crate) fn getxattr(path: &CStr, name: &CStr, value: &mut [u8]) -> io::Result
22752275
}
22762276
}
22772277

2278-
#[cfg(any(apple, linux_kernel))]
2278+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
22792279
pub(crate) fn lgetxattr(path: &CStr, name: &CStr, value: &mut [u8]) -> io::Result<usize> {
22802280
let value_ptr = value.as_mut_ptr();
22812281

@@ -2312,7 +2312,7 @@ pub(crate) fn lgetxattr(path: &CStr, name: &CStr, value: &mut [u8]) -> io::Resul
23122312
}
23132313
}
23142314

2315-
#[cfg(any(apple, linux_kernel))]
2315+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
23162316
pub(crate) fn fgetxattr(fd: BorrowedFd<'_>, name: &CStr, value: &mut [u8]) -> io::Result<usize> {
23172317
let value_ptr = value.as_mut_ptr();
23182318

@@ -2348,7 +2348,7 @@ pub(crate) fn fgetxattr(fd: BorrowedFd<'_>, name: &CStr, value: &mut [u8]) -> io
23482348
}
23492349
}
23502350

2351-
#[cfg(any(apple, linux_kernel))]
2351+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
23522352
pub(crate) fn setxattr(
23532353
path: &CStr,
23542354
name: &CStr,
@@ -2379,7 +2379,7 @@ pub(crate) fn setxattr(
23792379
}
23802380
}
23812381

2382-
#[cfg(any(apple, linux_kernel))]
2382+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
23832383
pub(crate) fn lsetxattr(
23842384
path: &CStr,
23852385
name: &CStr,
@@ -2410,7 +2410,7 @@ pub(crate) fn lsetxattr(
24102410
}
24112411
}
24122412

2413-
#[cfg(any(apple, linux_kernel))]
2413+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
24142414
pub(crate) fn fsetxattr(
24152415
fd: BorrowedFd<'_>,
24162416
name: &CStr,
@@ -2441,7 +2441,7 @@ pub(crate) fn fsetxattr(
24412441
}
24422442
}
24432443

2444-
#[cfg(any(apple, linux_kernel))]
2444+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
24452445
pub(crate) fn listxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usize> {
24462446
#[cfg(not(apple))]
24472447
unsafe {
@@ -2459,7 +2459,7 @@ pub(crate) fn listxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usize
24592459
}
24602460
}
24612461

2462-
#[cfg(any(apple, linux_kernel))]
2462+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
24632463
pub(crate) fn llistxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usize> {
24642464
#[cfg(not(apple))]
24652465
unsafe {
@@ -2477,7 +2477,7 @@ pub(crate) fn llistxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usiz
24772477
}
24782478
}
24792479

2480-
#[cfg(any(apple, linux_kernel))]
2480+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
24812481
pub(crate) fn flistxattr(fd: BorrowedFd<'_>, list: &mut [c::c_char]) -> io::Result<usize> {
24822482
let fd = borrowed_fd(fd);
24832483

@@ -2492,7 +2492,7 @@ pub(crate) fn flistxattr(fd: BorrowedFd<'_>, list: &mut [c::c_char]) -> io::Resu
24922492
}
24932493
}
24942494

2495-
#[cfg(any(apple, linux_kernel))]
2495+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
24962496
pub(crate) fn removexattr(path: &CStr, name: &CStr) -> io::Result<()> {
24972497
#[cfg(not(apple))]
24982498
unsafe {
@@ -2505,7 +2505,7 @@ pub(crate) fn removexattr(path: &CStr, name: &CStr) -> io::Result<()> {
25052505
}
25062506
}
25072507

2508-
#[cfg(any(apple, linux_kernel))]
2508+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
25092509
pub(crate) fn lremovexattr(path: &CStr, name: &CStr) -> io::Result<()> {
25102510
#[cfg(not(apple))]
25112511
unsafe {
@@ -2522,7 +2522,7 @@ pub(crate) fn lremovexattr(path: &CStr, name: &CStr) -> io::Result<()> {
25222522
}
25232523
}
25242524

2525-
#[cfg(any(apple, linux_kernel))]
2525+
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
25262526
pub(crate) fn fremovexattr(fd: BorrowedFd<'_>, name: &CStr) -> io::Result<()> {
25272527
let fd = borrowed_fd(fd);
25282528

src/backend/libc/mm/types.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ bitflags! {
8585
target_os = "emscripten",
8686
target_os = "fuchsia",
8787
target_os = "haiku",
88+
target_os = "hurd",
8889
target_os = "nto",
8990
target_os = "redox",
9091
)))]
@@ -97,6 +98,7 @@ bitflags! {
9798
solarish,
9899
target_os = "aix",
99100
target_os = "haiku",
101+
target_os = "hurd",
100102
target_os = "nto",
101103
target_os = "redox",
102104
)))]
@@ -112,6 +114,7 @@ bitflags! {
112114
target_os = "emscripten",
113115
target_os = "fuchsia",
114116
target_os = "haiku",
117+
target_os = "hurd",
115118
target_os = "nto",
116119
target_os = "redox",
117120
)))]
@@ -122,6 +125,7 @@ bitflags! {
122125
solarish,
123126
target_os = "aix",
124127
target_os = "haiku",
128+
target_os = "hurd",
125129
target_os = "nto",
126130
target_os = "redox",
127131
)))]
@@ -132,6 +136,7 @@ bitflags! {
132136
solarish,
133137
target_os = "aix",
134138
target_os = "haiku",
139+
target_os = "hurd",
135140
target_os = "nto",
136141
target_os = "redox",
137142
)))]
@@ -145,6 +150,7 @@ bitflags! {
145150
target_os = "emscripten",
146151
target_os = "fuchsia",
147152
target_os = "haiku",
153+
target_os = "hurd",
148154
target_os = "nto",
149155
target_os = "redox",
150156
)))]
@@ -158,6 +164,7 @@ bitflags! {
158164
target_os = "emscripten",
159165
target_os = "fuchsia",
160166
target_os = "haiku",
167+
target_os = "hurd",
161168
target_os = "nto",
162169
target_os = "redox",
163170
)))]
@@ -168,6 +175,7 @@ bitflags! {
168175
solarish,
169176
target_os = "aix",
170177
target_os = "haiku",
178+
target_os = "hurd",
171179
target_os = "nto",
172180
target_os = "redox",
173181
)))]
@@ -179,6 +187,7 @@ bitflags! {
179187
#[cfg(not(any(
180188
freebsdlike,
181189
target_os = "aix",
190+
target_os = "hurd",
182191
target_os = "nto",
183192
target_os = "redox",
184193
)))]
@@ -192,6 +201,7 @@ bitflags! {
192201
solarish,
193202
target_os = "aix",
194203
target_os = "haiku",
204+
target_os = "hurd",
195205
target_os = "nto",
196206
target_os = "redox",
197207
)))]
@@ -203,6 +213,7 @@ bitflags! {
203213
target_os = "aix",
204214
target_os = "dragonfly",
205215
target_os = "haiku",
216+
target_os = "hurd",
206217
target_os = "netbsd",
207218
target_os = "redox",
208219
)))]
@@ -219,6 +230,7 @@ bitflags! {
219230
target_os = "emscripten",
220231
target_os = "fuchsia",
221232
target_os = "haiku",
233+
target_os = "hurd",
222234
target_os = "nto",
223235
target_os = "redox",
224236
all(
@@ -334,7 +346,12 @@ pub enum Advice {
334346
WillNeed = bitcast!(c::MADV_WILLNEED),
335347

336348
/// `POSIX_MADV_DONTNEED`
337-
#[cfg(not(any(target_os = "android", target_os = "emscripten", target_os = "haiku")))]
349+
#[cfg(not(any(
350+
target_os = "android",
351+
target_os = "emscripten",
352+
target_os = "haiku",
353+
target_os = "hurd",
354+
)))]
338355
DontNeed = bitcast!(c::POSIX_MADV_DONTNEED),
339356

340357
/// `POSIX_MADV_DONTNEED`

src/backend/libc/net/addr.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ impl SocketAddrUnix {
7676

7777
fn init() -> c::sockaddr_un {
7878
c::sockaddr_un {
79-
#[cfg(any(bsd, target_os = "aix", target_os = "haiku", target_os = "nto"))]
79+
#[cfg(any(
80+
bsd,
81+
target_os = "aix",
82+
target_os = "haiku",
83+
target_os = "nto",
84+
target_os = "hurd",
85+
))]
8086
sun_len: 0,
8187
#[cfg(target_os = "vita")]
8288
ss_len: 0,
@@ -210,7 +216,13 @@ pub type SocketAddrStorage = c::sockaddr_storage;
210216
#[inline]
211217
pub(crate) fn offsetof_sun_path() -> usize {
212218
let z = c::sockaddr_un {
213-
#[cfg(any(bsd, target_os = "aix", target_os = "haiku", target_os = "nto"))]
219+
#[cfg(any(
220+
bsd,
221+
target_os = "aix",
222+
target_os = "haiku",
223+
target_os = "hurd",
224+
target_os = "nto",
225+
))]
214226
sun_len: 0_u8,
215227
#[cfg(target_os = "vita")]
216228
ss_len: 0,
@@ -219,6 +231,7 @@ pub(crate) fn offsetof_sun_path() -> usize {
219231
target_os = "aix",
220232
target_os = "espidf",
221233
target_os = "haiku",
234+
target_os = "hurd",
222235
target_os = "nto",
223236
target_os = "vita"
224237
))]
@@ -228,6 +241,7 @@ pub(crate) fn offsetof_sun_path() -> usize {
228241
target_os = "aix",
229242
target_os = "espidf",
230243
target_os = "haiku",
244+
target_os = "hurd",
231245
target_os = "nto",
232246
target_os = "vita"
233247
)))]

src/backend/libc/net/ext.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub(crate) const fn sockaddr_in6_new(
8383
target_os = "aix",
8484
target_os = "espidf",
8585
target_os = "haiku",
86+
target_os = "hurd",
8687
target_os = "nto",
8788
target_os = "vita"
8889
))]
@@ -99,6 +100,7 @@ pub(crate) const fn sockaddr_in6_new(
99100
target_os = "aix",
100101
target_os = "espidf",
101102
target_os = "haiku",
103+
target_os = "hurd",
102104
target_os = "nto",
103105
target_os = "vita"
104106
))]

src/backend/libc/net/read_sockaddr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 {
5959
target_os = "aix",
6060
target_os = "espidf",
6161
target_os = "haiku",
62+
target_os = "hurd",
6263
target_os = "nto",
6364
target_os = "vita"
6465
))]
@@ -68,6 +69,7 @@ unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 {
6869
target_os = "aix",
6970
target_os = "espidf",
7071
target_os = "haiku",
72+
target_os = "hurd",
7173
target_os = "nto",
7274
target_os = "vita"
7375
))]
@@ -77,6 +79,7 @@ unsafe fn read_ss_family(storage: *const c::sockaddr_storage) -> u16 {
7779
target_os = "aix",
7880
target_os = "espidf",
7981
target_os = "haiku",
82+
target_os = "hurd",
8083
target_os = "nto",
8184
target_os = "vita"
8285
)))]

src/backend/libc/net/send_recv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ bitflags! {
1919
target_os = "espidf",
2020
target_os = "nto",
2121
target_os = "haiku",
22+
target_os = "hurd",
2223
target_os = "vita",
2324
)))]
2425
const CONFIRM = bitcast!(c::MSG_CONFIRM);
@@ -41,6 +42,7 @@ bitflags! {
4142
windows,
4243
target_os = "aix",
4344
target_os = "haiku",
45+
target_os = "hurd",
4446
target_os = "nto",
4547
target_os = "vita",
4648
)))]
@@ -88,6 +90,7 @@ bitflags! {
8890
target_os = "aix",
8991
target_os = "espidf",
9092
target_os = "haiku",
93+
target_os = "hurd",
9194
target_os = "nto",
9295
target_os = "vita",
9396
)))]

src/backend/libc/net/sockopt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ pub(crate) fn get_socket_send_buffer_size(fd: BorrowedFd<'_>) -> io::Result<usiz
369369
target_os = "emscripten",
370370
target_os = "espidf",
371371
target_os = "haiku",
372+
target_os = "hurd",
372373
target_os = "netbsd",
373374
target_os = "nto",
374375
target_os = "vita",

src/backend/libc/net/write_sockaddr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub(crate) fn encode_sockaddr_v4(v4: &SocketAddrV4) -> c::sockaddr_in {
3232
target_os = "aix",
3333
target_os = "espidf",
3434
target_os = "haiku",
35+
target_os = "hurd",
3536
target_os = "nto",
3637
target_os = "vita",
3738
))]
@@ -62,6 +63,7 @@ pub(crate) fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
6263
target_os = "aix",
6364
target_os = "espidf",
6465
target_os = "haiku",
66+
target_os = "hurd",
6567
target_os = "nto",
6668
target_os = "vita"
6769
))]
@@ -80,6 +82,7 @@ pub(crate) fn encode_sockaddr_v6(v6: &SocketAddrV6) -> c::sockaddr_in6 {
8082
target_os = "aix",
8183
target_os = "espidf",
8284
target_os = "haiku",
85+
target_os = "hurd",
8386
target_os = "nto",
8487
target_os = "vita"
8588
)))]

src/backend/libc/pipe/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ bitflags! {
1818
solarish,
1919
target_os = "espidf",
2020
target_os = "haiku",
21+
target_os = "hurd",
2122
target_os = "nto",
2223
target_os = "openbsd",
2324
target_os = "redox",

0 commit comments

Comments
 (0)