Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Enable CUDA target #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ cfg_if! {
pub const INT_MIN: c_int = -2147483648;
pub const INT_MAX: c_int = 2147483647;

#[cfg(not(target_os = "cuda"))]
extern {
pub fn isalnum(c: c_int) -> c_int;
pub fn isalpha(c: c_int) -> c_int;
Expand Down Expand Up @@ -284,14 +285,22 @@ cfg_if! {

// These are all inline functions on android, so they end up just being entirely
// missing on that platform.
#[cfg(not(target_os = "android"))]
#[cfg(all(not(target_os = "android"), not(target_os = "cuda")))]
extern {
pub fn abs(i: c_int) -> c_int;
pub fn atof(s: *const c_char) -> c_double;
pub fn labs(i: c_long) -> c_long;
pub fn rand() -> c_int;
pub fn srand(seed: c_uint);
}

#[cfg(target_os = "cuda")]
extern {
pub fn malloc(size: size_t) -> *mut c_void;
pub fn free(p: *mut c_void);
pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/unix/notbsd/cuda.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
3 changes: 3 additions & 0 deletions src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,9 @@ cfg_if! {
} else if #[cfg(target_os = "android")] {
mod android;
pub use self::android::*;
} else if #[cfg(target_os = "cuda")] {
mod cuda;
pub use self::cuda::*;
} else {
// Unknown target_os
}
Expand Down