Skip to content

Commit 84821a0

Browse files
committed
Add support for QNX Neutrino 7.1
1 parent 590ab4d commit 84821a0

File tree

17 files changed

+542
-104
lines changed

17 files changed

+542
-104
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919

2020
// cfg aliases we would like to use
2121
apple_targets: { any(ios, macos, watchos, tvos, visionos) },
22-
bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets) },
22+
bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets, nto_qnx) },
2323
bsd_without_apple: { any(freebsd, dragonfly, netbsd, openbsd) },
2424
linux_android: { any(android, linux) },
2525
freebsdlike: { any(dragonfly, freebsd) },

src/dir.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ impl Entry {
228228
target_os = "emscripten",
229229
target_os = "fuchsia",
230230
target_os = "haiku",
231+
target_os = "nto",
231232
target_os = "hurd",
232233
solarish,
233234
linux_android,
@@ -250,7 +251,12 @@ impl Entry {
250251
/// notably, some Linux filesystems don't implement this. The caller should use `stat` or
251252
/// `fstat` if this returns `None`.
252253
pub fn file_type(&self) -> Option<Type> {
253-
#[cfg(not(any(solarish, target_os = "aix", target_os = "haiku")))]
254+
#[cfg(not(any(
255+
solarish,
256+
target_os = "aix",
257+
target_os = "haiku",
258+
target_os = "nto",
259+
)))]
254260
match self.0.d_type {
255261
libc::DT_FIFO => Some(Type::Fifo),
256262
libc::DT_CHR => Some(Type::CharacterDevice),
@@ -263,7 +269,12 @@ impl Entry {
263269
}
264270

265271
// illumos, Solaris, and Haiku systems do not have the d_type member at all:
266-
#[cfg(any(solarish, target_os = "aix", target_os = "haiku"))]
272+
#[cfg(any(
273+
solarish,
274+
target_os = "aix",
275+
target_os = "haiku",
276+
target_os = "nto",
277+
))]
267278
None
268279
}
269280
}

src/errno.rs

Lines changed: 248 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ cfg_if! {
4848
unsafe fn errno_location() -> *mut c_int {
4949
unsafe { libc::_Errno() }
5050
}
51+
} else if #[cfg(target_os = "nto")] {
52+
unsafe fn errno_location() -> *mut c_int {
53+
unsafe { libc::__get_errno_ptr() }
54+
}
5155
}
5256
}
5357

@@ -603,10 +607,20 @@ fn desc(errno: Errno) -> &'static str {
603607
#[cfg(freebsdlike)]
604608
EDOOFUS => "Programming error",
605609

606-
#[cfg(any(freebsdlike, target_os = "hurd", target_os = "redox"))]
610+
#[cfg(any(
611+
freebsdlike,
612+
target_os = "hurd",
613+
target_os = "redox",
614+
target_os = "nto",
615+
))]
607616
EMULTIHOP => "Multihop attempted",
608617

609-
#[cfg(any(freebsdlike, target_os = "hurd", target_os = "redox"))]
618+
#[cfg(any(
619+
freebsdlike,
620+
target_os = "hurd",
621+
target_os = "redox",
622+
target_os = "nto",
623+
))]
610624
ENOLINK => "Link has been severed",
611625

612626
#[cfg(target_os = "freebsd")]
@@ -615,7 +629,7 @@ fn desc(errno: Errno) -> &'static str {
615629
#[cfg(target_os = "freebsd")]
616630
ECAPMODE => "Not permitted in capability mode",
617631

618-
#[cfg(any(bsd, target_os = "hurd"))]
632+
#[cfg(all(not(target_os = "nto"), any(bsd, target_os = "hurd")))]
619633
ENEEDAUTH => "Need authenticator",
620634

621635
#[cfg(any(bsd, target_os = "redox", solarish))]
@@ -627,17 +641,19 @@ fn desc(errno: Errno) -> &'static str {
627641
target_os = "netbsd",
628642
target_os = "redox",
629643
target_os = "haiku",
644+
target_os = "nto",
630645
target_os = "hurd"
631646
))]
632647
EILSEQ => "Illegal byte sequence",
633648

634-
#[cfg(any(bsd, target_os = "haiku"))]
649+
#[cfg(all(not(target_os = "nto"), any(bsd, target_os = "haiku")))]
635650
ENOATTR => "Attribute not found",
636651

637652
#[cfg(any(
638653
bsd,
639654
target_os = "redox",
640655
target_os = "haiku",
656+
target_os = "nto",
641657
target_os = "hurd"
642658
))]
643659
EBADMSG => "Bad message",
@@ -670,7 +686,10 @@ fn desc(errno: Errno) -> &'static str {
670686
))]
671687
ENOTSUP => "Operation not supported",
672688

