Skip to content

Commit 55333e4

Browse files
author
Al Hoang
committed
add haiku support
* enabled as much functionality and defines that match updated libc definitions for haiku
1 parent db41e0b commit 55333e4

31 files changed

+425
-125
lines changed

.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ task:
288288
- name: OpenBSD x86_64
289289
env:
290290
TARGET: x86_64-unknown-openbsd
291+
- name: Haiku x86_64
292+
env:
293+
TARGET: x86_64-unknown-haiku
291294
setup_script:
292295
- rustup component add rust-src
293296
<< : *BUILD

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
99
- impl From<SockaddrIn> for std::net::SocketAddrV4 and
1010
impl From<SockaddrIn6> for std::net::SocketAddrV6.
1111
(#[1711](https://github.com/nix-rust/nix/pull/1711))
12+
- Fixed compilation and updated support on Haiku
13+
- Added support for the `x86_64-unknown-haiku` target.
14+
(#[1703](https://github.com/nix-rust/nix/pull/1703))
1215

1316
### Changed
1417
### Fixed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ targets = [
2727
]
2828

2929
[dependencies]
30-
libc = { version = "0.2.121", features = [ "extra_traits" ] }
30+
libc = { version = "0.2.125", features = [ "extra_traits" ] }
3131
bitflags = "1.1"
3232
cfg-if = "1.0"
3333

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Tier 3:
8282
* armv7-unknown-linux-uclibceabihf
8383
* x86_64-fuchsia
8484
* x86_64-unknown-dragonfly
85+
* x86_64-unknown-haiku
8586
* x86_64-unknown-linux-gnux32
8687
* x86_64-unknown-openbsd
8788
* x86_64-unknown-redox

bors.toml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ status = [
3535
"iOS aarch64",
3636
"iOS x86_64",
3737
"Illumos",
38+
"Haiku x86_64",
3839
]
3940

4041
# Set bors's timeout to 1 hour

src/dir.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl Entry {
226226
/// notably, some Linux filesystems don't implement this. The caller should use `stat` or
227227
/// `fstat` if this returns `None`.
228228
pub fn file_type(&self) -> Option<Type> {
229-
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
229+
#[cfg(not(any(target_os = "illumos", target_os = "solaris", target_os = "haiku")))]
230230
match self.0.d_type {
231231
libc::DT_FIFO => Some(Type::Fifo),
232232
libc::DT_CHR => Some(Type::CharacterDevice),
@@ -238,8 +238,8 @@ impl Entry {
238238
/* libc::DT_UNKNOWN | */ _ => None,
239239
}
240240

241-
// illumos and Solaris systems do not have the d_type member at all:
242-
#[cfg(any(target_os = "illumos", target_os = "solaris"))]
241+
// illumos, Solaris, and Haiku systems do not have the d_type member at all:
242+
#[cfg(any(target_os = "illumos", target_os = "solaris", target_os = "haiku"))]
243243
None
244244
}
245245
}

src/errno.rs

+198-11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ cfg_if! {
3030
unsafe fn errno_location() -> *mut c_int {
3131
libc::___errno()
3232
}
33+
} else if #[cfg(any(target_os = "haiku",))] {
34+
unsafe fn errno_location() -> *mut c_int {
35+
libc::_errnop()
36+
}
3337
}
3438
}
3539

