Skip to content

Commit

Permalink
Fix Android build.
Browse files Browse the repository at this point in the history
  • Loading branch information
naga-cf authored and vkrasnov committed Feb 24, 2021
1 parent 83b148c commit e2b6960
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/jni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::ptr;

use jni::objects::{JByteBuffer, JClass, JString};
use jni::strings::JNIStr;
use jni::sys::{jbyteArray, jint, jlong, jstring};
use jni::sys::{jbyteArray, jint, jlong, jshort, jstring};
use jni::JNIEnv;

use crate::crypto::x25519::X25519SecretKey;
Expand Down Expand Up @@ -132,6 +132,8 @@ pub unsafe extern "C" fn create_new_tunnel(
_class: JClass,
arg_secret_key: JString,
arg_public_key: JString,
keep_alive: jshort,
index: jint,
) -> jlong {
let secret_key = match env.get_string_utf_chars(arg_secret_key) {
Ok(v) => v,
Expand All @@ -143,7 +145,14 @@ pub unsafe extern "C" fn create_new_tunnel(
Err(_) => return 0,
};

let tunnel = new_tunnel(secret_key, public_key, Some(log_print), 3);
let tunnel = new_tunnel(
secret_key,
public_key,
keep_alive as u16,
index as u32,
Some(log_print),
3,
);

if tunnel.is_null() {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

pub mod crypto;

#[cfg(not(target_os = "windows"))]
#[cfg(not(any(target_os = "windows", target_os = "android")))]
pub mod device;

pub mod ffi;
Expand Down
5 changes: 4 additions & 1 deletion src/noise/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ mod tests {
impl SpinLock {
pub fn lock(&self) {
loop {
if self.lock.compare_and_swap(true, false, Ordering::Relaxed) {
if let Ok(true) =
self.lock
.compare_exchange(true, false, Ordering::SeqCst, Ordering::SeqCst)
{
break;
}
}
Expand Down

0 comments on commit e2b6960

Please sign in to comment.