Skip to content

Commit

Permalink
Auto merge of #2018 - asomers:aio_no_librt, r=JohnTitor
Browse files Browse the repository at this point in the history
aio functions do not require librt on FreeBSD

On FreeBSD, the aio_ functions require librt _only_ if they use
SIGEV_THREAD completion notification.  However, due to Rust's originally
poor support for C unions, libc doesn't even expose some of the fields of
struct sigevent that SIGEV_THREAD requires.  Accordingly, there is no
need to link librt to programs using aio via libc.

This change partially reverts 8c23f77
from PR #1630 .

While I'm here, fix the linkage of lio_listio on DragonflyBSD.  It
_does_ require librt.
  • Loading branch information
bors committed Jan 5, 2021
2 parents 7e7452f + f40f306 commit 9d6d018
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
21 changes: 21 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Expand Up @@ -1081,6 +1081,27 @@ extern "C" {
) -> *mut ::c_void;
}

#[link(name = "rt")]
extern "C" {
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_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;
}

cfg_if! {
if #[cfg(libc_thread_local)] {
mod errno;
Expand Down
19 changes: 19 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Expand Up @@ -1210,6 +1210,18 @@ safe_f! {
extern "C" {
pub fn __error() -> *mut ::c_int;

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_write(aiocbp: *mut aiocb) -> ::c_int;

pub fn extattr_delete_fd(
fd: ::c_int,
attrnamespace: ::c_int,
Expand Down Expand Up @@ -1300,6 +1312,13 @@ extern "C" {
flags: ::c_int,
) -> ::c_int;

pub fn lio_listio(
mode: ::c_int,
aiocb_list: *const *mut aiocb,
nitems: ::c_int,
sevp: *mut sigevent,
) -> ::c_int;

pub fn posix_fallocate(
fd: ::c_int,
offset: ::off_t,
Expand Down
17 changes: 0 additions & 17 deletions src/unix/bsd/freebsdlike/mod.rs
Expand Up @@ -1393,12 +1393,6 @@ extern "C" {
timeout: *const ::timespec,
) -> ::c_int;
pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int;
pub fn lio_listio(
mode: ::c_int,
aiocb_list: *const *mut aiocb,
nitems: ::c_int,
sevp: *mut sigevent,
) -> ::c_int;
pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int;
pub fn memrchr(
cx: *const ::c_void,
Expand Down Expand Up @@ -1603,17 +1597,6 @@ extern "C" {

#[link(name = "rt")]
extern "C" {
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_fsync(op: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn aio_error(aiocbp: *const 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_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int;
pub fn mq_notify(mqd: ::mqd_t, notification: *const ::sigevent)
Expand Down

0 comments on commit 9d6d018

Please sign in to comment.