async_cuda_core/ffi/mod.rs
1mod includes;
2
3pub mod device;
4pub mod error;
5pub mod memory;
6pub mod ptr;
7pub mod stream;
8
9/// Convenience macro for turning a CUDA error code into a `std::result::Result`.
10///
11/// # Usage
12///
13/// There are two possible uses of the macro:
14///
15/// (1) Shorthand to return `Ok(something)` or a CUDA error:
16///
17/// ```ignore
18/// result!(code, return_value);
19/// ```
20///
21/// (2) Shorthand to return `Ok(())` or a CUDA error:
22///
23/// ```ignore
24/// result!(code)
25/// ```
26macro_rules! result {
27 ($code:expr, $ok:expr) => {
28 if $code == 0 {
29 Ok($ok)
30 } else {
31 Err($crate::error::Error::Cuda($code))
32 }
33 };
34 ($code:expr) => {
35 result!($code, ())
36 };
37}
38
39use result;