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
4 changes: 2 additions & 2 deletions src/unix/newlib/horizon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub type c_ulong = u32;

pub type wchar_t = ::c_uint;

pub type in_port_t = ::c_ushort;
pub type u_register_t = ::c_uint;
pub type u_char = ::c_uchar;
pub type u_short = ::c_ushort;
Expand Down Expand Up @@ -34,8 +33,9 @@ s! {

pub struct sockaddr_in {
pub sin_family: ::sa_family_t,
pub sin_port: in_port_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_uchar; 8],
}

pub struct sockaddr_in6 {
Expand Down
83 changes: 59 additions & 24 deletions src/unix/newlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,6 @@ s! {
pub tm_isdst: ::c_int,
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: dev_t,
pub st_size: off_t,
pub st_atime: time_t,
pub st_spare1: ::c_long,
pub st_mtime: time_t,
pub st_spare2: ::c_long,
pub st_ctime: time_t,
pub st_spare3: ::c_long,
pub st_blksize: blksize_t,
pub st_blocks: blkcnt_t,
pub st_spare4: [::c_long; 2usize],
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was kinda invasive, I could swap it out for a few #[cfg()] instead, but unfortunately it seems s! is incompatible with cfg_if! (which would otherwise be more readable).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to see if this is fixable, but it would require something like https://docs.rs/eager.


pub struct statvfs {
pub f_bsize: ::c_ulong,
Expand All @@ -163,10 +144,6 @@ s! {
pub f_namemax: ::c_ulong,
}

pub struct sigset_t {
__val: [::c_ulong; 16],
}

pub struct sigaction {
pub sa_handler: extern fn(arg1: ::c_int),
pub sa_mask: sigset_t,
Expand Down Expand Up @@ -242,6 +219,57 @@ s! {
}
}

cfg_if! {
if #[cfg(target_os = "horizon")] {
pub type sigset_t = ::c_ulong;

s! {
pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: dev_t,
pub st_size: off_t,
pub st_atim: ::timespec,
Comment thread
ian-h-chamberlain marked this conversation as resolved.
pub st_mtim: ::timespec,
pub st_ctim: ::timespec,
pub st_blksize: blksize_t,
pub st_blocks: blkcnt_t,
pub st_spare4: [::c_long; 2usize],
}
}
} else {
s! {
pub struct sigset_t {
__val: [::c_ulong; 16],
}

pub struct stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: dev_t,
pub st_size: off_t,
pub st_atime: time_t,
pub st_spare1: ::c_long,
pub st_mtime: time_t,
pub st_spare2: ::c_long,
pub st_ctime: time_t,
pub st_spare3: ::c_long,
pub st_blksize: blksize_t,
pub st_blocks: blkcnt_t,
pub st_spare4: [::c_long; 2usize],
}
}
}
}

// unverified constants
align_const! {
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
Expand Down Expand Up @@ -283,7 +311,14 @@ pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1;
pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
pub const FD_SETSIZE: usize = 1024;

cfg_if! {
if #[cfg(target_os = "horizon")] {
pub const FD_SETSIZE: usize = 64;
} else {
pub const FD_SETSIZE: usize = 1024;
}
}
// intentionally not public, only used for fd_set
const ULONG_SIZE: usize = 32;

Expand Down