]> git.lizzy.rs Git - rust.git/blobdiff - src/shims/tls.rs
Fix merge conflicts
[rust.git] / src / shims / tls.rs
index abe6dd958693c79396504d082e80e364ae109aea..b6aadd31a5be673688b3dffd825ca82e9e2db13a 100644 (file)
@@ -6,7 +6,7 @@
 use rustc::{ty, ty::layout::HasDataLayout};
 
 use crate::{
-    InterpResult, InterpError, StackPopCleanup,
+    InterpResult, StackPopCleanup,
     MPlaceTy, Scalar, Tag,
     HelpersEvalContextExt,
 };
@@ -18,17 +18,17 @@ pub struct TlsEntry<'tcx> {
     /// The data for this key. None is used to represent NULL.
     /// (We normalize this early to avoid having to do a NULL-ptr-test each time we access the data.)
     /// Will eventually become a map from thread IDs to `Scalar`s, if we ever support more than one thread.
-    pub(crate) data: Option<Scalar<Tag>>,
-    pub(crate) dtor: Option<ty::Instance<'tcx>>,
+    data: Option<Scalar<Tag>>,
+    dtor: Option<ty::Instance<'tcx>>,
 }
 
 #[derive(Debug)]
 pub struct TlsData<'tcx> {
     /// The Key to use for the next thread-local allocation.
-    pub(crate) next_key: TlsKey,
+    next_key: TlsKey,
 
     /// pthreads-style thread-local storage.
-    pub(crate) keys: BTreeMap<TlsKey, TlsEntry<'tcx>>,
+    keys: BTreeMap<TlsKey, TlsEntry<'tcx>>,
 }
 
 impl<'tcx> Default for TlsData<'tcx> {
@@ -53,7 +53,7 @@ pub fn create_tls_key(
                 data: None,
                 dtor,
             },
-        );
+        ).unwrap_none();
         trace!("New TLS key allocated: {} with dtor {:?}", new_key, dtor);
         new_key
     }
@@ -64,7 +64,7 @@ pub fn delete_tls_key(&mut self, key: TlsKey) -> InterpResult<'tcx> {
                 trace!("TLS key {} removed", key);
                 Ok(())
             }
-            None => err!(TlsOutOfBounds),
+            None => throw_unsup!(TlsOutOfBounds),
         }
     }
 
@@ -78,7 +78,7 @@ pub fn load_tls(
                 trace!("TLS key {} loaded: {:?}", key, data);
                 Ok(data.unwrap_or_else(|| Scalar::ptr_null(cx).into()))
             }
-            None => err!(TlsOutOfBounds),
+            None => throw_unsup!(TlsOutOfBounds),
         }
     }
 
@@ -89,7 +89,7 @@ pub fn store_tls(&mut self, key: TlsKey, new_data: Option<Scalar<Tag>>) -> Inter
                 *data = new_data;
                 Ok(())
             }
-            None => err!(TlsOutOfBounds),
+            None => throw_unsup!(TlsOutOfBounds),
         }
     }
 
@@ -148,7 +148,7 @@ fn run_tls_dtors(&mut self) -> InterpResult<'tcx> {
             assert!(!this.is_null(ptr).unwrap(), "Data can't be NULL when dtor is called!");
             // TODO: Potentially, this has to support all the other possible instances?
             // See eval_fn_call in interpret/terminator/mod.rs
-            let mir = this.load_mir(instance.def)?;
+            let mir = this.load_mir(instance.def, None)?;
             let ret_place = MPlaceTy::dangling(this.layout_of(this.tcx.mk_unit())?, this).into();
             this.push_stack_frame(
                 instance,
@@ -158,7 +158,7 @@ fn run_tls_dtors(&mut self) -> InterpResult<'tcx> {
                 StackPopCleanup::None { cleanup: true },
             )?;
             let arg_local = this.frame().body.args_iter().next().ok_or_else(
-                || InterpError::AbiViolation("TLS dtor does not take enough arguments.".to_owned()),
+                || err_ub_format!("TLS dtor does not take enough arguments."),
             )?;
             let dest = this.local_place(arg_local)?;
             this.write_scalar(ptr, dest)?;