@@ -201,6 +205,7 @@ fn desc(errno: Errno) -> &'static str {
201205
ENOMEM => "Out of memory",
202206
EACCES => "Permission denied",
203207
EFAULT => "Bad address",
208+
#[cfg(not(target_os = "haiku"))]
204209
ENOTBLK => "Block device required",
205210
EBUSY => "Device or resource busy",
206211
EEXIST => "File exists",
@@ -237,8 +242,11 @@ fn desc(errno: Errno) -> &'static str {
237242
EPROTOTYPE => "Protocol wrong type for socket",
238243
ENOPROTOOPT => "Protocol not available",
239244
EPROTONOSUPPORT => "Protocol not supported",
245+
#[cfg(not(target_os = "haiku"))]
240246
ESOCKTNOSUPPORT => "Socket type not supported",
247+
#[cfg(not(target_os = "haiku"))]
241248
EPFNOSUPPORT => "Protocol family not supported",
249+
#[cfg(not(target_os = "haiku"))]
242250
EAFNOSUPPORT => "Address family not supported by protocol",
243251
EADDRINUSE => "Address already in use",
244252
EADDRNOTAVAIL => "Cannot assign requested address",
@@ -251,6 +259,7 @@ fn desc(errno: Errno) -> &'static str {
251259
EISCONN => "Transport endpoint is already connected",
252260
ENOTCONN => "Transport endpoint is not connected",
253261
ESHUTDOWN => "Cannot send after transport endpoint shutdown",
262+
#[cfg(not(target_os = "haiku"))]
254263
ETOOMANYREFS => "Too many references: cannot splice",
255264
ETIMEDOUT => "Connection timed out",
256265
ECONNREFUSED => "Connection refused",
@@ -409,7 +418,7 @@ fn desc(errno: Errno) -> &'static str {
409418
EBADMSG => "Trying to read unreadable message",
410419

411420
#[cfg(any(target_os = "linux", target_os = "android",
412-
target_os = "fuchsia"))]
421+
target_os = "fuchsia", target_os = "haiku"))]
413422
EOVERFLOW => "Value too large for defined data type",
414423

415424
#[cfg(any(target_os = "linux", target_os = "android",
@@ -516,7 +525,7 @@ fn desc(errno: Errno) -> &'static str {
516525

517526
#[cfg(any(target_os = "linux", target_os = "android",
518527
target_os = "illumos", target_os = "solaris",
519-
target_os = "fuchsia"))]
528+
target_os = "fuchsia", target_os = "haiku"))]
520529
ECANCELED => "Operation canceled",
521530

522531
#[cfg(any(target_os = "linux", target_os = "android",
@@ -587,24 +596,26 @@ fn desc(errno: Errno) -> &'static str {
587596

588597
#[cfg(any(target_os = "macos", target_os = "freebsd",
589598
target_os = "dragonfly", target_os = "ios",
590-
target_os = "netbsd", target_os = "redox"))]
599+
target_os = "netbsd", target_os = "redox",
600+
target_os = "haiku"))]
591601
EILSEQ => "Illegal byte sequence",
592602

593603
#[cfg(any(target_os = "macos", target_os = "freebsd",
594604
target_os = "dragonfly", target_os = "ios",
595-
target_os = "openbsd", target_os = "netbsd"))]
605+
target_os = "openbsd", target_os = "netbsd",
606+
target_os = "haiku"))]
596607
ENOATTR => "Attribute not found",
597608

598609
#[cfg(any(target_os = "macos", target_os = "freebsd",
599610
target_os = "dragonfly", target_os = "ios",
600611
target_os = "openbsd", target_os = "netbsd",
601-
target_os = "redox"))]
612+
target_os = "redox", target_os = "haiku"))]
602613
EBADMSG => "Bad message",
603614

604615
#[cfg(any(target_os = "macos", target_os = "freebsd",
605616
target_os = "dragonfly", target_os = "ios",
606617
target_os = "openbsd", target_os = "netbsd",
607-
target_os = "redox"))]
618+
target_os = "redox", target_os = "haiku"))]
608619
EPROTO => "Protocol error",
609620

610621
#[cfg(any(target_os = "macos", target_os = "freebsd",
@@ -620,7 +631,8 @@ fn desc(errno: Errno) -> &'static str {
620631
#[cfg(any(target_os = "macos", target_os = "freebsd",
621632
target_os = "dragonfly", target_os = "ios",
622633
target_os = "openbsd", target_os = "netbsd",
623-
target_os = "illumos", target_os = "solaris"))]
634+
target_os = "illumos", target_os = "solaris",
635+
target_os = "haiku"))]
624636
ENOTSUP => "Operation not supported",
625637

