Skip to content

Commit be8f315

Browse files
authored
Merge pull request #17 from lancastr/compilation-fixes
Compilation fixes
2 parents 58210be + 9dcdf71 commit be8f315

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

aio-bindings/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ license = "MIT"
99
[dependencies]
1010

1111
[build-dependencies]
12-
bindgen = "0.37.0"
12+
bindgen = "0.47.1"

aio-bindings/build.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@ use std::env;
44
use std::path::PathBuf;
55

66
fn main() {
7-
// Tell cargo to tell rustc to link the system bzip2
8-
// shared library.
9-
println!("cargo:rustc-link-lib=bz2");
7+
let target = env::var("TARGET").expect("Cargo build scripts always have TARGET");
108

119
// The bindgen::Builder is the main entry point
1210
// to bindgen, and lets you build up options for
1311
// the resulting bindings.
14-
let bindings = bindgen::Builder::default()
12+
let mut bindings = bindgen::Builder::default()
1513
.trust_clang_mangling(false)
16-
// The input header we would like to generate
14+
.clang_arg("-target")
15+
.clang_arg(target);
16+
17+
if let Ok(sysroot) = env::var("SYSROOT") {
18+
bindings = bindings
19+
.clang_arg("--sysroot")
20+
.clang_arg(sysroot);
21+
}
22+
23+
let bindings = bindings
24+
// The input header we would like to generate
1725
// bindings for.
1826
.header("wrapper.h")
1927
// Finish the builder and generate the bindings.

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ struct RequestState {
119119
request: aio::iocb,
120120

121121
// Concurrency primitive to notify completion to the associated future
122-
completed_receiver: futures::sync::oneshot::Receiver<c_long>,
122+
completed_receiver: futures::sync::oneshot::Receiver<aio_bindings::__s64>,
123123

124124
// We have both sides of a oneshot channel here
125-
completed_sender: Option<futures::sync::oneshot::Sender<c_long>>,
125+
completed_sender: Option<futures::sync::oneshot::Sender<aio_bindings::__s64>>,
126126
}
127127

128128
// Common data structures for futures returned by `AioContext`.
@@ -170,7 +170,7 @@ impl AioBaseFuture {
170170
let state_addr = state.deref().deref() as *const RequestState;
171171

172172
// Fill in the iocb data structure to be submitted to the kernel
173-
state.request.aio_data = unsafe { mem::transmute(state_addr) };
173+
state.request.aio_data = unsafe { mem::transmute::<_, usize>(state_addr) } as u64;
174174
state.request.aio_resfd = self.context.completed_fd as u32;
175175
state.request.aio_flags = aio::IOCB_FLAG_RESFD | self.iocb_info.flags;
176176
state.request.aio_fildes = self.iocb_info.fd as u32;
@@ -411,7 +411,7 @@ impl futures::Future for AioPollFuture {
411411

412412
// dispatch the retrieved events to the associated futures
413413
for ref event in &self.events {
414-
let request_state: &mut RequestState = unsafe { mem::transmute(event.data) };
414+
let request_state: &mut RequestState = unsafe { mem::transmute(event.data as usize) } ;
415415
request_state
416416
.completed_sender
417417
.take()
@@ -572,7 +572,7 @@ impl AioContext {
572572
let (ptr, len) = {
573573
let buffer = buffer_obj.as_mut();
574574
let len = buffer.len() as u64;
575-
let ptr = unsafe { mem::transmute(buffer.as_ptr()) };
575+
let ptr = unsafe { mem::transmute::<_, usize>(buffer.as_ptr()) } as u64;
576576
(ptr, len)
577577
};
578578

@@ -639,7 +639,7 @@ impl AioContext {
639639
let (ptr, len) = {
640640
let buffer = buffer_obj.as_ref();
641641
let len = buffer.len() as u64;
642-
let ptr = unsafe { mem::transmute(buffer.as_ptr()) };
642+
let ptr = unsafe { mem::transmute::<_, usize>(buffer.as_ptr()) } as c_long;
643643
(ptr, len)
644644
};
645645

@@ -652,7 +652,7 @@ impl AioContext {
652652
fd,
653653
offset,
654654
len,
655-
buf: ptr,
655+
buf: ptr as u64,
656656
flags: sync_level as u32,
657657
},
658658
state: None,

0 commit comments

Comments
 (0)