673-
#[cfg(any(bsd, target_os = "aix", target_os = "hurd"))]
689+
#[cfg(all(
690+
not(target_os = "nto"),
691+
any(bsd, target_os = "aix", target_os = "hurd")
692+
))]
674693
EPROCLIM => "Too many processes",
675694

676695
#[cfg(any(
@@ -718,10 +737,10 @@ fn desc(errno: Errno) -> &'static str {
718737
#[cfg(any(bsd, target_os = "hurd"))]
719738
EPROCUNAVAIL => "Bad procedure for program",
720739

721-
#[cfg(any(bsd, target_os = "hurd"))]
740+
#[cfg(all(not(target_os = "nto"), any(bsd, target_os = "hurd")))]
722741
EFTYPE => "Inappropriate file type or format",
723742

724-
#[cfg(any(bsd, target_os = "hurd"))]
743+
#[cfg(all(not(target_os = "nto"), any(bsd, target_os = "hurd")))]
725744
EAUTH => "Authentication error",
726745

727746
#[cfg(any(
@@ -757,7 +776,8 @@ fn desc(errno: Errno) -> &'static str {
757776
apple_targets,
758777
target_os = "aix",
759778
target_os = "netbsd",
760-
target_os = "redox"
779+
target_os = "redox",
780+
target_os = "nto",
761781
))]
762782
ENODATA => "No message available on STREAM",
763783

@@ -768,23 +788,26 @@ fn desc(errno: Errno) -> &'static str {
768788
apple_targets,
769789
target_os = "aix",
770790
target_os = "netbsd",
771-
target_os = "redox"
791+
target_os = "redox",
792+
target_os = "nto",
772793
))]
773794
ENOSR => "No STREAM resources",
774795

775796
#[cfg(any(
776797
apple_targets,
777798
target_os = "aix",
778799
target_os = "netbsd",
779-
target_os = "redox"
800+
target_os = "redox",
801+
target_os = "nto",
780802
))]
781803
ENOSTR => "Not a STREAM",
782804

783805
#[cfg(any(
784806
apple_targets,
785807
target_os = "aix",
786808
target_os = "netbsd",
787-
target_os = "redox"
809+
target_os = "redox",
810+
target_os = "nto",
788811
))]
789812
ETIME => "STREAM ioctl timeout",
790813

@@ -797,7 +820,11 @@ fn desc(errno: Errno) -> &'static str {
797820
#[cfg(apple_targets)]
798821
EQFULL => "Interface output queue is full",
799822

800-
#[cfg(any(target_os = "openbsd", target_os = "hurd"))]
823+
#[cfg(any(
824+
target_os = "openbsd",
825+
target_os = "hurd",
826+
target_os = "nto",
827+
))]
801828
EOPNOTSUPP => "Operation not supported",
802829

