]> git.lizzy.rs Git - rust.git/commitdiff
Fix misleading function names
authorDavid Cook <divergentdave@gmail.com>
Sun, 15 Mar 2020 20:10:08 +0000 (15:10 -0500)
committerDavid Cook <divergentdave@gmail.com>
Sun, 5 Apr 2020 15:05:34 +0000 (10:05 -0500)
src/shims/sync.rs
tests/run-pass/sync.rs

index 3208727730312ff0d261f26fb84f1325fb699ec0..22e62beae2f22a96550a6182ba63a545a3fc4420 100644 (file)
@@ -13,7 +13,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
     fn pthread_mutexattr_init(&mut self, attr_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, attr_op, 4)?;
+        assert_ptr_target_min_size(this, attr_op, 4)?;
 
         let attr = this.read_scalar(attr_op)?.not_undef()?;
         if this.is_null(attr)? {
@@ -36,7 +36,7 @@ fn pthread_mutexattr_settype(
     ) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, attr_op, 4)?;
+        assert_ptr_target_min_size(this, attr_op, 4)?;
 
         let attr = this.read_scalar(attr_op)?.not_undef()?;
         if this.is_null(attr)? {
@@ -62,7 +62,7 @@ fn pthread_mutexattr_settype(
     fn pthread_mutexattr_destroy(&mut self, attr_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, attr_op, 4)?;
+        assert_ptr_target_min_size(this, attr_op, 4)?;
 
         let attr = this.read_scalar(attr_op)?.not_undef()?;
         if this.is_null(attr)? {
@@ -92,8 +92,8 @@ fn pthread_mutex_init(
     ) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, mutex_op, 16)?;
-        check_ptr_target_min_size(this, attr_op, 4)?;
+        assert_ptr_target_min_size(this, mutex_op, 16)?;
+        assert_ptr_target_min_size(this, attr_op, 4)?;
 
         let mutex = this.read_scalar(mutex_op)?.not_undef()?;
         if this.is_null(mutex)? {
@@ -125,7 +125,7 @@ fn pthread_mutex_init(
     fn pthread_mutex_lock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, mutex_op, 16)?;
+        assert_ptr_target_min_size(this, mutex_op, 16)?;
 
         let mutex = this.read_scalar(mutex_op)?.not_undef()?;
         if this.is_null(mutex)? {
@@ -166,7 +166,7 @@ fn pthread_mutex_lock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx
     fn pthread_mutex_trylock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, mutex_op, 16)?;
+        assert_ptr_target_min_size(this, mutex_op, 16)?;
 
         let mutex = this.read_scalar(mutex_op)?.not_undef()?;
         if this.is_null(mutex)? {
@@ -201,7 +201,7 @@ fn pthread_mutex_trylock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'
     fn pthread_mutex_unlock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, mutex_op, 16)?;
+        assert_ptr_target_min_size(this, mutex_op, 16)?;
 
         let mutex = this.read_scalar(mutex_op)?.not_undef()?;
         if this.is_null(mutex)? {
@@ -246,7 +246,7 @@ fn pthread_mutex_unlock(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'t
     fn pthread_mutex_destroy(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, mutex_op, 16)?;
+        assert_ptr_target_min_size(this, mutex_op, 16)?;
 
         let mutex = this.read_scalar(mutex_op)?.not_undef()?;
         if this.is_null(mutex)? {
@@ -277,7 +277,7 @@ fn pthread_mutex_destroy(&mut self, mutex_op: OpTy<'tcx, Tag>) -> InterpResult<'
     fn pthread_rwlock_rdlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, rwlock_op, 12)?;
+        assert_ptr_target_min_size(this, rwlock_op, 12)?;
 
         let rwlock = this.read_scalar(rwlock_op)?.not_undef()?;
         if this.is_null(rwlock)? {
@@ -301,7 +301,7 @@ fn pthread_rwlock_rdlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<
     fn pthread_rwlock_tryrdlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, rwlock_op, 12)?;
+        assert_ptr_target_min_size(this, rwlock_op, 12)?;
 
         let rwlock = this.read_scalar(rwlock_op)?.not_undef()?;
         if this.is_null(rwlock)? {
@@ -325,7 +325,7 @@ fn pthread_rwlock_tryrdlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResu
     fn pthread_rwlock_wrlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, rwlock_op, 12)?;
+        assert_ptr_target_min_size(this, rwlock_op, 12)?;
 
         let rwlock = this.read_scalar(rwlock_op)?.not_undef()?;
         if this.is_null(rwlock)? {
@@ -351,7 +351,7 @@ fn pthread_rwlock_wrlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<
     fn pthread_rwlock_trywrlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, rwlock_op, 12)?;
+        assert_ptr_target_min_size(this, rwlock_op, 12)?;
 
         let rwlock = this.read_scalar(rwlock_op)?.not_undef()?;
         if this.is_null(rwlock)? {
@@ -375,7 +375,7 @@ fn pthread_rwlock_trywrlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResu
     fn pthread_rwlock_unlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, rwlock_op, 12)?;
+        assert_ptr_target_min_size(this, rwlock_op, 12)?;
 
         let rwlock = this.read_scalar(rwlock_op)?.not_undef()?;
         if this.is_null(rwlock)? {
@@ -402,7 +402,7 @@ fn pthread_rwlock_unlock(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<
     fn pthread_rwlock_destroy(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
-        check_ptr_target_min_size(this, rwlock_op, 12)?;
+        assert_ptr_target_min_size(this, rwlock_op, 12)?;
 
         let rwlock = this.read_scalar(rwlock_op)?.not_undef()?;
         if this.is_null(rwlock)? {
@@ -427,7 +427,7 @@ fn pthread_rwlock_destroy(&mut self, rwlock_op: OpTy<'tcx, Tag>) -> InterpResult
     }
 }
 
-fn check_ptr_target_min_size<'mir, 'tcx: 'mir>(ecx: &MiriEvalContext<'mir, 'tcx>, operand: OpTy<'tcx, Tag>, min_size: u64) -> InterpResult<'tcx, ()> {
+fn assert_ptr_target_min_size<'mir, 'tcx: 'mir>(ecx: &MiriEvalContext<'mir, 'tcx>, operand: OpTy<'tcx, Tag>, min_size: u64) -> InterpResult<'tcx, ()> {
     let target_ty = match operand.layout.ty.kind {
         TyKind::RawPtr(TypeAndMut{ ty, mutbl: _ }) => ty,
         _ => panic!("Argument to pthread function was not a raw pointer"),
index b247061083798411ec252fa8a126d9f20533bb92..c1e44789aa74e4e8ee3eb93a464197559cc6de2c 100644 (file)
@@ -10,7 +10,7 @@ fn main() {
     {
         test_mutex_libc_recursive();
         test_rwlock_stdlib();
-        test_rwlock_libc_init();
+        test_mutex_libc_init();
         test_rwlock_libc_static_initializer();
     }
 }
@@ -68,7 +68,7 @@ fn test_rwlock_stdlib() {
 // std::sys::unix::rwlock::RWLock keeps track of write_locked and num_readers
 
 #[cfg(not(target_os = "windows"))]
-fn test_rwlock_libc_init() {
+fn test_mutex_libc_init() {
     unsafe {
         let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
         assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, std::ptr::null_mut()), 0);