1
Fork 0

test thread-local key with no dtor

This commit is contained in:
Ralf Jung 2017-05-30 10:41:22 -07:00
parent 24a9a14dfa
commit dad95474cb
2 changed files with 16 additions and 1 deletions

View file

@ -727,7 +727,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
// Extract the function type out of the signature (that seems easier than constructing it ourselves...)
let dtor_ptr = args[1].read_ptr(&self.memory)?;
// TODO: The null-pointer case here is entirely untested
let dtor = if dtor_ptr.is_null_ptr() { None } else { Some(self.memory.get_fn(dtor_ptr.alloc_id)?) };
// Figure out how large a pthread TLS key actually is. This is libc::pthread_key_t.

View file

@ -0,0 +1,16 @@
#![feature(libc)]
extern crate libc;
use std::mem;
pub type Key = libc::pthread_key_t;
pub unsafe fn create(dtor: Option<unsafe extern fn(*mut u8)>) -> Key {
let mut key = 0;
assert_eq!(libc::pthread_key_create(&mut key, mem::transmute(dtor)), 0);
key
}
fn main() {
let _ = unsafe { create(None) };
}