803830
#[cfg(target_os = "openbsd")]
@@ -3334,3 +3361,212 @@ mod consts {
33343361
}
33353362
}
33363363
}
3364+
3365+
#[cfg(target_os = "nto")]
3366+
mod consts {
3367+
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
3368+
#[repr(i32)]
3369+
#[non_exhaustive]
3370+
pub enum Errno {
3371+
UnknownErrno = 0,
3372+
EPERM = libc::EPERM,
3373+
ENOENT = libc::ENOENT,
3374+
ESRCH = libc::ESRCH,
3375+
EINTR = libc::EINTR,
3376+
EIO = libc::EIO,
3377+
ENXIO = libc::ENXIO,
3378+
E2BIG = libc::E2BIG,
3379+
ENOEXEC = libc::ENOEXEC,
3380+
EBADF = libc::EBADF,
3381+
ECHILD = libc::ECHILD,
3382+
EDEADLK = libc::EDEADLK,
3383+
ENOMEM = libc::ENOMEM,
3384+
EACCES = libc::EACCES,
3385+
EFAULT = libc::EFAULT,
3386+
ENOTBLK = libc::ENOTBLK,
3387+
EBUSY = libc::EBUSY,
3388+
EEXIST = libc::EEXIST,
3389+
EXDEV = libc::EXDEV,
3390+
ENODEV = libc::ENODEV,
3391+
ENOTDIR = libc::ENOTDIR,
3392+
EISDIR = libc::EISDIR,
3393+
EINVAL = libc::EINVAL,
3394+
ENFILE = libc::ENFILE,
3395+
EMFILE = libc::EMFILE,
3396+
ENOTTY = libc::ENOTTY,
3397+
ETXTBSY = libc::ETXTBSY,
3398+
EFBIG = libc::EFBIG,
3399+
ENOSPC = libc::ENOSPC,
3400+
ESPIPE = libc::ESPIPE,
3401+
EROFS = libc::EROFS,
3402+
EMLINK = libc::EMLINK,
3403+
EPIPE = libc::EPIPE,
3404+
EDOM = libc::EDOM,
3405+
ERANGE = libc::ERANGE,
3406+
EAGAIN = libc::EAGAIN,
3407+
EINPROGRESS = libc::EINPROGRESS,
3408+
EALREADY = libc::EALREADY,
3409+
ENOTSOCK = libc::ENOTSOCK,
3410+
EDESTADDRREQ = libc::EDESTADDRREQ,
3411+
EMSGSIZE = libc::EMSGSIZE,
3412+
EPROTOTYPE = libc::EPROTOTYPE,
3413+
ENOPROTOOPT = libc::ENOPROTOOPT,
3414+
EPROTONOSUPPORT = libc::EPROTONOSUPPORT,
3415+
ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT,
3416+
EOPNOTSUPP = libc::EOPNOTSUPP,
3417+
EPFNOSUPPORT = libc::EPFNOSUPPORT,
3418+
EAFNOSUPPORT = libc::EAFNOSUPPORT,
3419+
EADDRINUSE = libc::EADDRINUSE,
3420+
EADDRNOTAVAIL = libc::EADDRNOTAVAIL,
3421+
ENETDOWN = libc::ENETDOWN,
3422+
ENETUNREACH = libc::ENETUNREACH,
3423+
ENETRESET = libc::ENETRESET,
3424+
ECONNABORTED = libc::ECONNABORTED,
3425+
ECONNRESET = libc::ECONNRESET,
3426+
ENOBUFS = libc::ENOBUFS,
3427+
EISCONN = libc::EISCONN,
3428+
ENOTCONN = libc::ENOTCONN,
3429+
ESHUTDOWN = libc::ESHUTDOWN,
3430+
ETOOMANYREFS = libc::ETOOMANYREFS,
3431+
ETIMEDOUT = libc::ETIMEDOUT,
3432+
ECONNREFUSED = libc::ECONNREFUSED,
3433+
ELOOP = libc::ELOOP,
3434+
ENAMETOOLONG = libc::ENAMETOOLONG,
3435+
EHOSTDOWN = libc::EHOSTDOWN,
3436+
EHOSTUNREACH = libc::EHOSTUNREACH,
3437+
ENOTEMPTY = libc::ENOTEMPTY,
3438+
EUSERS = libc::EUSERS,
3439+
EDQUOT = libc::EDQUOT,
3440+
ESTALE = libc::ESTALE,
3441+
EREMOTE = libc::EREMOTE,
3442+
EBADRPC = libc::EBADRPC,
3443+
ERPCMISMATCH = libc::ERPCMISMATCH,
3444+
EPROGUNAVAIL = libc::EPROGUNAVAIL,
3445+
EPROGMISMATCH = libc::EPROGMISMATCH,
3446+
EPROCUNAVAIL = libc::EPROCUNAVAIL,
3447+
ENOLCK = libc::ENOLCK,
3448+
ENOSYS = libc::ENOSYS,
3449+
EIDRM = libc::EIDRM,
3450+
ENOMSG = libc::ENOMSG,
3451+
EOVERFLOW = libc::EOVERFLOW,
3452+
EILSEQ = libc::EILSEQ,
3453+
ENOTSUP = libc::ENOTSUP,
3454+
ECANCELED = libc::ECANCELED,
3455+
EBADMSG = libc::EBADMSG,
3456+
ENODATA = libc::ENODATA,
3457+
ENOSR = libc::ENOSR,
3458+
ENOSTR = libc::ENOSTR,
3459+
ETIME = libc::ETIME,
3460+
EMULTIHOP = libc::EMULTIHOP,
3461+
ENOLINK = libc::ENOLINK,
3462+
EPROTO = libc::EPROTO,
3463+
}
3464+
3465+
impl Errno {
3466+
pub const ELAST: Errno = Errno::ENOTSUP;
3467+
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
3468+
}
3469+
3470+
#[deprecated(
3471+
since = "0.28.0",
3472+
note = "please use `Errno::from_raw()` instead"
3473+
)]
3474+
pub const fn from_i32(e: i32) -> Errno {
3475+
use self::Errno::*;
3476+
3477+
match e {
3478+
libc::EPERM => EPERM,
3479+
libc::ENOENT => ENOENT,
3480+
libc::ESRCH => ESRCH,
3481+
libc::EINTR => EINTR,
3482+
libc::EIO => EIO,
3483+
libc::ENXIO => ENXIO,
3484+
libc::E2BIG => E2BIG,
3485+
libc::ENOEXEC => ENOEXEC,
3486+
libc::EBADF => EBADF,
3487+
libc::ECHILD => ECHILD,
3488+
libc::EDEADLK => EDEADLK,
3489+
libc::ENOMEM => ENOMEM,
3490+
libc::EACCES => EACCES,
3491+
libc::EFAULT => EFAULT,
3492+
libc::ENOTBLK => ENOTBLK,
3493+
libc::EBUSY => EBUSY,
3494+
libc::EEXIST => EEXIST,
3495+
libc::EXDEV => EXDEV,
3496+
libc::ENODEV => ENODEV,
3497+
libc::ENOTDIR => ENOTDIR,
3498+
libc::EISDIR => EISDIR,
3499+
libc::EINVAL => EINVAL,
3500+
libc::ENFILE => ENFILE,
3501+
libc::EMFILE => EMFILE,
3502+
libc::ENOTTY => ENOTTY,
3503+
libc::ETXTBSY => ETXTBSY,
3504+
libc::EFBIG => EFBIG,
3505+
libc::ENOSPC => ENOSPC,
3506+
libc::ESPIPE => ESPIPE,
3507+
libc::EROFS => EROFS,
3508+
libc::EMLINK => EMLINK,
3509+
libc::EPIPE => EPIPE,
3510+
libc::EDOM => EDOM,
3511+
libc::ERANGE => ERANGE,
3512+
libc::EAGAIN => EAGAIN,
3513+
libc::EINPROGRESS => EINPROGRESS,
3514+
libc::EALREADY => EALREADY,
3515+
libc::ENOTSOCK => ENOTSOCK,
3516+
libc::EDESTADDRREQ => EDESTADDRREQ,
3517+
libc::EMSGSIZE => EMSGSIZE,
3518+
libc::EPROTOTYPE => EPROTOTYPE,
3519+
libc::ENOPROTOOPT => ENOPROTOOPT,
3520+
libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
3521+
libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
3522+
libc::EOPNOTSUPP => EOPNOTSUPP,
3523+
libc::EPFNOSUPPORT => EPFNOSUPPORT,
3524+
libc::EAFNOSUPPORT => EAFNOSUPPORT,
3525+
libc::EADDRINUSE => EADDRINUSE,
3526+
libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
3527+
libc::ENETDOWN => ENETDOWN,
3528+
libc::ENETUNREACH => ENETUNREACH,
3529+
libc::ENETRESET => ENETRESET,
3530+
libc::ECONNABORTED => ECONNABORTED,
3531+
libc::ECONNRESET => ECONNRESET,
3532+
libc::ENOBUFS => ENOBUFS,
3533+
libc::EISCONN => EISCONN,
3534+
libc::ENOTCONN => ENOTCONN,
3535+
libc::ESHUTDOWN => ESHUTDOWN,
3536+
libc::ETOOMANYREFS => ETOOMANYREFS,
3537+
libc::ETIMEDOUT => ETIMEDOUT,
3538+
libc::ECONNREFUSED => ECONNREFUSED,
3539+
libc::ELOOP => ELOOP,
3540+
libc::ENAMETOOLONG => ENAMETOOLONG,
3541+
libc::EHOSTDOWN => EHOSTDOWN,
3542+
libc::EHOSTUNREACH => EHOSTUNREACH,
3543+
libc::ENOTEMPTY => ENOTEMPTY,
3544+
libc::EUSERS => EUSERS,
3545+
libc::EDQUOT => EDQUOT,
3546+
libc::ESTALE => ESTALE,
3547+
libc::EREMOTE => EREMOTE,
3548+
libc::EBADRPC => EBADRPC,
3549+
libc::ERPCMISMATCH => ERPCMISMATCH,
3550+
libc::EPROGUNAVAIL => EPROGUNAVAIL,
3551+
libc::EPROGMISMATCH => EPROGMISMATCH,
3552+
libc::EPROCUNAVAIL => EPROCUNAVAIL,
3553+
libc::ENOLCK => ENOLCK,
3554+
libc::ENOSYS => ENOSYS,
3555+
libc::EIDRM => EIDRM,
3556+
libc::ENOMSG => ENOMSG,
3557+
libc::EOVERFLOW => EOVERFLOW,
3558+
libc::EILSEQ => EILSEQ,
3559+
libc::ENOTSUP => ENOTSUP,
3560+
libc::ECANCELED => ECANCELED,
3561+
libc::EBADMSG => EBADMSG,
3562+
libc::ENODATA => ENODATA,
3563+
libc::ENOSR => ENOSR,
3564+
libc::ENOSTR => ENOSTR,
3565+
libc::ETIME => ETIME,
3566+
libc::EMULTIHOP => EMULTIHOP,
3567+
libc::ENOLINK => ENOLINK,
3568+
libc::EPROTO => EPROTO,
3569+
_ => UnknownErrno,
3570+
}
3571+
}
3572+
}

0 commit comments

Comments
 (0)