Skip to content

Commit 951bd04

Browse files
committed
feat: add aio for solarish
1 parent 3a0b044 commit 951bd04

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

libc-test/build.rs

+12
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ fn test_solarish(target: &str) {
786786

787787
headers! {
788788
cfg:
789+
"aio.h",
789790
"ctype.h",
790791
"dirent.h",
791792
"dlfcn.h",
@@ -948,6 +949,11 @@ fn test_solarish(target: &str) {
948949
}
949950
});
950951

952+
cfg.skip_field_type(move |struct_, field| {
953+
// aio_buf is "volatile void*"
954+
struct_ == "aiocb" && field == "aio_buf"
955+
});
956+
951957
cfg.skip_field(move |s, field| {
952958
match s {
953959
// C99 sizing on this is tough
@@ -1026,6 +1032,12 @@ fn test_solarish(target: &str) {
10261032
// excluded from the tests.
10271033
"getifaddrs" if is_illumos => true,
10281034

1035+
// FIXME: Our API is unsound. The Rust API allows aliasing
1036+
// pointers, but the C API requires pointers not to alias.
1037+
// We should probably be at least using `&`/`&mut` here, see:
1038+
// https://github.com/gnzlbg/ctest/issues/68
1039+
"lio_listio" => true,
1040+
10291041
_ => false,
10301042
}
10311043
});

libc-test/semver/solarish.txt

+20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
AIO_ALLDONE
2+
AIO_CANCELED
3+
AIO_NOTCANCELED
14
IPV6_DONTFRAG
25
IPV6_PKTINFO
36
IPV6_RECVTCLASS
@@ -6,12 +9,29 @@ IP_DONTFRAG
69
IP_PKTINFO
710
IP_TOS
811
IP_TTL
12+
LIO_NOP
13+
LIO_NOWAIT
14+
LIO_READ
15+
LIO_WAIT
16+
LIO_WRITE
917
PIPE_BUF
18+
SIGEV_PORT
19+
aio_cancel
20+
aio_error
21+
aio_fsync
22+
aio_read
23+
aio_result_t
24+
aio_return
25+
aio_suspend
26+
aio_waitn
27+
aio_write
28+
aiocb
1029
arc4random
1130
arc4random_buf
1231
arc4random_uniform
1332
bind
1433
in6_pktinfo
1534
in_pktinfo
35+
lio_listio
1636
recvmsg
1737
sendmsg

src/unix/solarish/mod.rs

+52
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,24 @@ s! {
420420
pub portnfy_user: *mut ::c_void,
421421
}
422422

423+
pub struct aio_result_t {
424+
pub aio_return: ::ssize_t,
425+
pub aio_errno: ::c_int,
426+
}
427+
428+
pub struct aiocb {
429+
pub aio_fildes: ::c_int,
430+
pub aio_buf: *mut ::c_void,
431+
pub aio_nbytes: ::size_t,
432+
pub aio_offset: ::off_t,
433+
pub aio_reqprio: ::c_int,
434+
pub aio_sigevent: sigevent,
435+
pub aio_lio_opcode: ::c_int,
436+
pub aio_resultp: ::aio_result_t,
437+
pub aio_state: ::c_int,
438+
pub aio__pad: [::c_int; 1],
439+
}
440+
423441
pub struct exit_status {
424442
e_termination: ::c_short,
425443
e_exit: ::c_short,
@@ -1123,9 +1141,19 @@ pub const SIG_BLOCK: ::c_int = 1;
11231141
pub const SIG_UNBLOCK: ::c_int = 2;
11241142
pub const SIG_SETMASK: ::c_int = 3;
11251143

1144+
pub const AIO_CANCELED: ::c_int = 0;
1145+
pub const AIO_ALLDONE: ::c_int = 1;
1146+
pub const AIO_NOTCANCELED: ::c_int = 2;
1147+
pub const LIO_NOP: ::c_int = 0;
1148+
pub const LIO_READ: ::c_int = 1;
1149+
pub const LIO_WRITE: ::c_int = 2;
1150+
pub const LIO_NOWAIT: ::c_int = 0;
1151+
pub const LIO_WAIT: ::c_int = 1;
1152+
11261153
pub const SIGEV_NONE: ::c_int = 1;
11271154
pub const SIGEV_SIGNAL: ::c_int = 2;
11281155
pub const SIGEV_THREAD: ::c_int = 3;
1156+
pub const SIGEV_PORT: ::c_int = 4;
11291157

11301158
pub const CLD_EXITED: ::c_int = 1;
11311159
pub const CLD_KILLED: ::c_int = 2;
@@ -3035,6 +3063,30 @@ extern "C" {
30353063

30363064
pub fn sync();
30373065

3066+
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
3067+
pub fn aio_error(aiocbp: *const aiocb) -> ::c_int;
3068+
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
3069+
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
3070+
pub fn aio_return(aiocbp: *mut aiocb) -> ::ssize_t;
3071+
pub fn aio_suspend(
3072+
aiocb_list: *const *const aiocb,
3073+
nitems: ::c_int,
3074+
timeout: *const ::timespec,
3075+
) -> ::c_int;
3076+
pub fn aio_waitn(
3077+
aiocb_list: *mut *mut aiocb,
3078+
nent: ::c_uint,
3079+
nwait: *mut ::c_uint,
3080+
timeout: *const ::timespec,
3081+
) -> ::c_int;
3082+
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
3083+
pub fn lio_listio(
3084+
mode: ::c_int,
3085+
aiocb_list: *const *mut aiocb,
3086+
nitems: ::c_int,
3087+
sevp: *mut sigevent,
3088+
) -> ::c_int;
3089+
30383090
pub fn __major(version: ::c_int, devnum: ::dev_t) -> ::major_t;
30393091
pub fn __minor(version: ::c_int, devnum: ::dev_t) -> ::minor_t;
30403092
pub fn __makedev(version: ::c_int, majdev: ::major_t, mindev: ::minor_t) -> ::dev_t;

0 commit comments

Comments
 (0)