macros: Move the wrapping macro in a separate file

Will be reused.
This commit is contained in:
Luca Barbato 2017-03-15 14:09:48 +00:00
parent 37b2dc1b70
commit 75564b8439
3 changed files with 14 additions and 10 deletions

View File

@ -8,16 +8,6 @@ pub struct CuDevice {
device: CUdevice,
}
macro_rules! wrap {
($val:ident, $res:ident) => (
if $res == CUDA_SUCCESS {
Ok($val)
} else {
Err($res)
}
)
}
impl CuDevice {
pub fn new(ordinal: c_int) -> Result<CuDevice, CUresult> {
let mut d = CuDevice { device: 0 };

View File

@ -1,3 +1,6 @@
extern crate nvidia_video_codec_sys as ffi;
#[macro_use]
mod macros;
pub mod cuda;

11
src/macros.rs Normal file
View File

@ -0,0 +1,11 @@
macro_rules! wrap {
($val:ident, $res:ident) => (
if $res == CUDA_SUCCESS {
Ok($val)
} else {
Err($res)
}
)
}