Skip to content

Commit f85c7a2

Browse files
authored
Merge pull request rust-lang#173 from dwrensha/fix-tls-test
fix thread-local-no-dtor test on MacOS and ignore it on Windows
2 parents c817e6e + 7624bca commit f85c7a2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/terminator/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,11 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
724724
// Hook pthread calls that go to the thread-local storage memory subsystem
725725
"pthread_key_create" => {
726726
let key_ptr = args[0].read_ptr(&self.memory)?;
727-
727+
728728
// Extract the function type out of the signature (that seems easier than constructing it ourselves...)
729729
let dtor_ptr = args[1].read_ptr(&self.memory)?;
730730
let dtor = if dtor_ptr.is_null_ptr() { None } else { Some(self.memory.get_fn(dtor_ptr.alloc_id)?) };
731-
731+
732732
// Figure out how large a pthread TLS key actually is. This is libc::pthread_key_t.
733733
let key_size = match self.operand_ty(&arg_operands[0]).sty {
734734
TypeVariants::TyRawPtr(TypeAndMut { ty, .. }) => {
@@ -737,14 +737,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
737737
}
738738
_ => return Err(EvalError::AbiViolation("Wrong signature used for pthread_key_create: First argument must be a raw pointer.".to_owned()))
739739
};
740-
740+
741741
// Create key and write it into the memory where key_ptr wants it
742-
let key = self.memory.create_tls_key(dtor);
743-
if key >= (1 << key_size.bits()) {
742+
let key = self.memory.create_tls_key(dtor) as u128;
743+
if key_size.bits() < 128 && key >= (1u128 << key_size.bits() as u128) {
744744
return Err(EvalError::OutOfTls);
745745
}
746-
self.memory.write_int(key_ptr, key as i128, key_size.bytes())?;
747-
746+
self.memory.write_uint(key_ptr, key, key_size.bytes())?;
747+
748748
// Return success (0)
749749
self.write_primval(dest, PrimVal::Bytes(0), dest_ty)?;
750750
}

tests/run-pass/thread-local-no-dtor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//ignore-windows-gnu
2+
13
#![feature(libc)]
24
extern crate libc;
35

0 commit comments

Comments
 (0)