626638
#[cfg(any(target_os = "macos", target_os = "freebsd",
@@ -638,14 +650,14 @@ fn desc(errno: Errno) -> &'static str {
638650
target_os = "dragonfly", target_os = "ios",
639651
target_os = "openbsd", target_os = "netbsd",
640652
target_os = "redox", target_os = "illumos",
641-
target_os = "solaris"))]
653+
target_os = "solaris", target_os = "haiku"))]
642654
EDQUOT => "Disc quota exceeded",
643655

644656
#[cfg(any(target_os = "macos", target_os = "freebsd",
645657
target_os = "dragonfly", target_os = "ios",
646658
target_os = "openbsd", target_os = "netbsd",
647659
target_os = "redox", target_os = "illumos",
648-
target_os = "solaris"))]
660+
target_os = "solaris", target_os = "haiku"))]
649661
ESTALE => "Stale NFS file handle",
650662

651663
#[cfg(any(target_os = "macos", target_os = "freebsd",
@@ -714,15 +726,15 @@ fn desc(errno: Errno) -> &'static str {
714726
EBADMACHO => "Malformed Macho file",
715727

716728
#[cfg(any(target_os = "macos", target_os = "ios",
717-
target_os = "netbsd"))]
729+
target_os = "netbsd", target_os = "haiku"))]
718730
EMULTIHOP => "Reserved",
719731

720732
#[cfg(any(target_os = "macos", target_os = "ios",
721733
target_os = "netbsd", target_os = "redox"))]
722734
ENODATA => "No message available on STREAM",
723735

724736
#[cfg(any(target_os = "macos", target_os = "ios",
725-
target_os = "netbsd"))]
737+
target_os = "netbsd", target_os = "haiku"))]
726738
ENOLINK => "Reserved",
727739

