Last active
August 29, 2015 14:13
-
-
Save aldanor/1f5b0a61dc905023b788 to your computer and use it in GitHub Desktop.
hdf5 thread safety in rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(unstable)] | |
extern crate libc; | |
#[allow(unstable)] | |
mod test { | |
use libc::c_int; | |
use std::sync::{StaticMutex, MUTEX_INIT}; | |
static LOCK: StaticMutex = MUTEX_INIT; | |
#[link(name = "hdf5")] | |
extern { | |
static H5E_ERR_CLS_g: c_int; | |
fn H5open() -> c_int; | |
} | |
fn get_err_cls() -> c_int { | |
unsafe { | |
let _ = LOCK.lock().unwrap(); | |
H5open(); | |
} | |
H5E_ERR_CLS_g | |
} | |
#[test] | |
fn test1() { println!("test1(): H5E_ERR_CLS_g = {}", get_err_cls()); } | |
#[test] | |
fn test2() { println!("test1(): H5E_ERR_CLS_g = {}", get_err_cls()); } | |
#[test] | |
fn test3() { println!("test1(): H5E_ERR_CLS_g = {}", get_err_cls()); } | |
} |
Author
aldanor
commented
Jan 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment