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
2 changes: 1 addition & 1 deletion src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ s2! {
}

#[exhaustive] // FIXME(exhaustive): review for 1.0
#[cfg(not(target_os = "horizon"))]
#[cfg(not(any(target_os = "horizon", target_os = "nuttx")))]
pub struct pollfd {
pub fd: c_int,
pub events: c_short,
Expand Down
46 changes: 31 additions & 15 deletions src/unix/nuttx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub type suseconds_t = i32;
pub type tcflag_t = u32;
pub type clockid_t = c_int;
pub type time_t = i64;
pub type pollevent_t = u32;

cfg_if! {
if #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] {
Expand Down Expand Up @@ -274,6 +275,17 @@ s! {
pub imr_interface: in_addr,
pub imr_sourceaddr: in_addr,
}

pub struct pollfd {
pub fd: c_int,
pub events: pollevent_t,
pub revents: pollevent_t,

// Used internally by NuttX
pub arg: *const c_void,
pub cb: *const c_void,
pub r#priv: *const c_void,
}
}

// Reserved two pointer size for reserved area for some structures.
Expand All @@ -295,11 +307,11 @@ const __DEFAULT_RESERVED_SIZE__: usize = 2;

const __SOCKADDR_STORAGE_SIZE__: usize = 36;
const __PTHREAD_ATTR_SIZE__: usize = 5;
const __PTHREAD_MUTEX_SIZE__: usize = 9;
const __PTHREAD_COND_SIZE__: usize = 7;
const __PTHREAD_MUTEX_SIZE__: usize = 13; // Assumes CONFIG_LIBC_MUTEX_BACKTRACE=0
const __PTHREAD_COND_SIZE__: usize = 12;
const __PTHREAD_CONDATTR_SIZE__: usize = 5;
const __PTHREAD_RWLOCK_SIZE__: usize = 17;
const __SEM_SIZE__: usize = 6;
const __PTHREAD_RWLOCK_SIZE__: usize = 28;
const __SEM_SIZE__: usize = 10;
const __NAME_MAX__: usize = 64;
const __FDSET_SIZE__: usize = 10;
const __SIGSET_SIZE__: usize = 8;
Expand Down Expand Up @@ -518,17 +530,17 @@ pub const S_IWOTH: u32 = 0x002;
pub const S_IXOTH: u32 = 0x001;

// sys/poll.h
pub const POLLIN: i16 = 0x01;
pub const POLLRDNORM: i16 = 0x01;
pub const POLLRDBAND: i16 = 0x01;
pub const POLLPRI: i16 = 0x02;
pub const POLLOUT: i16 = 0x04;
pub const POLLWRNORM: i16 = 0x04;
pub const POLLWRBAND: i16 = 0x04;
pub const POLLHUP: i16 = 0x10;
pub const POLLRDHUP: i16 = 0x10;
pub const POLLERR: i16 = 0x08;
pub const POLLNVAL: i16 = 0x20;
pub const POLLIN: pollevent_t = 0x01;
pub const POLLRDNORM: pollevent_t = 0x01;
pub const POLLRDBAND: pollevent_t = 0x01;
pub const POLLPRI: pollevent_t = 0x02;
pub const POLLOUT: pollevent_t = 0x04;
pub const POLLWRNORM: pollevent_t = 0x04;
pub const POLLWRBAND: pollevent_t = 0x04;
pub const POLLHUP: pollevent_t = 0x10;
pub const POLLRDHUP: pollevent_t = 0x10;
pub const POLLERR: pollevent_t = 0x08;
pub const POLLNVAL: pollevent_t = 0x20;

// sys/socket.h
// Supported Protocol Families
Expand Down Expand Up @@ -696,4 +708,8 @@ extern "C" {
pub fn eventfd(count: c_uint, flags: c_int) -> c_int;
// unistd.h
pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int;

pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
pub fn sem_destroy(sem: *mut sem_t) -> c_int;
pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
}
Loading