728740
#[cfg(any(target_os = "macos", target_os = "ios",
@@ -2725,3 +2737,178 @@ mod consts {
27252737
}
27262738
}
27272739
}
2740+
2741+
#[cfg(target_os = "haiku")]
2742+
mod consts {
2743+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2744+
#[repr(i32)]
2745+
#[non_exhaustive]
2746+
pub enum Errno {
2747+
UnknownErrno = 0,
2748+
EPERM = libc::EPERM,
2749+
ENOENT = libc::ENOENT,
2750+
ESRCH = libc::ESRCH,
2751+
EINTR = libc::EINTR,
2752+
EIO = libc::EIO,
2753+
ENXIO = libc::ENXIO,
2754+
E2BIG = libc::E2BIG,
2755+
ENOEXEC = libc::ENOEXEC,
2756+
EBADF = libc::EBADF,
2757+
ECHILD = libc::ECHILD,
2758+
EDEADLK = libc::EDEADLK,
2759+
ENOMEM = libc::ENOMEM,
2760+
EACCES = libc::EACCES,
2761+
EFAULT = libc::EFAULT,
2762+
EBUSY = libc::EBUSY,
2763+
EEXIST = libc::EEXIST,
2764+
EXDEV = libc::EXDEV,
2765+
ENODEV = libc::ENODEV,
2766+
ENOTDIR = libc::ENOTDIR,
2767+
EISDIR = libc::EISDIR,
2768+
EINVAL = libc::EINVAL,
2769+
ENFILE = libc::ENFILE,
2770+
EMFILE = libc::EMFILE,
2771+
ENOTTY = libc::ENOTTY,
2772+
ETXTBSY = libc::ETXTBSY,
2773+
EFBIG = libc::EFBIG,
2774+
ENOSPC = libc::ENOSPC,
2775+
ESPIPE = libc::ESPIPE,
2776+
EROFS = libc::EROFS,
2777+
EMLINK = libc::EMLINK,
2778+
EPIPE = libc::EPIPE,
2779+
EDOM = libc::EDOM,
2780+
ERANGE = libc::ERANGE,
2781+
EAGAIN = libc::EAGAIN,
2782+
EINPROGRESS = libc::EINPROGRESS,
2783+
EALREADY = libc::EALREADY,
2784+
ENOTSOCK = libc::ENOTSOCK,
2785+
EDESTADDRREQ = libc::EDESTADDRREQ,
2786+
EMSGSIZE = libc::EMSGSIZE,
2787+
EPROTOTYPE = libc::EPROTOTYPE,
2788+
ENOPROTOOPT = libc::ENOPROTOOPT,
2789+
EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
2790+
ENOTSUP = libc::ENOTSUP,
2791+
EADDRINUSE = libc::EADDRINUSE,
2792+
EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
2793+
ENETDOWN = libc::ENETDOWN,
2794+
ENETUNREACH = libc::ENETUNREACH,
2795+
ENETRESET = libc::ENETRESET,
2796+
ECONNABORTED = libc::ECONNABORTED,
2797+
ECONNRESET = libc::ECONNRESET,
2798+
ENOBUFS = libc::ENOBUFS,
2799+
EISCONN = libc::EISCONN,
2800+
ENOTCONN = libc::ENOTCONN,
2801+
ESHUTDOWN = libc::ESHUTDOWN,
2802+
ETIMEDOUT = libc::ETIMEDOUT,
2803+
ECONNREFUSED = libc::ECONNREFUSED,
2804+
ELOOP = libc::ELOOP,
2805+
ENAMETOOLONG = libc::ENAMETOOLONG,
2806+
EHOSTDOWN = libc::EHOSTDOWN,
2807+
EHOSTUNREACH = libc::EHOSTUNREACH,
2808+
ENOTEMPTY = libc::ENOTEMPTY,
2809+
EDQUOT = libc::EDQUOT,
2810+
ESTALE = libc::ESTALE,
2811+
ENOLCK = libc::ENOLCK,
2812+
ENOSYS = libc::ENOSYS,
2813+
EIDRM = libc::EIDRM,
2814+
ENOMSG = libc::ENOMSG,
2815+
EOVERFLOW = libc::EOVERFLOW,
2816+
ECANCELED = libc::ECANCELED,
2817+
EILSEQ = libc::EILSEQ,
2818+
ENOATTR = libc::ENOATTR,
2819+
EBADMSG = libc::EBADMSG,
2820+
EMULTIHOP = libc::EMULTIHOP,
2821+
ENOLINK = libc::ENOLINK,
2822+
EPROTO = libc::EPROTO,
2823+
}
2824+
2825+
impl Errno {
2826+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
2827+
pub const EDEADLOCK: Errno = Errno::EDEADLK;
2828+
pub const EOPNOTSUPP: Errno = Errno::ENOTSUP;
2829+
}
2830+
2831+
pub const fn from_i32(e: i32) -> Errno {
2832+
use self::Errno::*;
2833+
2834+
match e {
2835+
libc::EPERM => EPERM,
2836+
libc::ENOENT => ENOENT,
2837+
libc::ESRCH => ESRCH,
2838+
libc::EINTR => EINTR,
2839+
libc::EIO => EIO,
2840+
libc::ENXIO => ENXIO,
2841+
libc::E2BIG => E2BIG,
2842+
libc::ENOEXEC => ENOEXEC,
2843+
libc::EBADF => EBADF,
2844+
libc::ECHILD => ECHILD,
2845+
libc::EDEADLK => EDEADLK,
2846+
libc::ENOMEM => ENOMEM,
2847+
libc::EACCES => EACCES,
2848+
libc::EFAULT => EFAULT,
2849+
libc::EBUSY => EBUSY,
2850+
libc::EEXIST => EEXIST,
2851+
libc::EXDEV => EXDEV,
2852+
libc::ENODEV => ENODEV,
2853+
libc::ENOTDIR => ENOTDIR,
2854+
libc::EISDIR => EISDIR,
2855+
libc::EINVAL => EINVAL,
2856+
libc::ENFILE => ENFILE,
2857+
libc::EMFILE => EMFILE,
2858+
libc::ENOTTY => ENOTTY,
2859+
libc::ETXTBSY => ETXTBSY,
2860+
libc::EFBIG => EFBIG,
2861+
libc::ENOSPC => ENOSPC,
2862+
libc::ESPIPE => ESPIPE,
2863+
libc::EROFS => EROFS,
2864+
libc::EMLINK => EMLINK,
2865+
libc::EPIPE => EPIPE,
2866+
libc::EDOM => EDOM,
2867+
libc::ERANGE => ERANGE,
2868+
libc::EAGAIN => EAGAIN,
2869+
libc::EINPROGRESS => EINPROGRESS,
2870+
libc::EALREADY => EALREADY,
2871+
libc::ENOTSOCK => ENOTSOCK,
2872+
libc::EDESTADDRREQ => EDESTADDRREQ,
2873+
libc::EMSGSIZE => EMSGSIZE,
2874+
libc::EPROTOTYPE => EPROTOTYPE,
2875+
libc::ENOPROTOOPT => ENOPROTOOPT,
2876+
libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
2877+
libc::ENOTSUP => ENOTSUP,
2878+
libc::EADDRINUSE => EADDRINUSE,
2879+
libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
2880+
libc::ENETDOWN => ENETDOWN,
2881+
libc::ENETUNREACH => ENETUNREACH,
2882+
libc::ENETRESET => ENETRESET,
2883+
libc::ECONNABORTED => ECONNABORTED,
2884+
libc::ECONNRESET => ECONNRESET,
2885+
libc::ENOBUFS => ENOBUFS,
2886+
libc::EISCONN => EISCONN,
2887+
libc::ENOTCONN => ENOTCONN,
2888+
libc::ESHUTDOWN => ESHUTDOWN,
2889+
libc::ETIMEDOUT => ETIMEDOUT,
2890+
libc::ECONNREFUSED => ECONNREFUSED,
2891+
libc::ELOOP => ELOOP,
2892+
libc::ENAMETOOLONG => ENAMETOOLONG,
2893+
libc::EHOSTDOWN => EHOSTDOWN,
2894+
libc::EHOSTUNREACH => EHOSTUNREACH,
2895+
libc::ENOTEMPTY => ENOTEMPTY,
2896+
libc::EDQUOT => EDQUOT,
2897+
libc::ESTALE => ESTALE,
2898+
libc::ENOLCK => ENOLCK,
2899+
libc::ENOSYS => ENOSYS,
2900+
libc::EIDRM => EIDRM,
2901+
libc::ENOMSG => ENOMSG,
2902+
libc::EOVERFLOW => EOVERFLOW,
2903+
libc::ECANCELED => ECANCELED,
2904+
libc::EILSEQ => EILSEQ,
2905+
libc::ENOATTR => ENOATTR,
2906+
libc::EBADMSG => EBADMSG,
2907+
libc::EMULTIHOP => EMULTIHOP,
2908+
libc::ENOLINK => ENOLINK,
2909+
libc::EPROTO => EPROTO,
2910+
_ => UnknownErrno,
2911+
}
2912+
}
2913+
}
2914+

src/fcntl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ libc_bitflags!(
5858
/// Open the file in append-only mode.
5959
O_APPEND;
6060
/// Generate a signal when input or output becomes possible.
61-
#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
61+
#[cfg(not(any(target_os = "illumos", target_os = "solaris", target_os = "haiku")))]
6262
#[cfg_attr(docsrs, doc(cfg(all())))]
6363
O_ASYNC;
6464
/// Closes the file descriptor once an `execve` call is made.
@@ -128,7 +128,7 @@ libc_bitflags!(
128128
#[cfg_attr(docsrs, doc(cfg(all())))]
129129
O_NOCTTY;
130130
/// Same as `O_NONBLOCK`.
131-
#[cfg(not(target_os = "redox"))]
131+
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
132132
#[cfg_attr(docsrs, doc(cfg(all())))]
133133
O_NDELAY;
134134
/// `open()` will fail if the given path is a symbolic link.

0 commit comments

Comments
 (0)