From a98188f8d4b55000dd8eee043bb7b9e54d516aad Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Mon, 25 Jun 2018 18:21:06 +0000 Subject: [PATCH 1/2] Enable CUDA target --- src/lib.rs | 3 ++- src/unix/notbsd/cuda.rs | 3 +++ src/unix/notbsd/mod.rs | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/unix/notbsd/cuda.rs diff --git a/src/lib.rs b/src/lib.rs index c997960a4b29c..80d41b7608748 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; @@ -284,7 +285,7 @@ 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; diff --git a/src/unix/notbsd/cuda.rs b/src/unix/notbsd/cuda.rs new file mode 100644 index 0000000000000..1310d9d4ef866 --- /dev/null +++ b/src/unix/notbsd/cuda.rs @@ -0,0 +1,3 @@ +pub type c_char = i8; +pub type c_long = i64; +pub type c_ulong = u64; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 6e4500684e136..6bc6f485c38f5 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -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 } From d2d779cfd7addb690790fd91230b2f3f83ae6c78 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Wed, 4 Jul 2018 16:05:14 +0000 Subject: [PATCH 2/2] malloc/free for CUDA --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 80d41b7608748..eb6210970d8b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -293,6 +293,14 @@ cfg_if! { 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; + } } }