Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
id: create_artifacts
if: always()
run: python3 ci/create-artifacts.py
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v6
if: always() && steps.create_artifacts.outcome == 'success'
with:
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }}
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
id: create_artifacts
if: always()
run: ./ci/create-artifacts.py
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v6
if: always() && steps.create_artifacts.outcome == 'success'
with:
name: ${{ env.ARCHIVE_NAME }}-${{ matrix.target }}${{ matrix.artifact-tag && format('-{0}', matrix.artifact-tag) }}
Expand All @@ -272,7 +272,7 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: test on Solaris
uses: vmactions/solaris-vm@v1.1.8
uses: vmactions/solaris-vm@v1.2.3
if: contains(matrix.target, 'solaris')
with:
release: "11.4-gcc"
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[
(
"target_os",
&[
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin",
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "qurt",
],
),
(
Expand Down
24 changes: 24 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4947,6 +4947,30 @@ fn test_linux(target: &str) {
_ => false,
});

if gnu {
// old constants, so tests fail if glibc is too new
cfg.skip_const(|s| {
[
"B50", "B75", "B110", "B134", "B150", "B200", "B300", "B600", "B1200", "B1800",
"B2400", "B4800", "B9600", "B19200", "B38400", "EXTA", "EXTB", "B57600", "B115200",
"B230400", "B460800", "B500000", "B576000", "B921600", "B1000000", "B1152000",
"B1500000", "B2000000", "B2500000", "B3000000", "B3500000", "B4000000",
]
.contains(&s.ident())
});
// old symbols, so tests fail if glibc is too new
cfg.skip_fn_ptrcheck(|s| {
[
"cfgetispeed",
"cfgetospeed",
"cfsetispeed",
"cfsetospeed",
"cfsetspeed",
]
.contains(&s)
});
}

ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap();

if !l4re {
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,7 @@ pthread_spin_lock
pthread_spin_trylock
pthread_spin_unlock
pthread_spinlock_t
pthread_timedjoin_np
ptrace
ptrace_io_desc
ptrace_lwpinfo
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ pthread_attr_setaffinity_np
pthread_rwlockattr_getkind_np
pthread_rwlockattr_getpshared
pthread_rwlockattr_setkind_np
pthread_timedjoin_np
pthread_tryjoin_np
ptrace_peeksiginfo_args
ptrace_sud_config
ptrace_syscall_info
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ prlimit
prlimit64
process_vm_readv
process_vm_writev
pthread_timedjoin_np
pututxline
pwritev2
pwritev64
Expand Down
33 changes: 33 additions & 0 deletions libc-test/tests/linux_gnu_baud.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#[cfg(all(target_os = "linux", target_env = "gnu"))]
#[test]
fn baud() {
use libc::*;
let controller_fd = unsafe { posix_openpt(O_RDWR | O_NOCTTY) };
assert!(controller_fd >= 0);
unsafe {
grantpt(controller_fd);
unlockpt(controller_fd);
}
let mut buffer = [0; 256];
let ret = unsafe { ptsname_r(controller_fd, buffer.as_mut_ptr(), 256) };
assert!(ret >= 0);
let terminal_fd = unsafe { open(buffer.as_ptr(), O_RDWR | O_NOCTTY) };
assert!(terminal_fd >= 0);
let mut tio: termios = unsafe { std::mem::zeroed() };
let ret = unsafe { tcgetattr(terminal_fd, &mut tio) };
assert!(ret >= 0);
assert_eq!(unsafe { cfgetispeed(&tio) }, B38400);
assert_eq!(unsafe { cfgetospeed(&tio) }, B38400);
let ret = unsafe { cfsetspeed(&mut tio, B1000000) };
assert!(ret >= 0);
assert_eq!(unsafe { cfgetispeed(&tio) }, B1000000);
assert_eq!(unsafe { cfgetospeed(&tio) }, B1000000);
let ret = unsafe { cfsetispeed(&mut tio, B9600) };
assert!(ret >= 0);
assert_eq!(unsafe { cfgetispeed(&tio) }, B9600);
assert!(matches!(unsafe { cfgetospeed(&tio) }, B9600 | B1000000));
let ret = unsafe { cfsetospeed(&mut tio, B19200) };
assert!(ret >= 0);
assert!(matches!(unsafe { cfgetispeed(&tio) }, B9600 | B19200));
assert_eq!(unsafe { cfgetospeed(&tio) }, B19200);
}
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ cfg_if! {
mod vxworks;
pub use crate::vxworks::*;

prelude!();
} else if #[cfg(target_os = "qurt")] {
mod primitives;
pub use crate::primitives::*;

mod qurt;
pub use crate::qurt::*;

prelude!();
} else if #[cfg(target_os = "solid_asp3")] {
mod primitives;
Expand Down
1 change: 1 addition & 0 deletions src/new/common/posix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
target_os = "emscripten",
target_os = "l4re",
target_os = "linux",
target_os = "qurt",
target_vendor = "apple",
))]
pub(crate) mod pthread;
Expand Down
5 changes: 4 additions & 1 deletion src/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ cfg_if! {
} else if #[cfg(target_os = "openbsd")] {
mod openbsd;
pub(crate) use openbsd::*;
} else if #[cfg(target_os = "qurt")] {
mod qurt;
pub(crate) use qurt::*;
} else if #[cfg(target_os = "redox")] {
mod redox;
// pub(crate) use redox::*;
Expand Down Expand Up @@ -210,7 +213,7 @@ cfg_if! {

// Per-family headers we export
cfg_if! {
if #[cfg(target_family = "unix")] {
if #[cfg(all(target_family = "unix", not(target_os = "qurt")))] {
// FIXME(pthread): eventually all platforms should use this module
#[cfg(any(
target_os = "android",
Expand Down
1 change: 1 addition & 0 deletions src/new/netbsd/net/if_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit
pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast

s! {
#[repr(C, align(8))]
pub struct if_msghdr {
pub ifm_msglen: c_ushort,
pub ifm_version: c_uchar,
Expand Down
154 changes: 154 additions & 0 deletions src/new/qurt/errno.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
//! Header: `errno.h`

use super::*;
use crate::prelude::*;

// Standard error codes - verified to match QuRT SDK
pub const EPERM: c_int = 1;
pub const ENOENT: c_int = 2;
pub const ESRCH: c_int = 3;
pub const EINTR: c_int = 4;
pub const EIO: c_int = 5;
pub const ENXIO: c_int = 6;
pub const E2BIG: c_int = 7;
pub const ENOEXEC: c_int = 8;
pub const EBADF: c_int = 9;
pub const ECHILD: c_int = 10;
pub const EAGAIN: c_int = 11;
pub const ENOMEM: c_int = 12;
pub const EACCES: c_int = 13;
pub const EFAULT: c_int = 14;
pub const ENOTBLK: c_int = 15;
pub const EBUSY: c_int = 16;
pub const EEXIST: c_int = 17;
pub const EXDEV: c_int = 18;
pub const ENODEV: c_int = 19;
pub const ENOTDIR: c_int = 20;
pub const EISDIR: c_int = 21;
pub const EINVAL: c_int = 22;
pub const ENFILE: c_int = 23;
pub const EMFILE: c_int = 24;
pub const ENOTTY: c_int = 25;
pub const ETXTBSY: c_int = 26;
pub const EFBIG: c_int = 27;
pub const ENOSPC: c_int = 28;
pub const ESPIPE: c_int = 29;
pub const EROFS: c_int = 30;
pub const EMLINK: c_int = 31;
pub const EPIPE: c_int = 32;
pub const EDOM: c_int = 33;
pub const ERANGE: c_int = 34;
pub const EDEADLK: c_int = 35;
pub const ENAMETOOLONG: c_int = 36;
pub const ENOLCK: c_int = 37;
pub const ENOSYS: c_int = 38;
pub const ENOTEMPTY: c_int = 39;
pub const ELOOP: c_int = 40;
pub const EWOULDBLOCK: c_int = EAGAIN;
pub const ENOMSG: c_int = 42;
pub const EIDRM: c_int = 43;
pub const ECHRNG: c_int = 44;
pub const EL2NSYNC: c_int = 45;
pub const EL3HLT: c_int = 46;
pub const EL3RST: c_int = 47;
pub const ELNRNG: c_int = 48;
pub const EUNATCH: c_int = 49;
pub const ENOCSI: c_int = 50;
pub const EL2HLT: c_int = 51;
pub const EBADE: c_int = 52;
pub const EBADR: c_int = 53;
pub const EXFULL: c_int = 54;
pub const ENOANO: c_int = 55;
pub const EBADRQC: c_int = 56;
pub const EBADSLT: c_int = 57;
pub const EDEADLOCK: c_int = EDEADLK;
pub const EBFONT: c_int = 59;
pub const ENOSTR: c_int = 60;
pub const ENODATA: c_int = 61;
pub const ETIME: c_int = 62;
pub const ENOSR: c_int = 63;
pub const ENONET: c_int = 64;
pub const ENOPKG: c_int = 65;
pub const EREMOTE: c_int = 66;
pub const ENOLINK: c_int = 67;
pub const EADV: c_int = 68;
pub const ESRMNT: c_int = 69;
pub const ECOMM: c_int = 70;
pub const EPROTO: c_int = 71;
pub const EMULTIHOP: c_int = 72;
pub const EDOTDOT: c_int = 73;
pub const EBADMSG: c_int = 74;
pub const EOVERFLOW: c_int = 75;
pub const ENOTUNIQ: c_int = 76;
pub const EBADFD: c_int = 77;
pub const EREMCHG: c_int = 78;
pub const ELIBACC: c_int = 79;
pub const ELIBBAD: c_int = 80;
pub const ELIBSCN: c_int = 81;
pub const ELIBMAX: c_int = 82;
pub const ELIBEXEC: c_int = 83;
pub const EILSEQ: c_int = 84;
pub const ERESTART: c_int = 85;
pub const ESTRPIPE: c_int = 86;
pub const EUSERS: c_int = 87;
pub const ENOTSOCK: c_int = 88;
pub const EDESTADDRREQ: c_int = 89;
pub const EMSGSIZE: c_int = 90;
pub const EPROTOTYPE: c_int = 91;
pub const ENOPROTOOPT: c_int = 92;
pub const EPROTONOSUPPORT: c_int = 93;
pub const ESOCKTNOSUPPORT: c_int = 94;
pub const EOPNOTSUPP: c_int = 95;
pub const ENOTSUP: c_int = EOPNOTSUPP;
pub const EPFNOSUPPORT: c_int = 96;
pub const EAFNOSUPPORT: c_int = 97;
pub const EADDRINUSE: c_int = 98;
pub const EADDRNOTAVAIL: c_int = 99;
pub const ENETDOWN: c_int = 100;
pub const ENETUNREACH: c_int = 101;
pub const ENETRESET: c_int = 102;
pub const ECONNABORTED: c_int = 103;
pub const ECONNRESET: c_int = 104;
pub const ENOBUFS: c_int = 105;
pub const EISCONN: c_int = 106;
pub const ENOTCONN: c_int = 107;
pub const ESHUTDOWN: c_int = 108;
pub const ETOOMANYREFS: c_int = 109;
pub const ETIMEDOUT: c_int = 110;
pub const ECONNREFUSED: c_int = 111;
pub const EHOSTDOWN: c_int = 112;
pub const EHOSTUNREACH: c_int = 113;
pub const EALREADY: c_int = 114;
pub const EINPROGRESS: c_int = 115;
pub const ESTALE: c_int = 116;
pub const EUCLEAN: c_int = 117;
pub const ENOTNAM: c_int = 118;
pub const ENAVAIL: c_int = 119;
pub const EISNAM: c_int = 120;
pub const EREMOTEIO: c_int = 121;
pub const EDQUOT: c_int = 122;
pub const ENOMEDIUM: c_int = 123;
pub const EMEDIUMTYPE: c_int = 124;
pub const ECANCELED: c_int = 125;
pub const ENOKEY: c_int = 126;
pub const EKEYEXPIRED: c_int = 127;
pub const EKEYREVOKED: c_int = 128;
pub const EKEYREJECTED: c_int = 129;
pub const EOWNERDEAD: c_int = 130;
pub const ENOTRECOVERABLE: c_int = 131;
pub const ERFKILL: c_int = 132;
pub const EHWPOISON: c_int = 133;

extern "C" {
// Error number access
#[link_name = "__errno_location"]
pub fn __errno_location() -> *mut c_int;
}

pub unsafe fn errno() -> c_int {
*__errno_location()
}

pub unsafe fn set_errno(value: c_int) {
*__errno_location() = value;
}
49 changes: 49 additions & 0 deletions src/new/qurt/fcntl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! Header: `fcntl.h`

use super::*;
use crate::prelude::*;

// File access modes
pub const O_RDONLY: c_int = 0x0000;
pub const O_WRONLY: c_int = 0x0001;
pub const O_RDWR: c_int = 0x0002;
pub const O_ACCMODE: c_int = 0x0003;

// File creation flags
pub const O_CREAT: c_int = 0x0040;
pub const O_EXCL: c_int = 0x0080;
pub const O_NOCTTY: c_int = 0x0100;
pub const O_TRUNC: c_int = 0x0200;

// File status flags
pub const O_APPEND: c_int = 0x0400;
pub const O_NONBLOCK: c_int = 0x0800;
pub const O_SYNC: c_int = 0x1000;
pub const O_FSYNC: c_int = O_SYNC;
pub const O_DSYNC: c_int = 0x1000;

// fcntl() commands
pub const F_DUPFD: c_int = 0;
pub const F_GETFD: c_int = 1;
pub const F_SETFD: c_int = 2;
pub const F_GETFL: c_int = 3;
pub const F_SETFL: c_int = 4;
pub const F_GETLK: c_int = 5;
pub const F_SETLK: c_int = 6;
pub const F_SETLKW: c_int = 7;

// File descriptor flags
pub const FD_CLOEXEC: c_int = 1;

// Lock types for fcntl()
pub const F_RDLCK: c_int = 0;
pub const F_WRLCK: c_int = 1;
pub const F_UNLCK: c_int = 2;

// Functions
extern "C" {
pub fn open(pathname: *const c_char, flags: c_int, ...) -> c_int;
pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
pub fn creat(pathname: *const c_char, mode: mode_t) -> c_int;
pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int;
}
Loading