Skip to content

Commit

Permalink
feat: add aio for solarish
Browse files Browse the repository at this point in the history
(backport <rust-lang#4033>)
(cherry picked from commit ccc0b07)
  • Loading branch information
Berrysoft authored and tgross35 committed Nov 16, 2024
1 parent a2fb7e7 commit fdd5a22
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ fn test_solarish(target: &str) {

headers! {
cfg:
"aio.h",
"ctype.h",
"dirent.h",
"dlfcn.h",
Expand Down Expand Up @@ -1009,6 +1010,11 @@ fn test_solarish(target: &str) {
}
});

cfg.skip_field_type(move |struct_, field| {
// aio_buf is "volatile void*"
struct_ == "aiocb" && field == "aio_buf"
});

cfg.skip_field(move |s, field| {
match s {
// C99 sizing on this is tough
Expand Down Expand Up @@ -1087,6 +1093,12 @@ fn test_solarish(target: &str) {
// excluded from the tests.
"getifaddrs" if is_illumos => true,

// FIXME: Our API is unsound. The Rust API allows aliasing
// pointers, but the C API requires pointers not to alias.
// We should probably be at least using `&`/`&mut` here, see:
// https://github.com/gnzlbg/ctest/issues/68
"lio_listio" => true,

_ => false,
}
});
Expand Down
20 changes: 20 additions & 0 deletions libc-test/semver/solarish.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
AIO_ALLDONE
AIO_CANCELED
AIO_NOTCANCELED
IPV6_DONTFRAG
IPV6_PKTINFO
IPV6_RECVTCLASS
Expand All @@ -6,9 +9,26 @@ IP_DONTFRAG
IP_PKTINFO
IP_TOS
IP_TTL
LIO_NOP
LIO_NOWAIT
LIO_READ
LIO_WAIT
LIO_WRITE
PIPE_BUF
SIGEV_PORT
aio_cancel
aio_error
aio_fsync
aio_read
aio_result_t
aio_return
aio_suspend
aio_waitn
aio_write
aiocb
bind
in6_pktinfo
in_pktinfo
lio_listio
recvmsg
sendmsg
13 changes: 13 additions & 0 deletions src/unix/solarish/illumos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ pub type lgrp_rsrc_t = ::c_int;
pub type lgrp_affinity_t = ::c_int;

s! {
pub struct aiocb {
pub aio_fildes: ::c_int,
pub aio_buf: *mut ::c_void,
pub aio_nbytes: ::size_t,
pub aio_offset: ::off_t,
pub aio_reqprio: ::c_int,
pub aio_sigevent: ::sigevent,
pub aio_lio_opcode: ::c_int,
pub aio_resultp: ::aio_result_t,
pub aio_state: ::c_int,
pub aio__pad: [::c_int; 1],
}

pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
pub shm_segsz: ::size_t,
Expand Down
39 changes: 39 additions & 0 deletions src/unix/solarish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ s! {
pub portnfy_user: *mut ::c_void,
}

pub struct aio_result_t {
pub aio_return: ::ssize_t,
pub aio_errno: ::c_int,
}

pub struct exit_status {
e_termination: ::c_short,
e_exit: ::c_short,
Expand Down Expand Up @@ -1133,9 +1138,19 @@ pub const SIG_BLOCK: ::c_int = 1;
pub const SIG_UNBLOCK: ::c_int = 2;
pub const SIG_SETMASK: ::c_int = 3;

pub const AIO_CANCELED: ::c_int = 0;
pub const AIO_ALLDONE: ::c_int = 1;
pub const AIO_NOTCANCELED: ::c_int = 2;
pub const LIO_NOP: ::c_int = 0;
pub const LIO_READ: ::c_int = 1;
pub const LIO_WRITE: ::c_int = 2;
pub const LIO_NOWAIT: ::c_int = 0;
pub const LIO_WAIT: ::c_int = 1;

pub const SIGEV_NONE: ::c_int = 1;
pub const SIGEV_SIGNAL: ::c_int = 2;
pub const SIGEV_THREAD: ::c_int = 3;
pub const SIGEV_PORT: ::c_int = 4;

pub const CLD_EXITED: ::c_int = 1;
pub const CLD_KILLED: ::c_int = 2;
Expand Down Expand Up @@ -3045,6 +3060,30 @@ extern "C" {

pub fn sync();

pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
pub fn aio_suspend(
aiocb_list: *const *const aiocb,
nitems: ::c_int,
timeout: *const ::timespec,
) -> ::c_int;
pub fn aio_waitn(
aiocb_list: *mut *mut aiocb,
nent: ::c_uint,
nwait: *mut ::c_uint,
timeout: *const ::timespec,
) -> ::c_int;
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
pub fn lio_listio(
mode: ::c_int,
aiocb_list: *const *mut aiocb,
nitems: ::c_int,
sevp: *mut sigevent,
) -> ::c_int;

pub fn __major(version: ::c_int, devnum: ::dev_t) -> ::major_t;
pub fn __minor(version: ::c_int, devnum: ::dev_t) -> ::minor_t;
pub fn __makedev(version: ::c_int, majdev: ::major_t, mindev: ::minor_t) -> ::dev_t;
Expand Down
15 changes: 15 additions & 0 deletions src/unix/solarish/solaris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ e! {
}

s! {
pub struct aiocb {
pub aio_fildes: ::c_int,
pub aio_buf: *mut ::c_void,
pub aio_nbytes: ::size_t,
pub aio_offset: ::off_t,
pub aio_reqprio: ::c_int,
pub aio_sigevent: ::sigevent,
pub aio_lio_opcode: ::c_int,
pub aio_resultp: ::aio_result_t,
pub aio_state: ::c_char,
pub aio_returned: ::c_char,
pub aio__pad1: [::c_char; 2],
pub aio_flags: ::c_int,
}

pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
pub shm_segsz: ::size_t,
Expand Down

0 comments on commit fdd5a22

Please sign in to comment.